\HeaderA{sim-methods}{Method for simulating data from a mutagenetic trees mixture model}{sim.Rdash.methods}
\aliasA{sim}{sim-methods}{sim}
\aliasA{sim,RtreemixModel,character,numeric-method}{sim-methods}{sim,RtreemixModel,character,numeric.Rdash.method}
\aliasA{sim,RtreemixModel,missing,missing-method}{sim-methods}{sim,RtreemixModel,missing,missing.Rdash.method}
\keyword{methods}{sim-methods}
\keyword{misc}{sim-methods}
\begin{Description}\relax
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.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S4 method for signature 'RtreemixModel, missing,
##   missing':
sim(model, sampling.mode,
sampling.param, ...)
## S4 method for signature 'RtreemixModel, character,
##   numeric':
sim(model, sampling.mode,
                            sampling.param, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{model}] An object of the class \code{RtreemixModel} specifying
the mutagenetic trees mixture model used for drawing the patterns,
or for simulating patterns with their sampling and waiting times.
\item[\code{sampling.mode}] A \code{character} that specifies the
sampling mode ("constant" or "exponential") used in the time simulations.
\item[\code{sampling.param}] A \code{numeric} that specifies the
sampling parameter corresponding to the sampling mode given by
\code{sampling.mode}.
\item[\code{...}] \code{no.draws} is an \code{integer} larger than zero specifying the
number of patterns that should be drawn from the given mixture model.
\code{no.sim} is an \code{integer} larger than 0 giving the number of
iterations for the waiting time simulations. Its default value is
10.
\code{seed} is a positive \code{integer} specifying the random generator
seed. Its default value is (-1) and then the time is used as a
random generator.

\end{ldescription}
\end{Arguments}
\begin{Value}
The function returns an \code{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 \code{RtreemixSim} class where the
simulated patterns together with their sampling and waiting times are stored.
\end{Value}
\begin{Author}\relax
Jasmina Bogojeska
\end{Author}
\begin{References}\relax
Learning multiple evolutionary pathways from cross-sectional
data, N. Beerenwinkel et al.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{RtreemixSim-class}{RtreemixSim.Rdash.class}}, \code{\LinkA{RtreemixModel-class}{RtreemixModel.Rdash.class}},
\code{\LinkA{RtreemixData-class}{RtreemixData.Rdash.class}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## 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)
\end{ExampleCode}
\end{Examples}

