| 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.
Unoccupied sites (rows where no taxon occurs) are automatically removed from the community matrix during construction to improve
performance. The original site indices of occupied rows are stored in ps$occupied, and the total number of sites (including
unoccupied) in ps$n_sites, enabling reconstruction of full-extent spatial outputs. Functions that return spatial results
automatically expand occupied-only data back to the full spatial extent.
A phylospatial object, which is a list containing the following elements:
Character indicating the community data type
Phylogeny of class phylo
Community matrix containing only occupied sites, 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 all sites (including unoccupied).
May be missing if no spatial data was supplied.
Integer vector of row indices identifying which sites in the original data are occupied.
Total number of sites in the original data, including unoccupied.
A community dissimilarity matrix of class dist indicating pairwise phylogenetic dissimilarity
between occupied sites. Missing unless ps_add_dissim() 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.