ph_comdist {phylocomr} | R Documentation |
comdist
Description
Outputs the phylogenetic distance between samples, based on phylogenetic distances of taxa in one sample to the taxa in the other
Usage
ph_comdist(
sample,
phylo,
rand_test = FALSE,
null_model = 0,
randomizations = 999,
abundance = TRUE
)
ph_comdistnt(
sample,
phylo,
rand_test = FALSE,
null_model = 0,
randomizations = 999,
abundance = TRUE
)
Arguments
sample |
(data.frame/character) sample data.frame or path to a sample file |
phylo |
(character/phylo) One of: phylogeny as a newick string (will be
written to a temp file) - OR path to file with a newick
string - OR a an ape |
rand_test |
(logical) do you want to use null models?
Default: |
null_model |
(integer) which null model to use. See Details. |
randomizations |
(numeric) number of randomizations. Default: 999 |
abundance |
(logical) If |
Details
See phylocomr-inputs for expected input formats
Value
data.frame or a list of data.frame's if use null models
Null models
0 - Phylogeny shuffle: This null model shuffles species labels across the entire phylogeny. This randomizes phylogenetic relationships among species.
1 - Species in each sample become random draws from sample pool: This null model maintains the species richness of each sample, but the identities of the species occurring in each sample are randomized. For each sample, species are drawn without replacement from the list of all species actually occurring in at least one sample. Thus, species in the phylogeny that are not actually observed to occur in a sample will not be included in the null communities
2 - Species in each sample become random draws from phylogeny pool: This null model maintains the species richness of each sample, but the identities of the species occurring in each sample are randomized. For each sample, species are drawn without replacement from the list of all species in the phylogeny pool. All species in the phylogeny will have equal probability of being included in the null communities. By changing the phylogeny, different species pools can be simulated. For example, the phylogeny could include the species present in some larger region.
3 - Independent swap: The independent swap algorithm (Gotelli and Entsminger, 2003); also known as ‘SIM9’ (Gotelli, 2000) creates swapped versions of the sample/species matrix.
Taxon name case
In the sample
table, if you're passing in a file, the names in the
third column must be all lowercase; if not, we'll lowercase them for you.
If you pass in a data.frame, we'll lowercase them for your. All phylo
tip/node labels are also lowercased to avoid any casing problems
Examples
sfile <- system.file("examples/sample_comstruct", package = "phylocomr")
pfile <- system.file("examples/phylo_comstruct", package = "phylocomr")
# from data.frame
sampledf <- read.table(sfile, header = FALSE,
stringsAsFactors = FALSE)
phylo_str <- readLines(pfile)
ph_comdist(sample = sampledf, phylo = phylo_str)
ph_comdistnt(sample = sampledf, phylo = phylo_str)
ph_comdist(sample = sampledf, phylo = phylo_str, rand_test = TRUE)
ph_comdistnt(sample = sampledf, phylo = phylo_str, rand_test = TRUE)
# from files
sample_str <- paste0(readLines(sfile), collapse = "\n")
sfile2 <- tempfile()
cat(sample_str, file = sfile2, sep = '\n')
pfile2 <- tempfile()
cat(phylo_str, file = pfile2, sep = '\n')
ph_comdist(sample = sfile2, phylo = pfile2)
ph_comdistnt(sample = sfile2, phylo = pfile2)
ph_comdist(sample = sfile2, phylo = pfile2, rand_test = TRUE)
ph_comdistnt(sample = sfile2, phylo = pfile2, rand_test = TRUE)