Skip to contents

Perform an ordination that reduces a spatial phylogenetic data set into three dimensions that can be plotted as the RGB bands of color space to visualize spatial patterns of community phylogenetic composition. This function is a wrapper around ps_ordinate().

Usage

ps_rgb(ps, method = c("nmds", "cmds", "pca"), trans = identity, spatial = TRUE)

Arguments

ps

A phylospatial object with a non-null dissim component, generated by ps_add_dissim.

method

Ordination method, either "pca" (principal component analysis implemented via stats::prcomp()), "cmds" (classical MDS, implemented via stats::cmdscale()), or "nmds" (the default, nonmetric MDS, implemented via vegan::metaMDS(); this is slower but often preferred).

trans

A function giving a transformation to apply to each dimension of the ordinated data. The default is the identity function. Specifying rank generates a more uniform color distribution.

spatial

Logical indicating whether a spatial object (inherited from ps) should be returned. Default is TRUE.

Value

A matrix or spatial object with three variables containing RGB color values in the range 0-1.

Examples

ps <- ps_add_dissim(moss())
RGB <- ps_rgb(ps, method = "cmds")
terra::plotRGB(RGB * 255, smooth = FALSE)