phylospatial | R Documentation |
This function creates a phylospatial
object. This is the core data type in the phylospatial library, and
is a required input to most other functions in the package. The two essential components of a spatial phylogenetic object
are a phylogenetic tree and an community data set.
phylospatial(
comm,
tree = NULL,
spatial = NULL,
data_type = c("auto", "probability", "binary", "abundance", "other"),
clade_fun = NULL,
build = TRUE,
check = TRUE,
area_tol = 0.01
)
comm |
Community data representing the distribution of terminal taxa across sites. Can be a matrix with a column per terminal and
a row per site, a SpatRaster with one layer per terminal, or a |
tree |
Phylogeny of class phylo. Terminals whose names do not match |
spatial |
An optional |
data_type |
Character giving the data type of |
clade_fun |
Function to calculate the local community weight for a clade based on community weights for tips found in a given location.
Must be either NULL (the default, in which case the default function for the selected |
build |
Logical indicating whether |
check |
Logical indicating whether community data should be validated. Default is TRUE. |
area_tol |
Numeric value giving tolerance for variation in the area of sites. Default is |
This function formats the input data as a phylospatial
object. Beyond validating, cleaning, and restructing the data, the main operation
it performs is to compute community occurrence data for every internal clade on the tree. For a given clade and site, community data for
all the terminals in the clade are used to calculate the clade's occurrence value in the site. As described above, this calculation can
happen in various ways, depending on what type of community data you have (e.g. binary, probability, or abundance) and how you want to
summarize them. By default, the function tries to detect your data_type
and use it to automatically select an appropriate summary
function as described above, but you can override this by providing your own function to clade_fun
.
You can also disable construction of the clade community matrix columns altogether by setting build = FALSE
). This is atypical, but you
might want to use this option if you have your own distribution data data on all clades (e.g. from modeling occurrence probabilities for
clades in addition to terminal species), or if your community data comes from a previously-constructed phylospatial
object.
A phylospatial
object, which is a list containing the following elements:
Character indicating the community data type
Phylogeny of class phylo
Community matrix, including a column for every terminal taxon and every larger clade. Column order corresponds to tree edge order.
A SpatRaster
or sf
providing spatial coordinates for the rows in comm
. May be missing if no spatial data was supplied.
A community dissimilary matrix of class dist
indicating pairwise phylogenetic dissimilarity between sites. Missing unless
ps_dissim(..., add = TRUE)
is called.
# load species distribution data and phylogeny
comm <- terra::rast(system.file("extdata", "moss_comm.tif", package = "phylospatial"))
tree <- ape::read.tree(system.file("extdata", "moss_tree.nex", package = "phylospatial"))
# construct `phylospatial` object
ps <- phylospatial(comm, tree)
ps
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.