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 approaches include the bar plot, boxplot, heatmap and pie chart based on An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035>.
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 )
dataset
default NULL; microtable object.
taxrank
default "Phylum"; taxonomic rank.
show
default 0; the relative abundance threshold used for filtering.
ntaxa
default 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.
groupmean
default NULL; calculating mean abundance for each group, select a group column name in sample_table.
delete_full_prefix
default TRUE; whether delete both the prefix and the character in front of them.
delete_part_prefix
default FALSE; whether only delete the prefix.
prefix
default 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.
use_percentage
default TRUE; show the abundance percentage.
input_taxaname
default NULL; character vector; if some taxa are selected, input taxa names.
abund_data for plotting.
\donttest{ data(dataset) t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 10) }
plot_bar()
Bar plot in trans_abund object.
trans_abund$plot_bar( use_colors = 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, base_font = NULL, ylab_title = NULL )
use_colors
default RColorBrewer::brewer.pal(12, "Paired"); providing the plotting colors.
bar_type
default "full"; "full" or "notfull"; if full, the total abundance sum to 1 or 100 percentage.
others_color
default "grey90"; the color for "others" taxa.
facet
default NULL; if using facet, providing a group column name of sample_table, such as, "Group".
facet2
default 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_facet
NULL; vector; used to order the facet, such as, c("Group1", "Group3", "Group2").
x_axis_name
NULL; a character string; a column name of sample_table used to show the sample names in x axis.
order_x
default NULL; vector; used to order the sample names in x axis; must be the samples vector, such as, c("S1", "S3", "S2").
barwidth
default NULL; bar width, see width in geom_bar
.
use_alluvium
default FALSE; whether add alluvium plot
clustering
default FALSE; whether order samples by the clustering
facet_color
default "grey95"; facet background color.
strip_text
default 11; facet text size.
legend_text_italic
default FALSE; whether use italic in legend.
xtext_type_hor
default TRUE; x axis text horizontal, if FALSE; text slant.
xtext_size
default 10; x axis text size.
xtext_keep
default TRUE; whether retain x text.
xtitle_keep
default TRUE; whether retain x title.
ytitle_size
default 17; y axis title size.
base_font
default NULL; ggplot font family in the plot.
ylab_title
default NULL; y axis title.
ggplot2 plot.
\donttest{ t1$plot_bar(facet = "Group", xtext_keep = FALSE) }
plot_heatmap()
Plot the heatmap in trans_abund object.
trans_abund$plot_heatmap( use_colors = c("#00008B", "#102D9B", "#215AAC", "#3288BD", "#66C2A5", "#E6F598", "#FFFFBF", "#FED690", "#FDAE61", "#F46D43", "#D53E4F", "#9E0142"), 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, base_font = NULL, pheatmap = FALSE, ... )
use_colors
default RColorBrewer::brewer.pal(12, "Paired"); providing the plotting colors.
facet
default NULL; a character string; if using facet, providing a group column name of sample_table, such as, "Group".
order_facet
NULL; vector; used to order the facet, such as, c("Group1", "Group3", "Group2").
x_axis_name
NULL; a character string; a column name of sample_table used to show the sample names in x axis.
order_x
default NULL; vector; used to order the sample names in x axis; must be the samples vector, such as, c("S1", "S3", "S2").
withmargin
default TRUE; whether retain the tile margin.
plot_numbers
default FALSE; whether plot the number in heatmap.
plot_text_size
default 4; If plot_numbers TRUE, text size in plot.
plot_breaks
default NULL; The legend breaks.
margincolor
default "white"; If withmargin TRUE, use this as the margin color.
plot_colorscale
default "log10"; color scale.
min_abundance
default .01; the minimum abundance percentage in plot.
max_abundance
default NULL; the maximum abundance percentage in plot, NULL reprensent the max percentage.
strip_text
default 11; facet text size.
xtext_size
default 10; x axis text size.
ytext_size
default 11; y axis text size.
xtext_keep
default TRUE; whether retain x text.
xtitle_keep
default TRUE; whether retain x title.
grid_clean
default TRUE; whether remove grid lines.
xtext_type_hor
default TRUE; x axis text horizontal, if FALSE; text slant.
base_font
default NULL; font in the plot.
pheatmap
default 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 in trans_abund object.
trans_abund$plot_box( use_colors = 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, base_font = NULL, ... )
use_colors
default RColorBrewer::brewer.pal(12, "Paired"); providing the plotting colors.
group
default NULL; column name of sample table to show abundance across groups.
show_point
default FALSE; whether show points in plot.
point_color
default "black"; If show_point TRUE; use the color
point_size
default 3; If show_point TRUE; use the size
point_alpha
default .3; If show_point TRUE; use the transparency.
plot_flip
default FALSE; Whether rotate plot.
boxfill
default TRUE; Whether fill the box.
middlecolor
default "grey95"; The middle line color.
middlesize
default 1; The middle line size.
xtext_type_hor
default TRUE; x axis text horizontal, if FALSE; text slant.
xtext_size
default 10; x axis text size.
xtext_keep
default TRUE; whether retain x text.
xtitle_keep
default TRUE; whether retain x title.
ytitle_size
default 17; y axis title size.
base_font
default NULL; font in the plot.
...
parameters pass to geom_boxplot
.
ggplot2 plot.
\donttest{ t1$plot_box(group = "Group") }
plot_pie()
Plot pie chart in trans_abund class.
trans_abund$plot_pie( use_colors = RColorBrewer::brewer.pal(8, "Dark2"), facet_nrow = 1, strip_text = 11, legend_text_italic = FALSE )
use_colors
default RColorBrewer::brewer.pal(8, "Dark2"); providing the plotting colors.
facet_nrow
default 1; how many rows in the plot.
strip_text
default 11; sample title size.
legend_text_italic
default 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)
deep
Whether to make a deep clone.
# NOT RUN {
## ------------------------------------------------
## Method `trans_abund$new`
## ------------------------------------------------
# }
# NOT RUN {
data(dataset)
t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 10)
# }
# NOT RUN {
## ------------------------------------------------
## Method `trans_abund$plot_bar`
## ------------------------------------------------
# }
# NOT RUN {
t1$plot_bar(facet = "Group", xtext_keep = FALSE)
# }
# NOT RUN {
## ------------------------------------------------
## Method `trans_abund$plot_heatmap`
## ------------------------------------------------
# }
# NOT RUN {
t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 40)
t1$plot_heatmap(facet = "Group", xtext_keep = FALSE, withmargin = FALSE)
# }
# NOT RUN {
## ------------------------------------------------
## Method `trans_abund$plot_box`
## ------------------------------------------------
# }
# NOT RUN {
t1$plot_box(group = "Group")
# }
# NOT RUN {
## ------------------------------------------------
## Method `trans_abund$plot_pie`
## ------------------------------------------------
# }
# NOT RUN {
t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", ntaxa = 6, groupmean = "Group")
t1$plot_pie(facet_nrow = 1)
# }
Run the code above in your browser using DataLab