Create trans_beta object for the analysis of distance matrix of beta-diversity.
This class is a wrapper for a series of beta-diversity related analysis, including several ordination calculations and plotting based on An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035>, group distance comparision, clustering, perMANOVA based on Anderson al. (2008) <doi:10.1111/j.1442-9993.2001.01070.pp.x> and PERMDISP. Please also cite the original paper: An et al. (2019). Soil bacterial community structure in Chinese wetlands. Geoderma, 337, 290-299.
new()
trans_beta$new(dataset = NULL, measure = NULL, group = NULL)
datasetthe object of microtable Class.
measuredefault NULL; bray, jaccard, wei_unifrac or unwei_unifrac, or other name of matrix you add; beta diversity index used for ordination, manova or group distance.
groupdefault NULL; sample group used for manova, betadisper or group distance.
parameters stored in the object.
data(dataset) t1 <- trans_beta$new(dataset = dataset, measure = "bray", group = "Group")
cal_ordination()
Ordination based on An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035>.
trans_beta$cal_ordination( ordination = "PCoA", ncomp = 3, trans_otu = FALSE, scale_species = FALSE )
ordinationdefault "PCoA"; "PCA", "PCoA" or "NMDS". PCA: principal component analysis; PCoA: principal coordinates analysis; NMDS: non-metric multidimensional scaling.
ncompdefault 3; the returned dimensions.
trans_otudefault FALSE; whether species abundance will be square transformed, used for PCA.
scale_speciesdefault FALSE; whether species loading in PCA will be scaled.
res_ordination stored in the object.
t1$cal_ordination(ordination = "PCoA")
plot_ordination()
Plotting the ordination result based on An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035>.
trans_beta$plot_ordination( plot_type = "point", color_values = RColorBrewer::brewer.pal(8, "Dark2"), shape_values = c(16, 17, 7, 8, 15, 18, 11, 10, 12, 13, 9, 3, 4, 0, 1, 2, 14), plot_color = NULL, plot_shape = NULL, plot_group_order = NULL, add_sample_label = NULL, point_size = 3, point_alpha = 0.8, centroid_segment_alpha = 0.6, centroid_segment_size = 1, centroid_segment_linetype = 3, ellipse_chull_fill = TRUE, ellipse_chull_alpha = 0.1, ellipse_level = 0.9, ellipse_type = "t" )
plot_typedefault "point"; one or more elements of "point", "ellipse", "chull" and "centroid".
add point
add confidence ellipse for points of each group
add convex hull for points of each group
add centroid line of each group
color_valuesdefault RColorBrewer::brewer.pal(8, "Dark2"); colors palette for different groups.
shape_valuesdefault c(16, 17, 7, 8, 15, 18, 11, 10, 12, 13, 9, 3, 4, 0, 1, 2, 14); a vector for point shape types of groups, see ggplot2 tutorial.
plot_colordefault NULL; a colname of sample_table to assign colors to different groups in plot.
plot_shapedefault NULL; a colname of sample_table to assign shapes to different groups in plot.
plot_group_orderdefault NULL; a vector used to order the groups in the legend of plot.
add_sample_labeldefault NULL; the column name in sample table, if provided, show the point name in plot.
point_sizedefault 3; point size in plot when "point" is in plot_type.
point_alphadefault .8; point transparency in plot when "point" is in plot_type.
centroid_segment_alphadefault 0.6; segment transparency in plot when "centroid" is in plot_type.
centroid_segment_sizedefault 1; segment size in plot when "centroid" is in plot_type.
centroid_segment_linetypedefault 3; the line type related with centroid in plot when "centroid" is in plot_type.
ellipse_chull_filldefault TRUE; whether fill colors to the area of ellipse or chull.
ellipse_chull_alphadefault 0.1; color transparency in the ellipse or convex hull depending on whether "ellipse" or "centroid" is in plot_type.
ellipse_leveldefault .9; confidence level of ellipse when "ellipse" is in plot_type.
ellipse_typedefault "t"; ellipse type when "ellipse" is in plot_type; see type in stat_ellipse.
ggplot.
t1$plot_ordination(plot_type = "point")
t1$plot_ordination(plot_color = "Group", plot_shape = "Group", plot_type = "point")
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "ellipse"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "chull"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "centroid"),
centroid_segment_linetype = 1)
cal_manova()
Calculate perMANOVA based on Anderson al. (2008) <doi:10.1111/j.1442-9993.2001.01070.pp.x> and R vegan adonis2 function.
trans_beta$cal_manova( manova_all = TRUE, manova_set = NULL, group = NULL, p_adjust_method = "fdr", ... )
manova_alldefault TRUE; TRUE represents test for all the groups, i.e. the overall test; FALSE represents test for all the paired groups.
manova_setdefault NULL; other specified group set for manova, such as "Group + Type" and "Group*Type"; see also adonis2.
groupdefault NULL; a column name of sample_table used for manova. If NULL, search group stored in the object.
p_adjust_methoddefault "fdr"; p.adjust method when manova_all = FALSE; see method parameter of p.adjust function for available options.
...parameters passed to adonis2 function of vegan package.
res_manova stored in object.
t1$cal_manova(manova_all = TRUE)
cal_betadisper()
A wrapper for betadisper function in vegan package for multivariate homogeneity test of groups dispersions.
trans_beta$cal_betadisper(...)
...parameters passed to betadisper function.
res_betadisper stored in object.
t1$cal_betadisper()
cal_group_distance()
Transform sample distances within groups or between groups.
trans_beta$cal_group_distance(within_group = TRUE)
within_groupdefault TRUE; whether transform sample distance within groups, if FALSE, transform sample distance between any two groups.
res_group_distance stored in object.
\donttest{
t1$cal_group_distance(within_group = TRUE)
}
plot_group_distance()
Plotting the distance between samples within or between groups.
trans_beta$plot_group_distance( plot_group_order = NULL, color_values = RColorBrewer::brewer.pal(8, "Dark2"), distance_pair_stat = FALSE, hide_ns = FALSE, hide_ns_more = NULL, pair_compare_filter_match = NULL, pair_compare_filter_select = NULL, pair_compare_method = "wilcox.test", plot_distance_xtype = NULL )
plot_group_orderdefault NULL; a vector used to order the groups in the plot.
color_valuescolors for presentation.
distance_pair_statdefault FALSE; whether do the paired comparisions.
hide_nsdefault FALSE; whether hide the "ns" pairs, i.e. non significant comparisions.
hide_ns_moredefault NULL; character vector; available when hide_ns = TRUE; if provided, used for the specific significance filtering, such as c("ns", "*").
pair_compare_filter_matchdefault NULL; only available when hide_ns = FALSE; if provided, remove the matched groups; use the regular express to match the paired groups.
pair_compare_filter_selectdefault NULL; numeric vector;only available when hide_ns = FALSE; if provided, only select those input groups. This parameter must be a numeric vector used to select the paired combination of groups. For example, pair_compare_filter_select = c(1, 3) can be used to select "CW"-"IW" and "IW"-"TW" from all the three pairs "CW"-"IW", "CW"-"TW" and "IW"-"TW" of ordered groups ("CW", "IW", "TW"). The parameter pair_compare_filter_select and pair_compare_filter_match can not be both used together.
pair_compare_methoddefault wilcox.test; wilcox.test, kruskal.test, t.test or anova.
plot_distance_xtypedefault NULL; number used to make x axis text generate angle.
ggplot.
\donttest{
t1$plot_group_distance(distance_pair_stat = TRUE)
t1$plot_group_distance(distance_pair_stat = TRUE, hide_ns = TRUE)
t1$plot_group_distance(distance_pair_stat = TRUE, hide_ns = TRUE, hide_ns_more = c("ns", "*"))
t1$plot_group_distance(distance_pair_stat = TRUE, pair_compare_filter_select = 3)
}
plot_clustering()
Plotting clustering result. Require ggdendro package.
trans_beta$plot_clustering( use_colors = RColorBrewer::brewer.pal(8, "Dark2"), measure = NULL, group = NULL, replace_name = NULL )
use_colorscolors for presentation.
measuredefault NULL; beta diversity index; If NULL, using the measure when creating object
groupdefault NULL; if provided, use this group to assign color.
replace_namedefault NULL; if provided, use this as label.
ggplot.
t1$plot_clustering(group = "Group", replace_name = c("Saline", "Type"))
clone()
The objects of this class are cloneable with this method.
trans_beta$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `trans_beta$new`
## ------------------------------------------------
data(dataset)
t1 <- trans_beta$new(dataset = dataset, measure = "bray", group = "Group")
## ------------------------------------------------
## Method `trans_beta$cal_ordination`
## ------------------------------------------------
t1$cal_ordination(ordination = "PCoA")
## ------------------------------------------------
## Method `trans_beta$plot_ordination`
## ------------------------------------------------
t1$plot_ordination(plot_type = "point")
t1$plot_ordination(plot_color = "Group", plot_shape = "Group", plot_type = "point")
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "ellipse"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "chull"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "centroid"),
centroid_segment_linetype = 1)
## ------------------------------------------------
## Method `trans_beta$cal_manova`
## ------------------------------------------------
t1$cal_manova(manova_all = TRUE)
## ------------------------------------------------
## Method `trans_beta$cal_betadisper`
## ------------------------------------------------
t1$cal_betadisper()
## ------------------------------------------------
## Method `trans_beta$cal_group_distance`
## ------------------------------------------------
t1$cal_group_distance(within_group = TRUE)
## ------------------------------------------------
## Method `trans_beta$plot_group_distance`
## ------------------------------------------------
t1$plot_group_distance(distance_pair_stat = TRUE)
t1$plot_group_distance(distance_pair_stat = TRUE, hide_ns = TRUE)
t1$plot_group_distance(distance_pair_stat = TRUE, hide_ns = TRUE, hide_ns_more = c("ns", "*"))
t1$plot_group_distance(distance_pair_stat = TRUE, pair_compare_filter_select = 3)
## ------------------------------------------------
## Method `trans_beta$plot_clustering`
## ------------------------------------------------
t1$plot_clustering(group = "Group", replace_name = c("Saline", "Type"))Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.