| 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
datasetthe object of
microtableclass.taxa_leveldefault "Phylum"; taxonomic rank name, such as "Genus". An integer is also acceptable. If the provided taxa_level is not found in
taxa_abundlist, the function will invoke thecal_abundfunction to obtain the relative abudance automatically.groupsample group used for the selection; a colname of input
microtable$sample_table.ordered_groupa vector representing the ordered elements of
groupparameter.by_IDdefault 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_groupdefault 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 inby_group; Note that the by_group can be same with by_ID, in which the final change is the result of each element inby_group. So generallyby_grouphas a larger scale thanby_IDparameter in terms of the sample numbers in each element.filter_thresdefault 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_abundThe 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_pairThe difference value of abudances between two niches, i.e. the latter minus the former.
res_changeThe 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
methoddefault "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
betaregpackage- 'lme'
lme: Linear Mixed Effect Model based on the
lmerTestpackage- 'glmm'
Generalized linear mixed model (GLMM) based on the
glmmTMBpackage with the beta family function, i.e.family = glmmTMB::beta_family(link = "logit"). For more parameters, please seeglmmTMB::glmmTMBfunction. 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 functioncar::Anova. The significance of 'Estimate' in each term of fixed factors comes from the model.
group2numdefault 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_taxondefault NULL; a taxon name. Note that if
delete_prefixis TRUE, the provided select_taxon should be taxa names without long prefix (those before |); ifdelete_prefixis FALSE, the select_taxon should be full names same with those in theres_abundof the object.color_valuesdefault
RColorBrewer::brewer.pal(8, "Dark2"); colors palette for the plotting.delete_prefixdefault TRUE; whether delete the prefix in the taxa names.
plot_typedefault c("point", "line", "errorbar", "smooth")[1:3]; a vector of visualization types. Multiple elements are available. 'smooth' denotes the fitting with
geom_smoothfunction of ggplot2 package.errorbar_SEdefault TRUE; TRUE: plot the errorbar with mean ± se; FALSE: plot the errorbar with mean ± sd.
rect_filldefault TRUE; Whether fill color in each rectangular area.
rect_colordefault c("grey70", "grey90"); the colors used to fill different rectangular area.
rect_alphadefault 0.2; the fill color transparency in rectangular area.
positiondefault 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_sizedefault 1; errorbar size.
errorbar_widthdefault 0.1; errorbar width.
point_sizedefault 3; point size for taxa.
point_alphadefault 0.8; point transparency.
line_sizedefault 0.8; line size.
line_alphadefault 0.8; line transparency.
line_typedefault 1; an integer; line type.
...parameters passed to
geom_smoothwhen '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
deepWhether 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()