Creating XML files in R
To create the XML files in R, you need to install the calibayesR - see SupportPackages for details
1 library(calibayesR)
Constructing the CaliBayes setting file
The CaliBayes settings file controls the parameters of the MCMC algorithm, such a burn-in, thin, and which simulator to use. To create this object, we use the following code:
1 wsdl = "http://calibayes1.ncl.ac.uk:81/CaliBayesService_v2.wsdl"
2 listSimulatorMethods(wsdl)
3
4 #Create settings file
5 settings = createCaliBayesSettings(wsdl, burn=10, thin=2, simulator="copasi-deterministic")
6
7 #To save the settings as an XML file
8 saveCaliBayesSettings("settings.xml", settings)
Further details can found in the associated R help files.
Encoding time course data in XML
The experimental data that the model is calibrated against is also stored in an XML file.
1 library(SBMLModels)
2 data(Decay)
3 #Plot of the experiment data for the simple decay model
4 plot(DecayData$time, DecayData$value, xlab="Time", ylab="Population level")
5 experiments = createCaliBayesExperiment(DecayData, species)
6 saveCaliBayesExperiment("experiment.xml", experiments)
7
8 #Decay$value are observations with error,
9 #where the error has a Normal distribution with mean 0, and precision tau
The distribution XML format
The CaliBayes distribution file contains the prior/posterior distribution of the species and parameters of the MCMC algorithm. To create this file, we use createCalibayes. For example
1 ################################################
2 #In practice n should be much larger - say 10^4#
3 ################################################
4 n=10
5
6 #Create a prior for the initial species level
7 species = data.frame(X=rnorm(n, 50, 1))
8
9 #Create prior for the measurement error structure
10 distributions = c('Gaussian')
11 errors = data.frame(X.tau=rnorm(n, 1, 0.01))
12
13 #Create priors for the parameters
14 parameters = data.frame(mu=runif(n,0.01,0.2))
15
16 #Create distribution object
17 prior = createCaliBayesDistribution(parameters, species, distributions, errors)
18 saveCaliBayesDistribution("distribution.xml", prior)
For further details see the R help files.