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
dataset

the object of microtable class.

measure

default "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 parameter method of vegan::vegdist function. 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_thres

default 0; the relative abundance threshold used to filter features with low abundance.

abundance.weighted

default TRUE; whether use abundance-weighted method for the phylogenetic metrics.

null.model

default 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. See null.model parameter of ses.mntd function in picante package for the algorithm details.

runs

default 1000; simulation number of times for null model.

iterations

default 1000; iteration number for part null models to perform; see iterations parameter of picante::randomizeMatrix function.

...

parameters passed to cal_betadiv function of microtable class when provided measure is not in the current vector; parameters passed to cal_betamntd function of trans_nullmodel class when measure = "betaMNTD"; parameters passed to cal_ses_betamntd function of trans_nullmodel class when measure = "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
group

one colname of sample_table in microtable object used for group distance convertion.

within_group

default TRUE; whether transform sample distance within groups? If FALSE, transform sample distances between any two groups.

by_group

default NULL; one colname of sample_table in microtable object. If provided, convert distances according to the provided by_group parameter. This is especially useful for ordering and filtering values further. When within_group = TRUE, the result of by_group parameter is the format of paired groups. When within_group = FALSE, the result of by_group parameter is the format same with the group information in sample_table.

ordered_group

default NULL; a vector representing the ordered elements of group parameter; only useful when within_group = FALSE.

sep

default TRUE; a character string to separate the group names after merging them into a new name.

add_cols

default NULL; add several columns of sample_table to the final res_group_distance table according to the by_group column; invoked only when within_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_diff function of trans_beta class.

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_distance function of trans_beta class.

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
deep

Whether 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()

[Package mecoturn version 0.3.0 Index]