plotBars {SQMtools} | R Documentation |
Plot a barplot using ggplot2
Description
Plot a ggplot2 barplot from a matrix or data frame. The data should be in tabular format (e.g. features in rows and samples in columns).
Usage
plotBars(
data,
label_x = "Samples",
label_y = "Abundances",
label_fill = "Features",
color = NULL,
base_size = 11,
max_scale_value = NULL,
metadata_groups = NULL
)
Arguments
data |
Numeric matrix or data frame. |
label_x |
character Label for the x axis (default |
label_y |
character Label for the y axis (default |
label_fill |
character Label for color categories (default |
color |
Vector with custom colors for the different features. If empty, the default ggplot2 palette will be used (default |
base_size |
numeric. Base font size (default |
max_scale_value |
numeric. Maximum value to include in the y axis. By default it is handled automatically by ggplot2 (default |
metadata_groups |
list. Split the plot into groups defined by the user: list('G1' = c('sample1', sample2'), 'G2' = c('sample3', 'sample4')) default |
Value
a ggplot2 plot object.
See Also
plotTaxonomy
for plotting the most abundant taxa of a SQM object; plotHeatmap
for plotting a heatmap with arbitrary data; mostAbundant
for selecting the most abundant rows in a dataframe or matrix.
Examples
data(Hadza)
sk = Hadza$taxa$superkingdom$abund
plotBars(sk, label_y = "Raw reads", label_fill = "Superkingdom")