gLVgenerateData: Generate random data for gLV fitting

Description Usage Arguments Value Author(s) Examples

Description

Generates random data simulating time series of cell abundances governed by Lotka Volterra dynamics

Usage

1
gLVgenerateData(species, number_of_interactions, timepoints, noise, testData)

Arguments

species

Integer describing the number of independent cellular subcommunities

number_of_interactions

Integer describing the number of non-zero interactions present in the simulated system. These are assigned randomly between the nodes or subcommunities

timepoints

Numeric vector containing the timepoints for which to compute the solutions of the model

noise

The standard deviation of the normally distributed stochastic factor added to the solution of the model at each time step

testData

Number of observations used as test dataset for validation on untrained data, taken from the last measurements of the time series.

Value

Returns a matrix. The first column displays the time points, and the remaining columns correspond each to a independent variable in the system.

Author(s)

Lukas Hirsch

Examples

 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
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (species, number_of_interactions, timepoints, 
    noise) 
{
    "requires inSilico_bio, discrete, addNoise_res"
    raw_data <- inSilico_bio(species, number_of_interactions)
    Parms <- raw_data[[2]]
    res <- raw_data[[1]]
    threshold = 3
    if (any(which(round(diff(abs(rowMeans(res[, -1])), 2), threshold) == 
        0))) {
        end <- min(which(round(diff(abs(rowMeans(res[, -1])), 
            2), threshold) == 0))
    }
    else {
        end <- nrow(res)
    }
    res <- solveLV_bio(Parms, seq(0, end, by = 0.01), res[1, 
        -1])
    discretization <- nrow(res)/timepoints
    res <- discrete(res, discretization)
    test_data <- res[(nrow(res) - 19):nrow(res), ]
    obs <- res[1:(nrow(res) - 20), ]
    obs <- addNoise_res(obs, noise)
    timepoints <- nrow(obs)
    dimensions <- ncol(obs[, -1])
    k <- sum(any(Parms == 0))/length(Parms)
    data <- list(species = species, timepoints = timepoints, 
        Parms = Parms, noise = noise, sparsity = k, obs = obs, 
        testData = test_data)
    class(data) <- "Sim_data"
    return(data)
  }

lkshrsch/gLVInterNetworks documentation built on May 21, 2019, 7:33 a.m.