wpd | R Documentation |
Calculates weighted Phylogenetic Diversity for a vector s of species observations, weighted by the frequency of each species within s. For example, if s=a, a, b, a, b, c, a, then species a will have weight 4, species b will have weight 2, and species c will have weight 1. Unobserved species have weight zero. However, one may wish to exclude observations that do not meet some criterion, such as co-observation of a symbiote or parasite. For this reason, a second set of weights w can be provided as a vector of numeric values that are paired with s. These weights are then implicitely combined with the weights discussed above depending on which weighted metric is chosen. In the case of Phylogenetic Entropy (Hw), per-tip weights are calculated as the sums of w. In the case of Weighted Faith (WF), per-tip weights are averages of w.
wpd(s, s_phylo, w = NULL, nested_set = NULL, metric = "Hp")
s |
character vector. One species name per observation. If no species was observed for a given datum, use NA. s can also be provided as a vector of unique species identities, in which case counts of those species can be given as w. |
s_phylo |
phylo object. Tree containing all unique names in s as tips. Must not contain duplicate tip labels. |
w |
numeric vector. Optional weights for s, e.g. number of parasites observed in each sample, or boolean weights corresponding to presence or absence of parasite species, or confidence species was observed, etc. If w is not provided but a weighted metric is specified, w will be set to 1 for each value of s. Thus, weights for each unique species in s would be equal to the number of times that species appears in s. w is not used for unweighted metrics (PD). Any NA values in w will be pairwise removed from w and s (default: NULL). |
nested_set |
matrix. The output of make_nested_set(s_phylo). If not provided, will be calculated on the fly. Precalculation only provides speedup with very large trees (default: NULL). |
metric |
character. Abbreviated name of desired tree-based phylogenetic diversity metric. Available metrics are:
|
Single WPD or PD value.
John L. Darcy
Allen B, Kon M, Bar-Yam Y (2009) A new phylogenetic diversity measure generalizing the Shannon index and its application to Phyllostomid bats. American Naturalist 174(2).
Swenson NG (2014) Functional and Phylogenetic Ecology in R. Springer UseR! Series, Springer, New York, New York, U.S.A.
Faith DP (1992) Conservation evaluation and phylogenetic diversity. Biological Conservation 61.
# library(specificity)
# set.seed(12345)
# s_phylo <- get(data(endophyte))$supertree
# w <- sample(c(0, 1), replace=TRUE, size=10)
# s <- sample(s_phylo$tip.label, replace=TRUE, size=10)
# wpd(s, s_phylo, w, metric="Hp")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.