trans_gamma: Simulate gamma-beta diversity relationships under specific...

trans_gammaR Documentation

Simulate gamma-beta diversity relationships under specific species distribution.

Description

Simulate gamma-beta diversity relationships under specific species distribution, and plot the result based on <doi:10.1038/s41467-020-19228-4>. The beta diversity is defined as the average distance-to-centroid value and measured as the average distance (or compositional dissimilarity) from one sample to the centroid of the group.

Methods

Public methods


Method new()

This function is used to simulate gamma-beta diversity relationships under specific species distribution.

Usage
trans_gamma$new(dataset = NULL, group = NULL, method = "bray", seed = 123)
Arguments
dataset

default NULL; microtable object; used for the observed pattern.

group

default NULL; a column name in sample_table; used as the different species pool for groups.

method

default "bray"; dissimilarity indices; see vegdist function and method parameter in vegan package; or "wei_unifrac" or "unwei_unifrac" in microtable$cal_betadiv().

seed

default 123; random seed used for the fixed random number generator for the repeatability.

Returns

parameters in object.

Examples
\donttest{
library(microeco)
data(dataset)
test1 <- trans_gamma$new(dataset = dataset, group = "Type", method = "bray")
}		

Method cal_observed()

Calculate observed gamma and beta diversity for each group. The beta diversity is defined as mean dispersion from the centroid based on the distance matrix. The gamma diversity is defined as the total species observed.

Usage
trans_gamma$cal_observed(sample_size = NULL)
Arguments
sample_size

default NULL; a numeric vector for the rarefied and uniform individual numbers in each sample; If null, use the observed data; If provided, use the rarefied data, e.g. c(500, 2000).

Returns

res_observed in object.

Examples
\donttest{
test1$cal_observed(sample_size = NULL)
}

Method plot_observed()

Plot the observed result.

Usage
trans_gamma$plot_observed(
  x_axis_title = "Gamma diversity",
  y_axis_title = "Beta diversity",
  ...
)
Arguments
x_axis_title

default "Gamma diversity"; x axis title.

y_axis_title

default "Beta diversity"; y axis title.

...

parameters pass to the function plot_scatterfit in trans_env Class.

Returns

ggplot.

Examples
\donttest{
test1$plot_observed(cor_method = "spearman")
}

Method cal_simulation()

Simulate gamma-beta diversity relationships under log-normal abundance distribution without any measured data.

Usage
trans_gamma$cal_simulation(
  gamma_vect = seq(1, 10000, by = 200),
  ind_vect = c(500, 1500, 3000, 5500, 10000),
  ncom = 100
)
Arguments
gamma_vect

default seq(1, 10000, by = 200); a vector as gamma diversity.

ind_vect

default c(500, 1500, 3000, 5500, 10000); a vector as individuals per plot.

ncom

default 100; number of communities; how many communities or samples in the region or the studied species pool.

Returns

res_simulation in object.

Examples
\donttest{
test1$cal_simulation(ncom = 20, ind_vect = c(200, 1000, 2000))
}

Method plot_simulation()

Plot the simulation result.

Usage
trans_gamma$plot_simulation(
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  show_point = TRUE,
  point_size = 0.3,
  point_alpha = 0.6,
  add_fitting = FALSE,
  ...
)
Arguments
color_values

colors used for presentation.

show_point

default TRUE; whether show the point.

point_size

default .3; point size value.

point_alpha

default .6; point alpha value.

add_fitting

default FALSE; whether add fitted line.

...

parameters pass to ggplot2::geom_line (when add_fitting = FALSE) or ggplot2::geom_smooth (when add_fitting = TRUE).

color

default "SampleID"; color mapping in the plot.

Returns

ggplot.

Examples
\donttest{
test1$plot_simulation()
}

Method print()

Print the trans_gamma object.

Usage
trans_gamma$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
trans_gamma$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `trans_gamma$new`
## ------------------------------------------------


library(microeco)
data(dataset)
test1 <- trans_gamma$new(dataset = dataset, group = "Type", method = "bray")
		

## ------------------------------------------------
## Method `trans_gamma$cal_observed`
## ------------------------------------------------


test1$cal_observed(sample_size = NULL)


## ------------------------------------------------
## Method `trans_gamma$plot_observed`
## ------------------------------------------------


test1$plot_observed(cor_method = "spearman")


## ------------------------------------------------
## Method `trans_gamma$cal_simulation`
## ------------------------------------------------


test1$cal_simulation(ncom = 20, ind_vect = c(200, 1000, 2000))


## ------------------------------------------------
## Method `trans_gamma$plot_simulation`
## ------------------------------------------------


test1$plot_simulation()


ChiLiubio/mecodev documentation built on Jan. 20, 2025, 8:05 a.m.