plot_rarefaction: Plot rarefaction curves for each treatment group

View source: R/mobr.R

plot_rarefactionR Documentation

Plot rarefaction curves for each treatment group

Description

Plot rarefaction curves for each treatment group

Usage

plot_rarefaction(
  mob_in,
  group_var,
  ref_level = NULL,
  method,
  dens_ratio = 1,
  pooled = TRUE,
  spat_algo = NULL,
  col = NULL,
  lwd = 3,
  log = "",
  leg_loc = "topleft",
  ...
)

Arguments

mob_in

an object of class mob_in created by make_mob_in()

group_var

String that specifies which field in mob_in$env the data should be grouped by

ref_level

String that defines the reference level of group_var to which all other groups are compared with, defaults to NULL. If NULL then the default contrasts of group_var are used.

method

a character string that specifies the method of rarefaction curve construction it can be one of the following:

  • 'IBR' ... individual-based rarefaction in which species are accumulated by randomly sampling individuals

  • 'SBR' ... sample-based rarefaction in which species are accumulated by randomly sampling samples (i.e., plots). Note that within plot spatial aggregation is maintained with this approach. Although this curve is implemented here, it is not used in the current version of the MoB framework

  • 'nsSBR' ... non-spatial, sampled-based rarefaction in which species are accumulated by randomly sampling samples that represent a spatially random sample of individuals (i.e., no with-in plot spatial aggregation). The argument dens_ratio must also be set otherwise this sampling results in a curve identical to the IBR (see Details).

  • 'sSBR' ... spatial sample-based rarefaction in which species are accumulated by including spatially proximate samples first.

dens_ratio

the ratio of individual density between a reference group and the community data (i.e., x) under consideration. This argument is used to rescale the rarefaction curve when estimating the effect of individual density on group differences in richness.

pooled

Boolean specifying if samples should be pooled at the group level or not. Defaults to TRUE. This argument only applies when the individual based rarefaction is used (i.e., method = 'indiv')

spat_algo

character string that can be either: 'kNN' or 'kNCN' for k-nearest neighbor and k-nearest centroid neighbor sampling respectively. It defaults to k-nearest neighbor which is a more computationally efficient algorithm that closely approximates the potentially more correct k-NCN algo (see Details).

col

optional vector of colors.

lwd

a number which specifies the width of the lines

log

a string that specifies if any axes are to be log transformed, options include 'x', 'y' or 'xy' in which either the x-axis, y-axis, or both axes are log transformed respectively

leg_loc

a string that specifies the location of the legend, options include: 'lowerleft', 'topleft', 'loweright','topright'

...

other arguments to provide to rarefaction

Examples

data(inv_comm)
data(inv_plot_attr)
inv_mob_in = make_mob_in(inv_comm, inv_plot_attr, coord_names = c('x', 'y'))
# random individual based rarefaction curves
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'IBR',
                 pooled=TRUE, leg_loc='bottomright')
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'IBR',
                 pooled=FALSE, log='x')
# random sample based rarefaction curves 
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'SBR', log='xy')
# spatial sample based rarefaction curves 
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'sSBR', log='xy')

MoBiodiv/mobr documentation built on Jan. 31, 2024, 6:15 p.m.