Description Usage Arguments Value Examples
Combines various simulating functions to generate "experiments" composed of multiple trends based on provided parameters. This function is meant as a template for custom simulations.
1 | simulate_timecourse(n.trends, p, param, n.samples = 10, n.experiments = 1)
|
n.trends |
Number of trends to generate per "experiment" i.e. number of metabolites. |
p |
A vector of fractions representing the proportions of decreasing, increasing, and concave trends (in that order). If the fractions don't sum to one, the remainder of the trends are assumed to be linear (undetermined). Note that floor() will be applied to convert final numbers to integers. |
param |
A list of parameters to be fed into the simulation of various time-course components. Parameters must be specified for maximum concentration, relative changes in concentration, measurement standard deviations, and the trends themselves. Each component has a qualifier (max, change, sd, trend) that is appended to the name of the argument used in the function e.g. max.par1 is used to set par1 for simulating maximum concentrations. To specify different parameters for each type of trend, append trend qualifier e.g. max.par1.decreasing can be used to set the maximum concentrations of only decreasing trends, with max.par1 used for all other trends. |
n.samples |
Number of timepoints within each trend. |
n.experiments |
Number of "experiments". |
A "long" dataframe with the following columns: experiment, metabolite, sample, concentration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # Constructing realistic list of parameters
# (this list of parameters can be loaded using data(timecourse_param) with
# an example simulation loaded using data(timecourse))
param <- list(
# Maximum concentrations are the same for every trend type
p.max = 0.3,
par1.max = c(7, 2),
par2.max = c(0.5, 2),
con.max = c(0, 50),
# Global change parameters are near 100% for increasing/concave trends
par1.change = c(5, 0.1),
con.change = c(0.5, 1),
# Decreasing trends can have a wide variety of changes
p.change.decreasing = 0.7,
par1.change.decreasing = c(2, 5),
par2.change.decreasing = c(0.5, 0.5),
con.change.decreasing = c(0.1, 1),
# Linear trends are characterized by relatively small changes
par1.change.linear = c(1, 5),
con.change.linear = c(0, 0.1),
# Measurement error is the same for every trend type (but no more than 20%)
p.sd = 0.7,
par1.sd = c(0.04, 0.02),
par2.sd = c(0.11, 0.02),
con.sd = c(0, 0.20),
# Decreasing trend specification
p.trend.decreasing = 0.05,
par1.trend.decreasing = c(0.2, 0.6, 0.10, 0.18),
par2.trend.decreasing = c(0.6, 0.9, 0.10, 0.18),
# Increasing trend specification
p.trend.increasing = 0.15,
par1.trend.increasing = c(0.045, 0.055, 0.2, 0.4),
par2.trend.increasing = c(0.945, 0.955, 0.1, 0.3),
# Concave trend specification
par1.trend.concave = c(3.5, 4.5, 2.5, 3.5, 0.0, 0.2, 0.8, 0.9),
# Linear trends are equaly split between increasing and decreasing
p.trend.linear = 0.5
)
# Generating trends
timecourse <- simulate_timecourse(10, c(0.3, 0.3, 0.3), param)
# Plotting
par(mfrow = c(5, 2), oma = c(5, 4, 1, 1) + 0.1, mar = c(1, 1, 1, 1) + 0.1)
for (metabolite in unique(timecourse$metabolite)) {
logic <- timecourse$metabolite == metabolite
plot(timecourse$sample[logic], timecourse$concentration[logic],
xlab='', ylab='')
}
title(xlab = 'Sample', ylab = 'Concentration', outer = TRUE, line = 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.