Skip to contents

Perform a clustering analysis that categorizes sites into biogeographic regions based on phylogenetic community compositional similarity.

Usage

ps_regions(ps, k = 5, method = "average", endemism = FALSE, normalize = TRUE)

Arguments

ps

A phylospatial object. If method is anything other than "kmeans", it must contain a dissim component generated by ps_add_dissim.

k

Number of spatial clusters to divide the region into (positive integer). See ps_regions_eval to help choose a value of k by comparing the variance explained by different numbers of regions.

method

Clustering method. Options include all methods listed under hclust, and "kmeans". If "kmeans" is selected, the dissim component of ps is ignored.

endemism

Logical indicating whether community values should be divided by column totals (taxon range sizes) to derive endemism. Only used if method = "kmeans"; in other cases this information should instead be supplied to ps_add_dissim.

normalize

Logical indicating whether community values should be divided by row totals (community sums). If TRUE, dissimilarity is based on proportional community composition. This happens after endemism is derived. Only used if method = "kmeans"; in other cases this information should instead be supplied to ps_add_dissim.

Value

A raster or matrix with an integer indicating which of the k regions each site belongs to.

References

Daru, B. H., Elliott, T. L., Park, D. S., & Davies, T. J. (2017). Understanding the processes underpinning patterns of phylogenetic regionalization. Trends in Ecology & Evolution, 32(11), 845-860.

Examples

ps <- ps_simulate()

# using kmeans clustering algorithm
terra::plot(ps_regions(ps, method = "kmeans"))


# to use a hierarchical clustering method, first we have to `ps_add_dissim()`
terra::plot(ps_regions(ps_add_dissim(ps), k = 7, method = "average"))