Learn R Programming

metricTester (version 1.2.2)

metricsNnulls: Parallelized function that calculates metrics on randomized matrices

Description

This function sends out jobs to as many cores as are specified. Each randomizes the input CDM according to all defined null models, then calculates each observed metric on each randomized matrix.

Usage

metricsNnulls(tree, picante.cdm, optional.dists = NULL, regional.abundance = NULL, distances.among = NULL, randomizations = 2, cores = "seq", nulls, metrics)

Arguments

tree
Phylo object
picante.cdm
A picante-style community data matrix with sites as rows, and species as columns
optional.dists
A symmetric distance matrix can be directly supplied. This option is experimental. Behavior depends on metric being used. If the metric in question relies on the phylogenetic distance matrix from a call to cophenetic(tree), then this optional distance matrix will be inserted instead.
regional.abundance
A character vector in the form "s1, s1, s1, s2, s2, s3, etc". Optional, will be generated from the input CDM if not provided.
distances.among
A symmetric distance matrix, summarizing the distances among all plots from the cdm. Optional, only used by some null models.
randomizations
The number of times the input CDM should be randomized and the metrics calculated across it.
cores
This function can run in parallel. In order to do so, the user must specify the desired number of cores to utilize. The default is "seq", which runs the calculations sequentially.
nulls
Optional list of named null model functions to use. If invoked, this option will likely be used to run a subset of the defined null models.
metrics
Optional list of named metric functions to use. If invoked, this option will likely be used to run a subset of the defined metrics.

Value

A list of lists of vectors. The first level has as many elements as there are randomizations. The second level has one list for each null model. Each element of this second level is a named vector corresponding to the calculated metric at each plot.

Details

This function sends out jobs to as many cores as are specified. Each randomizes the input CDM according to all defined null models, then calculates each observed metric on each randomized matrix.

References

Miller, E. T., D. R. Farine, and C. H. Trisos. 2015. Phylogenetic community structure metrics and null models: a review with new methods and software. bioRxiv 025726.

Examples

Run this code
#simulate tree with birth-death process
tree <- geiger::sim.bdtree(b=0.1, d=0, stop="taxa", n=50)

sim.abundances <- round(rlnorm(5000, meanlog=2, sdlog=1)) + 1

cdm <- simulateComm(tree, richness.vector=10:25, abundances=sim.abundances)

rawResults <- metricsNnulls(tree, cdm, randomizations=3,
nulls=list("richness"=metricTester:::my_richnessNull,
"frequency"=metricTester:::my_frequency))

Run the code above in your browser using DataLab