sim.morpho {dispRity} | R Documentation |
Simulates morphological data.
Description
Generates a morphological matrix using rTraitDisc
or gen.seq.HKY
functions.
Usage
sim.morpho(
tree,
characters,
states = 1,
model = "ER",
rates,
substitution = c(stats::runif, 2, 2),
invariant = TRUE,
verbose = FALSE
)
Arguments
tree |
A phylogenetic tree to use for generating the characters. |
characters |
The number of morphological characters to generate. |
states |
A |
model |
Either an implemented ( |
rates |
A function an its parameters for the rates distribution (see details). |
substitution |
A function an its parameters for the substitutions distribution (see details; |
invariant |
|
verbose |
Whether to be verbose or not ( |
Details
The
model
arguments must be either a user's defined function for generating the discrete morphological characters (that takes the states, rates and substitution arguments) or one of the two following:-
"ER"
uses theape::rTraitDisc
function with the"ER"
model argument (= Mk model). -
"HKY"
uses thephyclust::gen.seq.HKY
function withkappa
sampled from thesubstitution
argument,pi = runif(4)
(divided bysum(runif(4))
),rate.scale
sampled from therates
distribution andL
being the number ofcharacters
and transforms the purines (A, G) into 0 and the pyrimidines (C, T) into 1. -
"MIXED"
randomly uses"ER"
or"HKY"
for binary characters and"ER"
for any character with more than two states. the user defined model must be a
function
that generates a single discrete morphological character and takes one element from at least the following arguments:tree
,states
,rates
,substitution
.
-
The
states
argument attributes a number of states to each character by using the given probability vector for each number of states starting from two. For examplestates = c(0.7, 0.2, 0.1)
will generate 70% of characters with two states, 20% of characters with three states and 10% of characters with four states.The
rates
andsubstitution
arguments require a function that outputs a distribution and its optional parameters. For examplerates = c(runif, 1, 10)
creates a uniform distribution between 1 and 10 for the rates distribution.
Author(s)
Thomas Guillerme
See Also
check.morpho
, apply.NA
, rTraitDisc
, gen.seq.HKY
Examples
set.seed(4)
## A random tree with 15 tips
tree <- rcoal(15)
## Setting up the parameters
my_rates = c(rgamma, rate = 10, shape = 5)
my_substitutions = c(runif, 2, 2)
## HKY binary (15*50)
matrixHKY <- sim.morpho(tree, characters = 50, model = "HKY",
rates = my_rates, substitution = my_substitutions)
## Mk matrix (15*50) (for Mkv models)
matrixMk <- sim.morpho(tree, characters = 50, model = "ER", rates = my_rates)
## Mk invariant matrix (15*50) (for Mk models)
matrixMk <- sim.morpho(tree, characters = 50, model = "ER", rates = my_rates,
invariant = FALSE)
## MIXED model invariant matrix (15*50)
matrixMixed <- sim.morpho(tree, characters = 50, model = "MIXED",
rates = my_rates, substitution = my_substitutions, invariant = FALSE,
verbose = TRUE)