trans_gamma | R Documentation |
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.
new()
This function is used to simulate gamma-beta diversity relationships under specific species distribution.
trans_gamma$new(dataset = NULL, group = NULL, method = "bray", seed = 123)
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.
parameters in object.
\donttest{ library(microeco) data(dataset) test1 <- trans_gamma$new(dataset = dataset, group = "Type", method = "bray") }
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.
trans_gamma$cal_observed(sample_size = NULL)
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).
res_observed in object.
\donttest{ test1$cal_observed(sample_size = NULL) }
plot_observed()
Plot the observed result.
trans_gamma$plot_observed( x_axis_title = "Gamma diversity", y_axis_title = "Beta diversity", ... )
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.
ggplot.
\donttest{ test1$plot_observed(cor_method = "spearman") }
cal_simulation()
Simulate gamma-beta diversity relationships under log-normal abundance distribution without any measured data.
trans_gamma$cal_simulation( gamma_vect = seq(1, 10000, by = 200), ind_vect = c(500, 1500, 3000, 5500, 10000), ncom = 100 )
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.
res_simulation in object.
\donttest{ test1$cal_simulation(ncom = 20, ind_vect = c(200, 1000, 2000)) }
plot_simulation()
Plot the simulation result.
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, ... )
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.
ggplot.
\donttest{ test1$plot_simulation() }
print()
Print the trans_gamma object.
trans_gamma$print()
clone()
The objects of this class are cloneable with this method.
trans_gamma$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## 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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.