Create trans_alpha object for alpha diveristy statistics and plotting.
This class is a wrapper for a series of alpha diveristy related analysis, including the statistics and plotting based on An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035> and Paul et al. (2013) <doi:10.1371/journal.pone.0061217>.
new()
trans_alpha$new(dataset = NULL, group = NULL, order_x = NULL)
dataset
the object of microtable
Class.
group
default NULL; the sample column used for the statistics; If provided, can return data_stat.
order_x
default NULL; sample_table column name or a vector containg sample names; if provided, order samples by using factor.
data_alpha and data_stat stored in the object.
\donttest{ data(dataset) t1 <- trans_alpha$new(dataset = dataset, group = "Group") }
cal_diff()
Test the difference of alpha diversity across groups.
trans_alpha$cal_diff( method = c("KW", "KW_dunn", "wilcox", "t.test", "anova")[1], measure = NULL, p_adjust_method = "fdr", anova_set = NULL, ... )
method
default "KW"; see the following available options:
KW: Kruskal-Wallis Rank Sum Test for all groups (>= 2)
Dunn's Kruskal-Wallis Multiple Comparisons, see dunnTest function in FSA package
Wilcoxon Rank Sum and Signed Rank Tests for all paired groups
Student's t-Test for all paired groups
Duncan's multiple range test for anova
measure
default NULL; a vector; if null, all indexes will be calculated; see names of microtable$alpha_diversity, e.g. Observed, Chao1, ACE, Shannon, Simpson, InvSimpson, Fisher, Coverage, PD.
p_adjust_method
default "fdr"; p.adjust method; see method parameter of p.adjust function for available options; NULL can disuse the p value adjustment.
anova_set
default NULL; specified group set for anova, such as 'block + N*P*K', see aov
.
...
parameters passed to kruskal.test or wilcox.test function (method = "KW") or dunnTest function of FSA package (method = "KW_dunn") or agricolae::duncan.test (method = "anova").
res_diff in object. A data.frame generally. A list for anova when anova_set is assigned. In the data frame, 'Group' column means that the group has the maximum median or mean value across the test groups; For non-parametric methods, maximum median value; For t.test, maximum mean value.
\donttest{ t1$cal_diff(method = "KW") t1$cal_diff(method = "KW_dunn") t1$cal_diff(method = "anova") }
plot_alpha()
Plotting the alpha diveristy.
trans_alpha$plot_alpha( color_values = RColorBrewer::brewer.pal(8, "Dark2"), measure = "Shannon", group = NULL, add_sig = TRUE, add_sig_label = "Significance", add_sig_text_size = 3.88, use_boxplot = TRUE, boxplot_color = TRUE, boxplot_add = "jitter", order_x_mean = FALSE, y_start = 1.01, y_increase = 0.05, xtext_angle = NULL, xtext_size = 15, ytitle_size = 17, ... )
color_values
default RColorBrewer::brewer.pal(8, "Dark2"); color pallete for groups.
measure
default Shannon; alpha diveristy measurement; see names of alpha_diversity of dataset, e.g., Observed, Chao1, ACE, Shannon, Simpson, InvSimpson, Fisher, Coverage, PD.
group
default NULL; group name used for the plot.
add_sig
default TRUE; wheter add significance label using the result of cal_diff function, i.e. object$res_diff; This is manily designed to add post hoc test of anova or Dunn's Kruskal-Wallis Multiple Comparisons to make the label adding easy.
add_sig_label
default "Significance"; select a colname of object$res_diff for the label text, such as 'P.adj' or 'Significance'.
add_sig_text_size
default 3.88; the size of text in added label.
use_boxplot
default TRUE; TRUE: boxplot; FALSE: mean-se plot.
boxplot_color
default TRUE; TRUE: use color_values, FALSE: use "black".
boxplot_add
default "jitter"; points type, see the add parameter in ggpubr::ggboxplot.
order_x_mean
default FALSE; whether order x axis by the means of groups from large to small.
y_start
default 1.01; the y axis value from which to add the label; the default 1.01 means 1.01 * max(values).
y_increase
default 0.05; the increasing y axia space to add label; the default 0.05 means 0.05 * y_start; this parameter is also used to label the letters of anova result with the fixed (1 + y_increase) * y_start space.
xtext_angle
default NULL; number (e.g. 30) used to make x axis text generate angle.
xtext_size
default 15; x axis text size.
ytitle_size
default 17; y axis title size.
...
parameters pass to ggpubr::ggboxplot function.
ggplot.
\donttest{ t1$plot_alpha(measure = "Shannon", group = "Group") }
print()
Print the trans_alpha object.
trans_alpha$print()
clone()
The objects of this class are cloneable with this method.
trans_alpha$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------ ## Method `trans_alpha$new` ## ------------------------------------------------ data(dataset) t1 <- trans_alpha$new(dataset = dataset, group = "Group") ## ------------------------------------------------ ## Method `trans_alpha$cal_diff` ## ------------------------------------------------ t1$cal_diff(method = "KW") t1$cal_diff(method = "KW_dunn") t1$cal_diff(method = "anova") ## ------------------------------------------------ ## Method `trans_alpha$plot_alpha` ## ------------------------------------------------ t1$plot_alpha(measure = "Shannon", group = "Group")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.