| betaturn {mecoturn} | R Documentation |
Analyze the 'turnover' of microbial communities.
Description
Analyze the 'turnover' of microbial communities, i.e. beta-diversity along a gradient <doi:10.1111/j.1461-0248.2010.01552.x>. The workflow consists of the steps of dissimilarity matrix generation, matrix conversion, differential test and visualization.
Methods
Public methods
Method new()
Usage
betaturn$new( dataset, measure = "bray", filter_thres = 0, abundance.weighted = TRUE, null.model = NULL, runs = 1000, iterations = 1000, ... )
Arguments
datasetthe object of
microtableclass.measuredefault "bray"; beta diversity dissimilarity metric; must be one of
c("bray", "jaccard", "wei_unifrac", "unwei_unifrac", "betaMPD", "betaMNTD", "betaNRI", "betaNTI", "ses_UniFrac", "RCbray")or other options in parametermethodofvegan::vegdistfunction. If the distance matrix has been in the beta_diversity list of microtable object, the function can ignore this step. Otherwise, the function can generate the corresponding beta diversity distance matrix in the microtable object. bray: Bray-Curtis; RCbray: Raup–Crick based Bray-Curtis; wei_unifrac: weighted UniFrac; ses_UniFrac: standardized deviation of UniFrac.filter_thresdefault 0; the relative abundance threshold used to filter features with low abundance.
abundance.weighteddefault TRUE; whether use abundance-weighted method for the phylogenetic metrics.
null.modeldefault NULL; one of
c("taxa.labels", "richness", "frequency", "sample.pool", "phylogeny.pool", "independentswap", "trialswap"), in which "taxa.labels" can only be used for phylogenetic analysis. Seenull.modelparameter ofses.mntdfunction inpicantepackage for the algorithm details.runsdefault 1000; simulation number of times for null model.
iterationsdefault 1000; iteration number for part null models to perform; see iterations parameter of
picante::randomizeMatrixfunction....parameters passed to
cal_betadivfunction ofmicrotableclass when provided measure is not in the current vector; parameters passed tocal_betamntdfunction oftrans_nullmodelclass whenmeasure = "betaMNTD"; parameters passed tocal_ses_betamntdfunction oftrans_nullmodelclass whenmeasure = "betaNTI".
Returns
dataset, stored in the object. The new dataset has a beta_diversity list and the calculated distance matrix in the list.
Examples
data(wheat_16S) b1 <- betaturn$new(wheat_16S, measure = "bray")
Method cal_group_distance()
Convert sample distances within groups or between groups.
Usage
betaturn$cal_group_distance( group, within_group = TRUE, by_group = NULL, ordered_group = NULL, sep = " vs ", add_cols = NULL )
Arguments
groupone colname of sample_table in
microtableobject used for group distance convertion.within_groupdefault TRUE; whether transform sample distance within groups? If FALSE, transform sample distances between any two groups.
by_groupdefault NULL; one colname of sample_table in
microtableobject. If provided, convert distances according to the provided by_group parameter. This is especially useful for ordering and filtering values further. Whenwithin_group = TRUE, the result of by_group parameter is the format of paired groups. Whenwithin_group = FALSE, the result of by_group parameter is the format same with the group information insample_table.ordered_groupdefault NULL; a vector representing the ordered elements of
groupparameter; only useful when within_group = FALSE.sepdefault TRUE; a character string to separate the group names after merging them into a new name.
add_colsdefault NULL; add several columns of sample_table to the final
res_group_distancetable according to theby_groupcolumn; invoked only whenwithin_group = FALSE.
Returns
res_group_distance stored in object.
Examples
b1$cal_group_distance(group = "Type", within_group = FALSE, by_group = "Plant_ID")
Method cal_group_distance_diff()
Differential test of distances among groups.
Usage
betaturn$cal_group_distance_diff(...)
Arguments
...parameters passed to
cal_group_distance_difffunction oftrans_betaclass.
Returns
res_group_distance_diff stored in object.
Examples
b1$cal_group_distance_diff(method = "wilcox")
Method plot_group_distance()
Plot the distance between samples within or between groups.
Usage
betaturn$plot_group_distance(...)
Arguments
...parameters passed to
plot_group_distancefunction oftrans_betaclass.
Returns
ggplot.
Examples
b1$plot_group_distance()
Method clone()
The objects of this class are cloneable with this method.
Usage
betaturn$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## ------------------------------------------------
## Method `betaturn$new`
## ------------------------------------------------
data(wheat_16S)
b1 <- betaturn$new(wheat_16S, measure = "bray")
## ------------------------------------------------
## Method `betaturn$cal_group_distance`
## ------------------------------------------------
b1$cal_group_distance(group = "Type", within_group = FALSE, by_group = "Plant_ID")
## ------------------------------------------------
## Method `betaturn$cal_group_distance_diff`
## ------------------------------------------------
b1$cal_group_distance_diff(method = "wilcox")
## ------------------------------------------------
## Method `betaturn$plot_group_distance`
## ------------------------------------------------
b1$plot_group_distance()