Learn R Programming

rdiversity (version 1.0)

metacommunity: Coerce to metacommunity

Description

Functions to check if an object is a metacommunity or coerce an object into a metacommunity.

Usage

metacommunity(partition, similarity, ...)

# S4 method for data.frame,missing metacommunity(partition)

# S4 method for numeric,missing metacommunity(partition)

# S4 method for matrix,missing metacommunity(partition)

# S4 method for data.frame,matrix metacommunity(partition, similarity)

# S4 method for numeric,matrix metacommunity(partition, similarity)

# S4 method for matrix,matrix metacommunity(partition, similarity)

# S4 method for missing,phylo metacommunity(partition, similarity, interval = 1)

# S4 method for numeric,phylo metacommunity(partition, similarity, interval = 1)

# S4 method for data.frame,phylo metacommunity(partition, similarity, interval = 1)

# S4 method for matrix,phylo metacommunity(partition, similarity, interval = 1)

Arguments

partition

two-dimensional matrix of mode numeric with rows as types, columns as subcommunities, and elements containing the relative abundances of types in subcommunities. For phylogenetic diversity, see Details.

similarity

(optional) two-dimensional matrix of mode numeric, with rows as types, columns as types, and elements containing the pairwise similarity between types. For phylogenetic diversity, see Details.

...

(optional) additional arguments, especially:

interval

(optional; and for phylogenetic metacommunities only) how much evolutionary history should be retained, with 0 marking the most recent present-day species, and 1 (the default) marking the most recent common ancestor. Numbers greater than 1 extend the root of the tree.

Value

Returns an object of class metacommunity (see Details).

Details

  • type_abundance - proportional abundance of types in the subcommunity as a fraction of the metacommunity as a whole (in the phylogenetic case, this corresponds to the proportional abundance of historical species, which is calculated from the proportional abundance of present day species)

  • similarity - pairwise similarity between types

  • ordinariness - ordinariness of types

  • subcommunity_weights - subcommunity weights

  • type_weights - weight of types within a subcommunity

  • raw_abundance - proportional abundance of samples (usually types, except in the phylogenetic case where samples correspond to the present day species)

  • raw_structure - length of historical species (in phylogeny)

  • parameters - parameters associated with each historical species (in phylogeny)

When calculating phylogenetic diversity either:

  • set partition as the relative abundance of present-day species, with similarity as an object of class phylo, from which the relative abundance and pairwise similarity of historical species will be calculated; or

  • set partition as the relative abundance of historical species, with similarity as the pairwise similarity of historical species.

See Also

metacommunity-class

Examples

Run this code
# NOT RUN {
tree <- ape::rtree(n = 5)
tree$tip.label <- paste0("sp", seq_along(tree$tip.label))
partition <- cbind(a = c(1,1,1,0,0), b = c(0,1,0,1,1))
row.names(partition) <- tree$tip.label
partition <- partition / sum(partition)

a <- metacommunity(partition, tree)
b <- metacommunity(partition)

# }

Run the code above in your browser using DataLab