taxaturn {mecoturn}R Documentation

Analyze the 'turnover' of taxa.

Description

Analyze the 'turnover' of taxa along a defined gradient. The workflow of taxaturn class includes the taxonomic abundance calculation, abundance transformation, abundance change summary, statistical analysis and visualization.

Methods

Public methods


Method new()

Usage
taxaturn$new(
  dataset,
  taxa_level = "Phylum",
  group,
  ordered_group,
  by_ID = NULL,
  by_group = NULL,
  filter_thres = 0
)
Arguments
dataset

the object of microtable class.

taxa_level

default "Phylum"; taxonomic rank name, such as "Genus". An integer is also acceptable. If the provided taxa_level is not found in taxa_abund list, the function will invoke the cal_abund function to obtain the relative abudance automatically.

group

sample group used for the selection; a colname of input microtable$sample_table.

ordered_group

a vector representing the ordered elements of group parameter.

by_ID

default NULL; a column of sample_table used to obtain the consistent change along provided elements. So by_ID can be ID (unique repetition) or even group (with repetitions). If it denotes unique ID, consistent change can be performed across each ID. It is also especially useful for the paired wilcox test (or paired t test) in the following analysis. If it does not represent unique ID, the mean of each group will be calculated, and consistent change across groups will be obtained.

by_group

default NULL; NULL or other colname of sample_table of input dataset used to show the result for different groups; NULL represents the output is the default consistent change across all the elements in by_ID; a colname of sample_table of input dataset means the consistent change is obtained for each group instead of all the elements in by_group; Note that the by_group can be same with by_ID, in which the final change is the result of each element in by_group. So generally by_group has a larger scale than by_ID parameter in terms of the sample numbers in each element.

filter_thres

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

Returns

res_abund, res_change_pair and res_change in the object:

res_abund

The Mean, SD or SE of abundances for all the samples or each group. Mean: mean of abudances; SD: standard deviation; SE: standard error.

res_change_pair

The difference value of abudances between two niches, i.e. the latter minus the former.

res_change

The summary of the abudance change results in res_change_pair.

Examples
data(wheat_16S)
t1 <- taxaturn$new(wheat_16S, taxa_level = "Phylum", group = "Type", 
 ordered_group = c("S", "RS", "R"), by_ID = "Plant_ID", filter_thres = 0.01)

Method cal_diff()

Differential test of taxonomic abundance across groups

Usage
taxaturn$cal_diff(
  method = c("wilcox", "t.test", "anova", "betareg", "lme", "glmm")[1],
  group2num = FALSE,
  ...
)
Arguments
method

default "wilcox"; see the following available options:

'wilcox'

Wilcoxon Rank Sum and Signed Rank Tests for all paired groups

't.test'

Student's t-Test for all paired groups

'anova'

one-way or multi-way anova

'betareg'

Beta Regression based on the betareg package

'lme'

lme: Linear Mixed Effect Model based on the lmerTest package

'glmm'

Generalized linear mixed model (GLMM) based on the glmmTMB package with the beta family function, i.e. family = glmmTMB::beta_family(link = "logit"). For more parameters, please see glmmTMB::glmmTMB function. In the return table, Conditional_R2 and Marginal_R2 represent total variance (explained by both fixed and random effects) and the variance explained by fixed effects, respectively. The significance of fixed factors are tested by Chi-square test from function car::Anova. The significance of 'Estimate' in each term of fixed factors comes from the model.

group2num

default FALSE; whether convert ordered groups to integer numbers when method is "lme" or "glmm".

...

parameters passed to trans_diff$new.

Returns

res_change or res_diff in the object.

Examples
t1$cal_diff(method = "wilcox")

Method plot()

Plot the line chart.

Usage
taxaturn$plot(
  select_taxon = NULL,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  delete_prefix = TRUE,
  plot_type = c("point", "line", "errorbar", "smooth")[1:3],
  errorbar_SE = TRUE,
  rect_fill = TRUE,
  rect_color = c("grey70", "grey90"),
  rect_alpha = 0.2,
  position = position_dodge(0.1),
  errorbar_size = 1,
  errorbar_width = 0.1,
  point_size = 3,
  point_alpha = 0.8,
  line_size = 0.8,
  line_alpha = 0.8,
  line_type = 1,
  ...
)
Arguments
select_taxon

default NULL; a taxon name. Note that if delete_prefix is TRUE, the provided select_taxon should be taxa names without long prefix (those before |); if delete_prefix is FALSE, the select_taxon should be full names same with those in the res_abund of the object.

color_values

default RColorBrewer::brewer.pal(8, "Dark2"); colors palette for the plotting.

delete_prefix

default TRUE; whether delete the prefix in the taxa names.

plot_type

default c("point", "line", "errorbar", "smooth")[1:3]; a vector of visualization types. Multiple elements are available. 'smooth' denotes the fitting with geom_smooth function of ggplot2 package.

errorbar_SE

default TRUE; TRUE: plot the errorbar with mean ± se; FALSE: plot the errorbar with mean ± sd.

rect_fill

default TRUE; Whether fill color in each rectangular area.

rect_color

default c("grey70", "grey90"); the colors used to fill different rectangular area.

rect_alpha

default 0.2; the fill color transparency in rectangular area.

position

default position_dodge(0.1); Position adjustment for the points and lines, either as a string (such as "identity"), or the result of a call to a position adjustment function.

errorbar_size

default 1; errorbar size.

errorbar_width

default 0.1; errorbar width.

point_size

default 3; point size for taxa.

point_alpha

default 0.8; point transparency.

line_size

default 0.8; line size.

line_alpha

default 0.8; line transparency.

line_type

default 1; an integer; line type.

...

parameters passed to geom_smooth when 'smooth' is in plot_type parameter.

Returns

ggplot2 plot.

Examples
t1$plot()

Method clone()

The objects of this class are cloneable with this method.

Usage
taxaturn$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `taxaturn$new`
## ------------------------------------------------

data(wheat_16S)
t1 <- taxaturn$new(wheat_16S, taxa_level = "Phylum", group = "Type", 
 ordered_group = c("S", "RS", "R"), by_ID = "Plant_ID", filter_thres = 0.01)

## ------------------------------------------------
## Method `taxaturn$cal_diff`
## ------------------------------------------------

t1$cal_diff(method = "wilcox")

## ------------------------------------------------
## Method `taxaturn$plot`
## ------------------------------------------------

t1$plot()

[Package mecoturn version 0.3.0 Index]