Create trans_abund object to transform taxonomic abundance for plotting.
This class is a wrapper for the taxonomic abundance transformations and plotting. The transformed data style is the long-format for ggplot2 plotting. The plotting methods include bar plot, boxplot, heatmap and pie chart.
new()
trans_abund$new( dataset = NULL, taxrank = "Phylum", show = 0, ntaxa = 10, groupmean = NULL, delete_full_prefix = TRUE, delete_part_prefix = FALSE, prefix = NULL, use_percentage = TRUE, input_taxaname = NULL )
datasetdefault NULL; the object of microtable class.
taxrankdefault "Phylum"; taxonomic rank.
showdefault 0; the relative abundance threshold used for filtering.
ntaxadefault 10; how many taxa will be used, ordered by abundance from high to low; this parameter does not conflict with the parameter show; both can be used.
groupmeandefault NULL; calculating mean abundance for each group; select a group column name in sample_table.
delete_full_prefixdefault TRUE; whether delete both the prefix of taxonomy and the character in front of them.
delete_part_prefixdefault FALSE; whether only delete the prefix of taxonomy.
prefixdefault NULL; character string; can be used when delete_full_prefix = T or delete_part_prefix = T; default NULL reprensents using the "letter+__", e.g. "k__" for Phylum level; Please alter this parameter when the prefix is not standard.
use_percentagedefault TRUE; show the abundance percentage.
input_taxanamedefault NULL; character vector; if some taxa are selected, input taxa names.
data_abund stored in the object for plotting.
\donttest{
data(dataset)
t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 10)
}
plot_bar()
Bar plot.
trans_abund$plot_bar( color_values = RColorBrewer::brewer.pal(12, "Paired"), bar_type = "full", others_color = "grey90", facet = NULL, facet2 = NULL, order_facet = NULL, x_axis_name = NULL, order_x = NULL, barwidth = NULL, use_alluvium = FALSE, clustering = FALSE, facet_color = "grey95", strip_text = 11, legend_text_italic = FALSE, xtext_type_hor = TRUE, xtext_size = 10, xtext_keep = TRUE, xtitle_keep = TRUE, ytitle_size = 17, ylab_title = NULL )
color_valuesdefault RColorBrewer::brewer.pal(12, "Paired"); colors palette for the plotting.
bar_typedefault "full"; "full" or "notfull"; if full, the total abundance sum to 1 or 100 percentage.
others_colordefault "grey90"; the color for "others" taxa.
facetdefault NULL; if using facet, providing a group column name of sample_table, such as, "Group".
facet2default NULL; the second facet, used with facet parameter together; facet2 should have a finer scale; use this parameter, please first install package ggh4x using install.packages("ggh4x")
order_facetNULL; vector; used to order the facet, such as, c("Group1", "Group3", "Group2").
x_axis_nameNULL; a character string; a column name of sample_table used to show the sample names in x axis.
order_xdefault NULL; vector; used to order the sample names in x axis; must be the samples vector, such as, c("S1", "S3", "S2").
barwidthdefault NULL; bar width, see width in geom_bar.
use_alluviumdefault FALSE; whether add alluvium plot
clusteringdefault FALSE; whether order samples by the clustering
facet_colordefault "grey95"; facet background color.
strip_textdefault 11; facet text size.
legend_text_italicdefault FALSE; whether use italic in legend.
xtext_type_hordefault TRUE; x axis text horizontal, if FALSE; text slant.
xtext_sizedefault 10; x axis text size.
xtext_keepdefault TRUE; whether retain x text.
xtitle_keepdefault TRUE; whether retain x title.
ytitle_sizedefault 17; y axis title size.
ylab_titledefault NULL; y axis title.
ggplot2 plot.
\donttest{
t1$plot_bar(facet = "Group", xtext_keep = FALSE)
}
plot_heatmap()
Plot the heatmap.
trans_abund$plot_heatmap( color_values = rev(RColorBrewer::brewer.pal(n = 11, name = "RdYlBu")), facet = NULL, order_facet = NULL, x_axis_name = NULL, order_x = NULL, withmargin = TRUE, plot_numbers = FALSE, plot_text_size = 4, plot_breaks = NULL, margincolor = "white", plot_colorscale = "log10", min_abundance = 0.01, max_abundance = NULL, strip_text = 11, xtext_size = 10, ytext_size = 11, xtext_keep = TRUE, xtitle_keep = TRUE, grid_clean = TRUE, xtext_type_hor = TRUE, pheatmap = FALSE, ... )
color_valuesdefault rev(RColorBrewer::brewer.pal(n = 11, name = "RdYlBu")); colors palette for the plotting.
facetdefault NULL; a character string; if using facet, provide a column name in sample_table, such as "Group".
order_facetNULL; vector; used to order the facet, such as, c("Group1", "Group3", "Group2").
x_axis_nameNULL; a character string; a column name of sample_table used to show the sample names in x axis.
order_xdefault NULL; vector; used to order the sample names in x axis; must be the samples vector, such as, c("S1", "S3", "S2").
withmargindefault TRUE; whether retain the tile margin.
plot_numbersdefault FALSE; whether plot the number in heatmap.
plot_text_sizedefault 4; If plot_numbers TRUE, text size in plot.
plot_breaksdefault NULL; The legend breaks.
margincolordefault "white"; If withmargin TRUE, use this as the margin color.
plot_colorscaledefault "log10"; color scale.
min_abundancedefault .01; the minimum abundance percentage in plot.
max_abundancedefault NULL; the maximum abundance percentage in plot, NULL reprensent the max percentage.
strip_textdefault 11; facet text size.
xtext_sizedefault 10; x axis text size.
ytext_sizedefault 11; y axis text size.
xtext_keepdefault TRUE; whether retain x text.
xtitle_keepdefault TRUE; whether retain x title.
grid_cleandefault TRUE; whether remove grid lines.
xtext_type_hordefault TRUE; x axis text horizontal, if FALSE; text slant.
pheatmapdefault FALSE; whether use pheatmap package to plot the heatmap.
...paremeters pass to pheatmap when pheatmap = TRUE.
ggplot2 plot or grid plot based on pheatmap.
\donttest{
t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 40)
t1$plot_heatmap(facet = "Group", xtext_keep = FALSE, withmargin = FALSE)
}
plot_box()
Box plot.
trans_abund$plot_box( color_values = RColorBrewer::brewer.pal(8, "Dark2"), group = NULL, show_point = FALSE, point_color = "black", point_size = 3, point_alpha = 0.3, plot_flip = FALSE, boxfill = TRUE, middlecolor = "grey95", middlesize = 1, xtext_type_hor = FALSE, xtext_size = 10, xtext_keep = TRUE, xtitle_keep = TRUE, ytitle_size = 17, ... )
color_valuesdefault RColorBrewer::brewer.pal(8, "Dark2"); colors palette for the plotting.
groupdefault NULL; a column name of sample table to show abundance across groups.
show_pointdefault FALSE; whether show points in plot.
point_colordefault "black"; If show_point TRUE; use the color
point_sizedefault 3; If show_point TRUE; use the size
point_alphadefault .3; If show_point TRUE; use the transparency.
plot_flipdefault FALSE; Whether rotate plot.
boxfilldefault TRUE; Whether fill the box with colors.
middlecolordefault "grey95"; The middle line color.
middlesizedefault 1; The middle line size.
xtext_type_hordefault TRUE; x axis text horizontal, if FALSE; text slant.
xtext_sizedefault 10; x axis text size.
xtext_keepdefault TRUE; whether retain x text.
xtitle_keepdefault TRUE; whether retain x title.
ytitle_sizedefault 17; y axis title size.
...parameters pass to geom_boxplot.
ggplot2 plot.
\donttest{
t1$plot_box(group = "Group")
}
plot_line()
Plot the line chart.
trans_abund$plot_line( color_values = RColorBrewer::brewer.pal(8, "Dark2"), plot_SE = TRUE, 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, xtext_type_hor = FALSE, xtext_size = 10, ytitle_size = 17 )
color_valuesdefault RColorBrewer::brewer.pal(8, "Dark2"); colors palette for the plotting.
plot_SEdefault TRUE; TRUE: plot the errorbar with mean±se; FALSE: plot the errorbar with mean±sd.
positiondefault position_dodge(0.1); Position adjustment, 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.
xtext_type_hordefault TRUE; x axis text horizontal, if FALSE; text slant.
xtext_sizedefault 10; x axis text size.
ytitle_sizedefault 17; y axis title size.
ggplot2 plot.
\donttest{
t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 5)
t1$plot_line(point_size = 3)
t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 5, groupmean = "Group")
t1$plot_line(point_size = 5, errorbar_size = 1, xtext_type_hor = TRUE)
}
plot_pie()
Plot pie chart.
trans_abund$plot_pie( color_values = RColorBrewer::brewer.pal(8, "Dark2"), facet_nrow = 1, strip_text = 11, legend_text_italic = FALSE )
color_valuesdefault RColorBrewer::brewer.pal(8, "Dark2"); colors palette for the plotting.
facet_nrowdefault 1; how many rows in the plot.
strip_textdefault 11; sample title size.
legend_text_italicdefault FALSE; whether use italic in legend.
ggplot2 plot.
\donttest{
t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 6, groupmean = "Group")
t1$plot_pie(facet_nrow = 1)
}
print()
Print the trans_abund object.
trans_abund$print()
clone()
The objects of this class are cloneable with this method.
trans_abund$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------ ## Method `trans_abund$new` ## ------------------------------------------------ data(dataset) t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 10) ## ------------------------------------------------ ## Method `trans_abund$plot_bar` ## ------------------------------------------------ t1$plot_bar(facet = "Group", xtext_keep = FALSE) ## ------------------------------------------------ ## Method `trans_abund$plot_heatmap` ## ------------------------------------------------ t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 40) t1$plot_heatmap(facet = "Group", xtext_keep = FALSE, withmargin = FALSE) ## ------------------------------------------------ ## Method `trans_abund$plot_box` ## ------------------------------------------------ t1$plot_box(group = "Group") ## ------------------------------------------------ ## Method `trans_abund$plot_line` ## ------------------------------------------------ t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 5) t1$plot_line(point_size = 3) t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 5, groupmean = "Group") t1$plot_line(point_size = 5, errorbar_size = 1, xtext_type_hor = TRUE) ## ------------------------------------------------ ## Method `trans_abund$plot_pie` ## ------------------------------------------------ t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 6, groupmean = "Group") t1$plot_pie(facet_nrow = 1)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.