sim-methods {Rtreemix} | R Documentation

## Method for simulating data from a mutagenetic trees mixture model

### Description

This function draws a certain number of patterns from a specified mutagenetic trees mixture model. Thus, the mixture model has to be specified. When besides the mixture model also the sampling mode and its respective sampling parameter are specified, this function simulates patterns together with their waiting and sampling times from the respective model.

### Usage

    sim(model, sampling.mode, sampling.param, ...)

### Arguments

`model` | An object of the class `RtreemixModel` specifying the mutagenetic trees mixture model used for drawing the patterns, or for simulating patterns with their sampling and waiting times.
`sampling.mode` | A `character` that specifies the sampling mode ("constant" or "exponential") used in the time simulations.
`sampling.param` | A `numeric` that specifies the sampling parameter corresponding to the sampling mode given by `sampling.mode`.
`...` | `no.draws` is an `integer` larger than zero specifying the number of patterns that should be drawn from the given mixture model. `no.sim` is an `integer` larger than 0 giving the number of iterations for the waiting time simulations. Its default value is 10. `seed` is a positive `integer` specifying the random generator seed. Its default value is (-1) and then the time is used as a random generator.

### Value

The function returns an `RtreemixData` object in the case when one wants to draw a certain number of patterns from a given mixture model, i.e. when only the mutagenetic trees mixture model and the number of patterns to be drawn are specified. When besides the model also the sampling mode and the sampling parameter are given, the function returns an object from the `RtreemixSim` class where the simulated patterns together with their sampling and waiting times are stored.

### Author(s)

Jasmina Bogojeska

### References

Learning multiple evolutionary pathways from cross-sectional data, N. Beerenwinkel et al.

### See Also

`RtreemixSim-class`, `RtreemixModel-class`, `RtreemixData-class`

### Examples

    ## Create a random RtreemixModel object with 3 branchings and 9 genetic events.
    rand.mod <- generate(K = 3, no.events = 9, noise.tree = TRUE, prob = c(0.2, 0.8))

    ## Draw 300 samples from the randomly generated model rand.mod
    data <- sim(model = rand.mod, no.draws = 300)
    show(data)

    ## Create an RtreemixSim object by simulating patterns with their sampling and waiting times from a given mixture model.
    sim.data <- sim(model = rand.mod, sampling.mode = "exponential", sampling.param = 1, no.sim = 100)
    show(sim.data)
    WaitingTimes(sim.data)
    SamplingTimes(sim.data)

[Package Rtreemix version 1.50.0 Index]