| Title: | Microbiome Analysis Plotting and Visualization |
|---|---|
| Description: | The miaViz package implements functions to visualize TreeSummarizedExperiment objects especially in the context of microbiome analysis. Part of the mia family of R/Bioconductor packages. |
| Authors: | Tuomas Borman [aut, cre] (ORCID: <https://orcid.org/0000-0002-8563-8884>), Felix G.M. Ernst [aut] (ORCID: <https://orcid.org/0000-0001-5064-0928>), Leo Lahti [aut] (ORCID: <https://orcid.org/0000-0001-5537-637X>), Basil Courbayre [ctb], Giulio Benedetti [ctb] (ORCID: <https://orcid.org/0000-0002-8732-7692>), Théotime Pralas [ctb], Chouaib Benchraka [ctb], Sam Hillman [ctb], Geraldson Muluh [ctb], Noah De Gunst [ctb], Ely Seraidarian [ctb], Himmi Lindgren [ctb], Akewak Jeba [ctb] (ORCID: <https://orcid.org/0009-0007-1347-7552>), Vivian Ikeh [ctb] |
| Maintainer: | Tuomas Borman <[email protected]> |
| License: | Artistic-2.0 | file LICENSE |
| Version: | 1.21.0 |
| Built: | 2026-05-09 09:09:28 UTC |
| Source: | https://github.com/bioc/miaViz |
The scope of this package is the plotting and visualization of microbiome
data. The main class for interfacing is the TreeSummarizedExperiment
class.
Maintainer: Tuomas Borman [email protected] (ORCID)
Authors:
Felix G.M. Ernst (ORCID)
Leo Lahti [email protected] (ORCID)
Other contributors:
Basil Courbayre [contributor]
Giulio Benedetti (ORCID) [contributor]
Théotime Pralas [contributor]
Chouaib Benchraka [contributor]
Sam Hillman [contributor]
Geraldson Muluh [contributor]
Noah De Gunst [contributor]
Ely Seraidarian [contributor]
Himmi Lindgren [contributor]
Akewak Jeba (ORCID) [contributor]
Vivian Ikeh [contributor]
mia class
These functions will be deprecated. Please use other functions instead.
plotTaxaPrevalence(x, ...) ## S4 method for signature 'ANY' plotTaxaPrevalence(x, ...) plotFeaturePrevalence(x, ...) ## S4 method for signature 'ANY' plotFeaturePrevalence(x, ...)plotTaxaPrevalence(x, ...) ## S4 method for signature 'ANY' plotTaxaPrevalence(x, ...) plotFeaturePrevalence(x, ...) ## S4 method for signature 'ANY' plotFeaturePrevalence(x, ...)
x |
|
... |
|
getNeatOrder sorts already ordinated data by the radial
theta angle. This method is useful for organizing data points based on their
angular position in a 2D space, typically after an ordination technique such
as PCA or NMDS has been applied.
The function takes in a matrix of ordinated data, optionally
centers the data using specified methods (mean, median, or
NULL), and then calculates the angle (theta) for each point relative
to the centroid. The data points are then sorted based on these theta values
in ascending order.
One significant application of this sorting method is in plotting heatmaps. By using radial theta sorting, the relationships between data points can be preserved according to the ordination method's spatial configuration, rather than relying on hierarchical clustering, which may distort these relationships. This approach allows for a more faithful representation of the data's intrinsic structure as captured by the ordination process.
getNeatOrder(x, centering = "mean", ...) ## S4 method for signature 'matrix' getNeatOrder(x, centering = "mean", ...)getNeatOrder(x, centering = "mean", ...) ## S4 method for signature 'matrix' getNeatOrder(x, centering = "mean", ...)
x |
A matrix containing the ordinated data to be sorted. Columns should represent the principal components (PCs) and rows should represent the entities being analyzed (e.g. features or samples). There should be 2 columns only representing 2 PCs. |
centering |
|
... |
Additional arguments passed to other methods. |
It's important to note that the sechm package does actually have the functionality for plotting a heatmap using this radial theta angle ordering, though only by using an MDS ordination.
That being said, the getNeatOrder function is more modular and
separate to the plotting, and can be applied to any kind of ordinated data
which can be valuable depending on the use case.
Rajaram & Oono (2010) NeatMap - non-clustering heat map alternatives in R outlines this in more detail.
A character vector of row indices in the sorted order.
# Load the required libraries and dataset library(mia) library(scater) library(ComplexHeatmap) |> suppressPackageStartupMessages() library(circlize) |> suppressPackageStartupMessages() data(peerj13075) # Group data by taxonomic order tse <- agglomerateByRank(peerj13075, rank = "order", onRankOnly = TRUE) # Transform the samples into relative abundances using CLR tse <- transformAssay( tse, assay.type = "counts", method="clr", MARGIN = "cols", name="clr", pseudocount = TRUE) # Transform the features (taxa) into zero mean, unit variance # (standardize transformation) tse <- transformAssay( tse, assay.type="clr", method="standardize", MARGIN = "rows") # Perform PCA using calculatePCA res <- calculatePCA(tse, assay.type = "standardize", ncomponents = 10) # Sort by radial theta and sort the original assay data sorted_order <- getNeatOrder(res[, c(1,2)], centering = "mean") tse <- tse[, sorted_order] # Define the color function and cap the colors at [-5, 5] col_fun <- colorRamp2(c(-5, 0, 5), c("blue", "white", "red")) # Create the heatmap heatmap <- Heatmap(assay(tse, "standardize"), name = "NeatMap", col = col_fun, cluster_rows = FALSE, # Do not cluster rows cluster_columns = FALSE, # Do not cluster columns show_row_dend = FALSE, show_column_dend = FALSE, row_names_gp = gpar(fontsize = 4), column_names_gp = gpar(fontsize = 6), heatmap_width = unit(20, "cm"), heatmap_height = unit(15, "cm") )# Load the required libraries and dataset library(mia) library(scater) library(ComplexHeatmap) |> suppressPackageStartupMessages() library(circlize) |> suppressPackageStartupMessages() data(peerj13075) # Group data by taxonomic order tse <- agglomerateByRank(peerj13075, rank = "order", onRankOnly = TRUE) # Transform the samples into relative abundances using CLR tse <- transformAssay( tse, assay.type = "counts", method="clr", MARGIN = "cols", name="clr", pseudocount = TRUE) # Transform the features (taxa) into zero mean, unit variance # (standardize transformation) tse <- transformAssay( tse, assay.type="clr", method="standardize", MARGIN = "rows") # Perform PCA using calculatePCA res <- calculatePCA(tse, assay.type = "standardize", ncomponents = 10) # Sort by radial theta and sort the original assay data sorted_order <- getNeatOrder(res[, c(1,2)], centering = "mean") tse <- tse[, sorted_order] # Define the color function and cap the colors at [-5, 5] col_fun <- colorRamp2(c(-5, 0, 5), c("blue", "white", "red")) # Create the heatmap heatmap <- Heatmap(assay(tse, "standardize"), name = "NeatMap", col = col_fun, cluster_rows = FALSE, # Do not cluster rows cluster_columns = FALSE, # Do not cluster columns show_row_dend = FALSE, show_column_dend = FALSE, row_names_gp = gpar(fontsize = 4), column_names_gp = gpar(fontsize = 6), heatmap_width = unit(20, "cm"), heatmap_height = unit(15, "cm") )
These example data objects were prepared to serve as examples. See the details for more information.
data(col_graph) data(row_graph) data(row_graph_order)data(col_graph) data(row_graph) data(row_graph_order)
An object of class tbl_graph (inherits from igraph) of length 26.
An object of class tbl_graph (inherits from igraph) of length 996.
An object of class tbl_graph (inherits from igraph) of length 110.
For *_graph data:
“Jaccard” distances were calculated via
calculateDistance(genus, FUN = vegan::vegdist, method = "jaccard",
exprs_values = "relabundance"), either using transposed assay data or not
to calculate distances for samples or features. NOTE: the function
mia::calculateDistance is now deprecated.
“Jaccard” dissimilarites were converted to similarities and values
above a threshold were used to construct a graph via
graph.adjacency(mode = "lower", weighted = TRUE).
The igraph object was converted to tbl_graph via
as_tbl_graph from the tidygraph package.
To be able to fine tune plotting, several additional plotting arguments are available. These are described on this page.
line.alpha: Numeric scalar in [0, 1],
Specifies the transparency of the tree edges. (Default: 1)
line.width: Numeric scalar. Specifies the default
width of an edge. (Default: NULL) to use default of the
ggtree package.
line.width.range: Numeric vector. The range for
plotting dynamic edge widths in. (Default: c(0.5,3))
point.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the tips. (Defaults: 1)
point.size: Numeric scalar. Specifies the
default size of tips. (Defaults: 2)
point.size.range: Numeric vector. Specifies the range
for plotting dynamic tip sizes in. (Defaults: c(1,4))
label.font.size: Numeric scalar. Font size for the
tip and node labels. (Default: 3)
highlight.font.size: Numeric scalar. Font size for
the highlight labels. (Default: 3)
line.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the tree edges. (Default: 1)
line.width: Numeric scalar. Specifies the default
width of an edge. (Default: NULL) to use default of the
ggtree package.
line.width.range: Numeric vector. The range for
plotting dynamic edge widths in. (Default: c(0.5,3))
point.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the tips. (Default: 1)
point.size: Numeric scalar. Specifies the
default size of tips. (Default: 2.)
point.size.range: Numeric vector. The range for
plotting dynamic tip sizes in. (Default: c(1,4))
flipped: Logical scalar. Should the plot be flipped?
(Default: FALSE)
add.legend: Logical scalar. Should legends be
plotted? (Default: TRUE)
add.x.text: Logical scalar. Should x tick labels be
plotted? (Default: FALSE)
add.border: Logical scalar. Should border of bars be
plotted? (Default: FALSE)
bar.alpha: Numeric scalar in [0, 1]. Specifies
the transparency of the bars. (Default: 1)
point.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the points. (Default: 1)
point.size: Numeric scalar. Specifies the
default size of points. (Default: 2)
add.legend: Logical scalar. Should legends be
plotted? (Default: TRUE)
point.shape: Numeric scalar. Sets the shape of
points. (Default: 21)
point.colour: Character scalar. Specifies the
default colour of points. (Default: 2)
point.size: Numeric scalar. Specifies the
default size of points. (Default: 2)
point.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the points. (Default: 1)
flipped: Logical scalar. Should the plot be flipped?
(Default: FALSE)
scales.free: Logical scalar. Should
scales = "free" be set for faceted plots? (Default: TRUE)
angle.x.text: Logical scalar. Should x tick labels be
plotted? (Default: FALSE)
flipped: Logical scalar. Specifies whether the plot
should be flipped. (Default: FALSE)
add.legend: Logical scalar. Should legends be
plotted? (Default: TRUE)
point.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the tips. (Default: 1)
point.size: Numeric scalar. Specifies the
default size of tips. (Default: 2.)
line.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the tree edges. (Default: 1)
line.type: Numeric scalar. Specifies the default line
type. (Default: NULL) to use default of the ggplot2 package.
line.size: Numeric scalar. Specifies the default
width of a line. (Default: NULL) to use default of the
ggplot2 package.
add.legend: Logical scalar. Should legends be
plotted? (Default: TRUE)
line.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the tree edges. (Default: 1)
line.type: Numeric scalar. Specifies the default line
type. (Default: NULL) to use default of the ggplot2 package.
line.width: Numeric scalar. Specifies the default
width of a line. (Default: NULL) to use default of the
ggplot2 package.
line.width.range: Numeric vector. The range for
plotting dynamic line widths in. (Default: c(0.5,3))
ribbon.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the ribbon. (Default: 0.3)
add.legend: Logical scalar. Should legends be
plotted? (Default: TRUE)
rect.alpha: Numeric scalar in [0, 1].
Specifies the transparency of the areas. (Default: 1)
rect.colour: Character scalar. Specifies the colour
to use for colouring the borders of the areas. (Default: "black")
na.value: Character scalar. Specifies the colour to
use for NA values. (Default: "grey80")
plotAbundance() creates a barplot of feature abundances, typically
used to visualize the relative abundance of features at a specific taxonomy
rank.
plotAbundance(x, ...) ## S4 method for signature 'SummarizedExperiment' plotAbundance( x, assay.type = assay_name, assay_name = "counts", layout = "bar", ... )plotAbundance(x, ...) ## S4 method for signature 'SummarizedExperiment' plotAbundance( x, assay.type = assay_name, assay_name = "counts", layout = "bar", ... )
x |
a
|
... |
additional parameters for plotting.
See |
assay.type |
|
assay_name |
Deprecate. Use |
layout |
|
It is recommended to handle subsetting, agglomeration, and transformation
outside this function. However, agglomeration and relative transformation
can be applied using the group and as.relative parameters,
respectively. If one of the TAXONOMY_RANKS is selected via
group, mia::agglomerateByRank() is used, otherwise
agglomerateByVariable() is applied.
a ggplot object or list of two
ggplot objects, if col.var are added to
the plot.
data(GlobalPatterns, package="mia") tse <- GlobalPatterns # If rank is set to NULL (default), agglomeration is not done. However, note # that there is maximum number of rows that can be plotted. That is why # we take sample from the data. set.seed(26348) sample <- sample(rownames(tse), 20) tse_sub <- tse[sample, ] # Apply relative transformation tse_sub <- transformAssay(tse_sub, method = "relabundance") plotAbundance(tse_sub, assay.type = "relabundance") # Plotting counts using the first taxonomic rank as default plotAbundance( tse, assay.type="counts", group = "Phylum") + labs(y="Counts") # Using "Phylum" as rank. Apply relative transformation to "counts" assay. plotAbundance( tse, assay.type="counts", group = "Phylum", add_legend = FALSE, as.relative = TRUE) # Apply relative transform tse <- transformAssay(tse, method = "relabundance") # A feature from colData or taxon from chosen rank can be used for ordering # samples. plotAbundance( tse, assay.type="relabundance", group = "Phylum", order.col.by = "Bacteroidetes") # col.var from colData can be plotted together with abundance plot. # Returned object is a list that includes two plot; other visualizes ## abundance other col.var. plot <- plotAbundance( tse, assay.type = "relabundance", group = "Phylum", col.var = "SampleType") # These two plots can be combined with wrap_plots function from patchwork # package library(patchwork) wrap_plots(plot, ncol = 1, heights = c(0.95, 0.05)) # Same plot as above but showing sample IDs as labels for the x axis on the # top plot. Moreover, we use facets. plot <- plotAbundance( tse, assay.type = "relabundance", group = "Phylum", col.var = "SampleType", add.legend = FALSE, add.x.text = TRUE, facet.cols = TRUE, scales = "free_x") + theme(axis.text.x = element_text(angle = 90)) plot # Compositional barplot with top 5 taxa and samples sorted by # "Bacteroidetes" # Getting top taxa on a Phylum level tse <- transformAssay(tse, method = "relabundance") tse_phylum <- agglomerateByRank(tse, rank = "Phylum") top_taxa <- getTop(tse_phylum, top = 5, assay.type = "relabundance") # Renaming the "Phylum" rank to keep only top taxa and the rest to "Other" phylum_renamed <- lapply(rowData(tse)$Phylum, function(x){ if (x %in% top_taxa) {x} else {"Other"}}) rowData(tse)$Phylum <- as.character(phylum_renamed) # Compositional barplot plotAbundance( tse, assay.type="relabundance", group = "Phylum", order.row.by="abund", order.col.by = "Bacteroidetes")data(GlobalPatterns, package="mia") tse <- GlobalPatterns # If rank is set to NULL (default), agglomeration is not done. However, note # that there is maximum number of rows that can be plotted. That is why # we take sample from the data. set.seed(26348) sample <- sample(rownames(tse), 20) tse_sub <- tse[sample, ] # Apply relative transformation tse_sub <- transformAssay(tse_sub, method = "relabundance") plotAbundance(tse_sub, assay.type = "relabundance") # Plotting counts using the first taxonomic rank as default plotAbundance( tse, assay.type="counts", group = "Phylum") + labs(y="Counts") # Using "Phylum" as rank. Apply relative transformation to "counts" assay. plotAbundance( tse, assay.type="counts", group = "Phylum", add_legend = FALSE, as.relative = TRUE) # Apply relative transform tse <- transformAssay(tse, method = "relabundance") # A feature from colData or taxon from chosen rank can be used for ordering # samples. plotAbundance( tse, assay.type="relabundance", group = "Phylum", order.col.by = "Bacteroidetes") # col.var from colData can be plotted together with abundance plot. # Returned object is a list that includes two plot; other visualizes ## abundance other col.var. plot <- plotAbundance( tse, assay.type = "relabundance", group = "Phylum", col.var = "SampleType") # These two plots can be combined with wrap_plots function from patchwork # package library(patchwork) wrap_plots(plot, ncol = 1, heights = c(0.95, 0.05)) # Same plot as above but showing sample IDs as labels for the x axis on the # top plot. Moreover, we use facets. plot <- plotAbundance( tse, assay.type = "relabundance", group = "Phylum", col.var = "SampleType", add.legend = FALSE, add.x.text = TRUE, facet.cols = TRUE, scales = "free_x") + theme(axis.text.x = element_text(angle = 90)) plot # Compositional barplot with top 5 taxa and samples sorted by # "Bacteroidetes" # Getting top taxa on a Phylum level tse <- transformAssay(tse, method = "relabundance") tse_phylum <- agglomerateByRank(tse, rank = "Phylum") top_taxa <- getTop(tse_phylum, top = 5, assay.type = "relabundance") # Renaming the "Phylum" rank to keep only top taxa and the rest to "Other" phylum_renamed <- lapply(rowData(tse)$Phylum, function(x){ if (x %in% top_taxa) {x} else {"Other"}}) rowData(tse)$Phylum <- as.character(phylum_renamed) # Compositional barplot plotAbundance( tse, assay.type="relabundance", group = "Phylum", order.row.by="abund", order.col.by = "Bacteroidetes")
This function plots abundance of the most abundant taxa.
plotAbundanceDensity(x, ...) ## S4 method for signature 'SummarizedExperiment' plotAbundanceDensity( x, layout = c("jitter", "density", "point"), assay.type = assay_name, assay_name = "counts", n = min(nrow(x), 25L), colour.by = colour_by, colour_by = NULL, shape.by = shape_by, shape_by = NULL, size.by = size_by, size_by = NULL, decreasing = order_descending, order_descending = TRUE, ... )plotAbundanceDensity(x, ...) ## S4 method for signature 'SummarizedExperiment' plotAbundanceDensity( x, layout = c("jitter", "density", "point"), assay.type = assay_name, assay_name = "counts", n = min(nrow(x), 25L), colour.by = colour_by, colour_by = NULL, shape.by = shape_by, shape_by = NULL, size.by = size_by, size_by = NULL, decreasing = order_descending, order_descending = TRUE, ... )
x |
a
|
... |
additional parameters for plotting.
See |
layout |
|
assay.type |
|
assay_name |
Deprecate. Use |
n |
|
colour.by |
|
colour_by |
Deprecated. Use |
shape.by |
|
shape_by |
Deprecated. Use |
size.by |
|
size_by |
Deprecated. Use |
decreasing |
|
order_descending |
Deprecated. Use |
This function plots abundance of the most abundant taxa. Abundance can be plotted as a jitter plot, a density plot, or a point plot. By default, x-axis represents abundance and y-axis taxa. In a jitter and point plot, each point represents abundance of individual taxa in individual sample. Most common abundances are shown as a higher density.
A density plot can be seen as a smoothened bar plot. It visualized distribution of abundances where peaks represent most common abundances.
A ggplot2 object
data("peerj13075", package = "mia") tse <- peerj13075 # Plots the abundances of 25 most abundant taxa. Jitter plot is the default # option. plotAbundanceDensity(tse, assay.type = "counts") # Counts relative abundances tse <- transformAssay(tse, method = "relabundance") # Plots the relative abundance of 10 most abundant taxa. # "nationality" information is used to color the points. X-axis is # log-scaled. plotAbundanceDensity( tse, layout = "jitter", assay.type = "relabundance", n = 10, colour.by = "Geographical_location") + scale_x_log10() # Plots the relative abundance of 10 most abundant taxa as a density plot. # X-axis is log-scaled plotAbundanceDensity( tse, layout = "density", assay.type = "relabundance", n = 10 ) + scale_x_log10() # Plots the relative abundance of 10 most abundant taxa as a point plot. # Point shape is changed from default (21) to 41. plotAbundanceDensity( tse, layout = "point", assay.type = "relabundance", n = 10, point.shape = 41) # Plots the relative abundance of 10 most abundant taxa as a point plot. # In addition to colour, groups can be visualized by size and shape in point # plots, and adjusted for point size plotAbundanceDensity( tse, layout = "point", assay.type = "relabundance", n = 10, shape.by = "Geographical_location", size.by = "Age", point.size=1) # Ordering via decreasing plotAbundanceDensity( tse, assay.type = "relabundance", decreasing = FALSE) # for custom ordering set decreasing = NA and order the input object # to your wishes plotAbundanceDensity( tse, assay.type = "relabundance", decreasing = NA) # Box plots and violin plots are supported by scater::plotExpression. # Plots the relative abundance of 5 most abundant taxa as a violin plot. library(scater) top <- getTop(tse, top = 5) plotExpression(tse, features = top, assay.type = "relabundance") + ggplot2::coord_flip() # Plots the relative abundance of 5 most abundant taxa as a box plot. plotExpression(tse, features = top, assay.type = "relabundance", show_violin = FALSE, show_box = TRUE) + ggplot2::coord_flip()data("peerj13075", package = "mia") tse <- peerj13075 # Plots the abundances of 25 most abundant taxa. Jitter plot is the default # option. plotAbundanceDensity(tse, assay.type = "counts") # Counts relative abundances tse <- transformAssay(tse, method = "relabundance") # Plots the relative abundance of 10 most abundant taxa. # "nationality" information is used to color the points. X-axis is # log-scaled. plotAbundanceDensity( tse, layout = "jitter", assay.type = "relabundance", n = 10, colour.by = "Geographical_location") + scale_x_log10() # Plots the relative abundance of 10 most abundant taxa as a density plot. # X-axis is log-scaled plotAbundanceDensity( tse, layout = "density", assay.type = "relabundance", n = 10 ) + scale_x_log10() # Plots the relative abundance of 10 most abundant taxa as a point plot. # Point shape is changed from default (21) to 41. plotAbundanceDensity( tse, layout = "point", assay.type = "relabundance", n = 10, point.shape = 41) # Plots the relative abundance of 10 most abundant taxa as a point plot. # In addition to colour, groups can be visualized by size and shape in point # plots, and adjusted for point size plotAbundanceDensity( tse, layout = "point", assay.type = "relabundance", n = 10, shape.by = "Geographical_location", size.by = "Age", point.size=1) # Ordering via decreasing plotAbundanceDensity( tse, assay.type = "relabundance", decreasing = FALSE) # for custom ordering set decreasing = NA and order the input object # to your wishes plotAbundanceDensity( tse, assay.type = "relabundance", decreasing = NA) # Box plots and violin plots are supported by scater::plotExpression. # Plots the relative abundance of 5 most abundant taxa as a violin plot. library(scater) top <- getTop(tse, top = 5) plotExpression(tse, features = top, assay.type = "relabundance") + ggplot2::coord_flip() # Plots the relative abundance of 5 most abundant taxa as a box plot. plotExpression(tse, features = top, assay.type = "relabundance", show_violin = FALSE, show_box = TRUE) + ggplot2::coord_flip()
assay, rowData or colData.This methods visualizes abundances or variables from rowData or
colData.
plotBoxplot(object, ...) ## S4 method for signature 'SummarizedExperiment' plotBoxplot( object, assay.type = NULL, row.var = NULL, col.var = NULL, x = NULL, features = NULL, group.by = NULL, ... )plotBoxplot(object, ...) ## S4 method for signature 'SummarizedExperiment' plotBoxplot( object, assay.type = NULL, row.var = NULL, col.var = NULL, x = NULL, features = NULL, group.by = NULL, ... )
object |
a
|
... |
Additional parameters for plotting.
|
assay.type |
|
row.var |
|
col.var |
|
x |
|
features |
|
group.by |
|
A box plot is standard visualization technique to compare numeric values,
such as abundance, between categorical values, such as sample groups.
plotBoxplot() streamlines creation of box plots, and it offers
multiple options for visualization.
A ggplot2 object.
data("Tito2024QMP") tse <- Tito2024QMP tse <- transformAssay(tse, method = "relabundance") tse <- addAlpha(tse, index = "shannon") # Visualize alpha diversity plotBoxplot(tse, col.var = "shannon", x = "diagnosis") # Visualize relative abundance of top features tse <- tse[getTop(tse, 6), ] plotBoxplot( tse, assay.type = "relabundance", x = "diagnosis", fill.by = "diagnosis", features = rownames(tse), facet.by = "rownames", ncol = 2 ) # Add proportion bar plotBoxplot( tse, assay.type = "relabundance", x = "diagnosis", fill.by = "diagnosis", features = rownames(tse), facet.by = "rownames", add.proportion = TRUE, threshold = 0.1 ) # Visualize only with beeswarm plotBoxplot( tse, assay.type = "relabundance", x = "diagnosis", group.by = "diagnosis", colour.by = "colonoscopy", features = rownames(tse), facet.by = "rownames", point.offset = "swarm", add.box = FALSE ) # Do not add points plotBoxplot( tse, assay.type = "relabundance", fill.by = "diagnosis", features = rownames(tse), facet.by = "rownames", add.points = FALSE ) # Calculate statistical significance with Wilcoxon test plotBoxplot( tse, col.var = "shannon", fill.by = "diagnosis", add.significance = TRUE ) ## Not run: # Add pre-calculated p-values # Calculate p-values df <- meltSE(tse, add.col = TRUE) pvals <- df |> rstatix::t_test(shannon ~ diagnosis) |> ungroup() |> as.data.frame() # Add them with p.value argument plotBoxplot( tse, x = "diagnosis", col.var = "shannon", p.value = pvals ) ## End(Not run) ## Not run: library(microbiomeDataSets) mae <- microbiomeDataSets::peerj32() tse <- getWithColData(mae, 1) tse[["time_point"]] <- as.character(tse[["time"]]) # Create a plot showing chance between time points in abundance of # Akkermansia plotBoxplot( tse, x = "time_point", assay.type = "counts", fill.by = "group", features = "Akkermansia", pair.by = "subject", add.chance = TRUE, scales = "free" ) ## End(Not run)data("Tito2024QMP") tse <- Tito2024QMP tse <- transformAssay(tse, method = "relabundance") tse <- addAlpha(tse, index = "shannon") # Visualize alpha diversity plotBoxplot(tse, col.var = "shannon", x = "diagnosis") # Visualize relative abundance of top features tse <- tse[getTop(tse, 6), ] plotBoxplot( tse, assay.type = "relabundance", x = "diagnosis", fill.by = "diagnosis", features = rownames(tse), facet.by = "rownames", ncol = 2 ) # Add proportion bar plotBoxplot( tse, assay.type = "relabundance", x = "diagnosis", fill.by = "diagnosis", features = rownames(tse), facet.by = "rownames", add.proportion = TRUE, threshold = 0.1 ) # Visualize only with beeswarm plotBoxplot( tse, assay.type = "relabundance", x = "diagnosis", group.by = "diagnosis", colour.by = "colonoscopy", features = rownames(tse), facet.by = "rownames", point.offset = "swarm", add.box = FALSE ) # Do not add points plotBoxplot( tse, assay.type = "relabundance", fill.by = "diagnosis", features = rownames(tse), facet.by = "rownames", add.points = FALSE ) # Calculate statistical significance with Wilcoxon test plotBoxplot( tse, col.var = "shannon", fill.by = "diagnosis", add.significance = TRUE ) ## Not run: # Add pre-calculated p-values # Calculate p-values df <- meltSE(tse, add.col = TRUE) pvals <- df |> rstatix::t_test(shannon ~ diagnosis) |> ungroup() |> as.data.frame() # Add them with p.value argument plotBoxplot( tse, x = "diagnosis", col.var = "shannon", p.value = pvals ) ## End(Not run) ## Not run: library(microbiomeDataSets) mae <- microbiomeDataSets::peerj32() tse <- getWithColData(mae, 1) tse[["time_point"]] <- as.character(tse[["time"]]) # Create a plot showing chance between time points in abundance of # Akkermansia plotBoxplot( tse, x = "time_point", assay.type = "counts", fill.by = "group", features = "Akkermansia", pair.by = "subject", add.chance = TRUE, scales = "free" ) ## End(Not run)
plotRDA and plotCCA create an RDA/CCA plot starting from the
output of CCA and RDA functions, two common methods
for supervised ordination of microbiome data.
plotCCA(x, ...) plotRDA(x, ...) ## S4 method for signature 'SingleCellExperiment' plotCCA(x, dimred, ...) ## S4 method for signature 'matrix' plotCCA(x, ...) ## S4 method for signature 'SingleCellExperiment' plotRDA(x, dimred, ...) ## S4 method for signature 'matrix' plotRDA(x, ...)plotCCA(x, ...) plotRDA(x, ...) ## S4 method for signature 'SingleCellExperiment' plotCCA(x, dimred, ...) ## S4 method for signature 'matrix' plotCCA(x, ...) ## S4 method for signature 'SingleCellExperiment' plotRDA(x, dimred, ...) ## S4 method for signature 'matrix' plotRDA(x, ...)
x |
a
|
... |
additional parameters for plotting, inherited from
|
dimred |
|
plotRDA and plotCCA create an RDA/CCA plot starting from the
output of CCA and RDA functions, two common methods
for supervised ordination of microbiome data. Either a
TreeSummarizedExperiment
or a matrix object is supported as input. When the input is a
TreeSummarizedExperiment, this should contain the output of addRDA
in the reducedDim slot and the argument dimred needs to be defined.
When the input is a matrix, this should be returned as output from
getRDA. However, the first method is recommended because it provides
the option to adjust aesthetics to the colData variables through the
arguments inherited from plotReducedDim.
A ggplot2 object
# Load dataset data("enterotype", package = "mia") tse <- enterotype # Run RDA and store results into TreeSE tse <- transformAssay(tse, method = "relabundance") tse <- addRDA( tse, assay.type = "relabundance", formula = assay ~ ClinicalStatus + Gender + Age, distance = "bray", na.action = na.exclude ) suppressWarnings({ # Create RDA plot coloured by variable plotRDA(tse, "RDA", colour.by = "ClinicalStatus") # Create RDA plot with empty ellipses plotRDA(tse, "RDA", colour.by = "ClinicalStatus", add.ellipse = "colour") # Create RDA plot with text encased in labels plotRDA(tse, "RDA", colour.by = "ClinicalStatus", vec.text = FALSE) # Create RDA plot without repelling text plotRDA(tse, "RDA", colour.by = "ClinicalStatus", repel.labels = FALSE) # Create RDA plot without vectors plotRDA(tse, "RDA", colour.by = "ClinicalStatus", add.vectors = FALSE) # Calculate RDA as a separate object rda_mat <- getRDA( tse, assay.type = "relabundance", formula = assay ~ ClinicalStatus + Gender + Age, distance = "bray", na.action = na.exclude ) # Create RDA plot from RDA matrix plotRDA(rda_mat) })# Load dataset data("enterotype", package = "mia") tse <- enterotype # Run RDA and store results into TreeSE tse <- transformAssay(tse, method = "relabundance") tse <- addRDA( tse, assay.type = "relabundance", formula = assay ~ ClinicalStatus + Gender + Age, distance = "bray", na.action = na.exclude ) suppressWarnings({ # Create RDA plot coloured by variable plotRDA(tse, "RDA", colour.by = "ClinicalStatus") # Create RDA plot with empty ellipses plotRDA(tse, "RDA", colour.by = "ClinicalStatus", add.ellipse = "colour") # Create RDA plot with text encased in labels plotRDA(tse, "RDA", colour.by = "ClinicalStatus", vec.text = FALSE) # Create RDA plot without repelling text plotRDA(tse, "RDA", colour.by = "ClinicalStatus", repel.labels = FALSE) # Create RDA plot without vectors plotRDA(tse, "RDA", colour.by = "ClinicalStatus", add.vectors = FALSE) # Calculate RDA as a separate object rda_mat <- getRDA( tse, assay.type = "relabundance", formula = assay ~ ClinicalStatus + Gender + Age, distance = "bray", na.action = na.exclude ) # Create RDA plot from RDA matrix plotRDA(rda_mat) })
SummarizedExperiment
plotGraph plots an igraph object with additional information
matched from a SummarizedExperiment object for the nodes only.
Information on the edges have to provided manually.
plotColGraph(x, y, ...) plotRowGraph(x, y, ...) ## S4 method for signature 'ANY,SummarizedExperiment' plotColGraph( x, y, show.label = show_label, show_label = FALSE, add.legend = add_legend, add_legend = TRUE, layout = "kk", edge.type = edge_type, edge_type = c("fan", "link", "arc", "parallel"), edge.colour.by = edge_colour_by, edge_colour_by = NULL, edge.width.by = edge_width_by, edge_width_by = NULL, colour.by = colour_by, colour_by = NULL, shape.by = shape_by, shape_by = NULL, size.by = size_by, size_by = NULL, assay.type = by_exprs_values, by_exprs_values = "counts", other.fields = other_fields, other_fields = list(), ... ) ## S4 method for signature 'SummarizedExperiment,missing' plotColGraph(x, y, name = "graph", ...) ## S4 method for signature 'ANY,SummarizedExperiment' plotRowGraph( x, y, show.label = show_label, show_label = FALSE, add.legend = add_legend, add_legend = TRUE, layout = "kk", edge.type = edge_type, edge_type = c("fan", "link", "arc", "parallel"), edge.colour.by = edge_colour_by, edge_colour_by = NULL, edge.width.by = edge_width_by, edge_width_by = NULL, colour.by = colour_by, colour_by = NULL, shape.by = shape_by, shape_by = NULL, size.by = NULL, assay.type = by_exprs_values, by_exprs_values = "counts", other.fields = other_fields, other_fields = list(), ... ) ## S4 method for signature 'SummarizedExperiment,missing' plotRowGraph(x, y, name = "graph", ...)plotColGraph(x, y, ...) plotRowGraph(x, y, ...) ## S4 method for signature 'ANY,SummarizedExperiment' plotColGraph( x, y, show.label = show_label, show_label = FALSE, add.legend = add_legend, add_legend = TRUE, layout = "kk", edge.type = edge_type, edge_type = c("fan", "link", "arc", "parallel"), edge.colour.by = edge_colour_by, edge_colour_by = NULL, edge.width.by = edge_width_by, edge_width_by = NULL, colour.by = colour_by, colour_by = NULL, shape.by = shape_by, shape_by = NULL, size.by = size_by, size_by = NULL, assay.type = by_exprs_values, by_exprs_values = "counts", other.fields = other_fields, other_fields = list(), ... ) ## S4 method for signature 'SummarizedExperiment,missing' plotColGraph(x, y, name = "graph", ...) ## S4 method for signature 'ANY,SummarizedExperiment' plotRowGraph( x, y, show.label = show_label, show_label = FALSE, add.legend = add_legend, add_legend = TRUE, layout = "kk", edge.type = edge_type, edge_type = c("fan", "link", "arc", "parallel"), edge.colour.by = edge_colour_by, edge_colour_by = NULL, edge.width.by = edge_width_by, edge_width_by = NULL, colour.by = colour_by, colour_by = NULL, shape.by = shape_by, shape_by = NULL, size.by = NULL, assay.type = by_exprs_values, by_exprs_values = "counts", other.fields = other_fields, other_fields = list(), ... ) ## S4 method for signature 'SummarizedExperiment,missing' plotRowGraph(x, y, name = "graph", ...)
x, y
|
a graph object and a
|
... |
additional arguments for plotting. See
|
show.label |
|
show_label |
Deprecated. Use |
add.legend |
|
add_legend |
Deprecated. Use |
layout |
|
edge.type |
|
edge_type |
Deprecated. Use |
edge.colour.by |
|
edge_colour_by |
Deprecated. Use |
edge.width.by |
|
edge_width_by |
Deprecated. Use |
colour.by |
|
colour_by |
Deprecated. Use |
shape.by |
|
shape_by |
Deprecated. Use |
size.by |
|
size_by |
Deprecated. Use |
assay.type |
|
by_exprs_values |
Deprecated. Use |
other.fields |
Additional fields to include in the node information without plotting them. |
other_fields |
Deprecated. Use |
name |
|
Internally tidygraph and ggraph are used. Therefore, all
graph types which can be converted by tidygraph::as_tbl_graph can
be used.
a ggtree plot
# data setup library(mia) data(GlobalPatterns) data(col_graph) data(row_graph) data(row_graph_order) metadata(GlobalPatterns)$col_graph <- col_graph genus <- agglomerateByRank(GlobalPatterns,"Genus",na.rm=TRUE) metadata(genus)$row_graph <- row_graph order <- agglomerateByRank(genus,"Order",na.rm=TRUE) metadata(order)$row_graph <- row_graph_order # plot a graph independently plotColGraph(col_graph, genus, colour.by = "SampleType", edge.colour.by = "weight", edge.width.by = "weight", show.label = TRUE) # plot the graph stored in the object plotColGraph(genus, name = "col_graph", colour.by = "SampleType", edge.colour.by = "weight", edge.width.by = "weight") # plot a graph independently plotRowGraph(row_graph, genus, colour.by = "Kingdom", edge.colour.by = "weight", edge.width.by = "weight") # plot the graph stored in the object plotRowGraph(genus, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight") # plot a graph independently plotRowGraph(row_graph_order, order, colour.by = "Kingdom", edge.colour.by = "weight", edge.width.by = "weight") # plot the graph stored in the object and include some labels plotRowGraph(order, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight", show.label = c("Sulfolobales","Spirochaetales", "Verrucomicrobiales")) # labels can also be included via selecting specific rownames of x/y plotRowGraph(order, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight", show.label = c(1,10,50)) # labels can also be included via a logical vector, which has the same length # as nodes are present label_select <- rep(FALSE,nrow(order)) label_select[c(1,10,50)] <- TRUE plotRowGraph(order, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight", show.label = label_select)# data setup library(mia) data(GlobalPatterns) data(col_graph) data(row_graph) data(row_graph_order) metadata(GlobalPatterns)$col_graph <- col_graph genus <- agglomerateByRank(GlobalPatterns,"Genus",na.rm=TRUE) metadata(genus)$row_graph <- row_graph order <- agglomerateByRank(genus,"Order",na.rm=TRUE) metadata(order)$row_graph <- row_graph_order # plot a graph independently plotColGraph(col_graph, genus, colour.by = "SampleType", edge.colour.by = "weight", edge.width.by = "weight", show.label = TRUE) # plot the graph stored in the object plotColGraph(genus, name = "col_graph", colour.by = "SampleType", edge.colour.by = "weight", edge.width.by = "weight") # plot a graph independently plotRowGraph(row_graph, genus, colour.by = "Kingdom", edge.colour.by = "weight", edge.width.by = "weight") # plot the graph stored in the object plotRowGraph(genus, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight") # plot a graph independently plotRowGraph(row_graph_order, order, colour.by = "Kingdom", edge.colour.by = "weight", edge.width.by = "weight") # plot the graph stored in the object and include some labels plotRowGraph(order, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight", show.label = c("Sulfolobales","Spirochaetales", "Verrucomicrobiales")) # labels can also be included via selecting specific rownames of x/y plotRowGraph(order, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight", show.label = c(1,10,50)) # labels can also be included via a logical vector, which has the same length # as nodes are present label_select <- rep(FALSE,nrow(order)) label_select[c(1,10,50)] <- TRUE plotRowGraph(order, name = "row_graph", colour.by = "Phylum", edge.colour.by = "weight", edge.width.by = "weight", show.label = label_select)
Relative relations of two grouping can be visualized by plotting tiles with
relative sizes. plotColTile and plotRowTile can be used for
this.
plotColTile(object, x, y, ...) plotRowTile(object, x, y, ...) ## S4 method for signature 'SummarizedExperiment' plotColTile(object, x, y, ...) ## S4 method for signature 'SummarizedExperiment' plotRowTile(object, x, y, ...)plotColTile(object, x, y, ...) plotRowTile(object, x, y, ...) ## S4 method for signature 'SummarizedExperiment' plotColTile(object, x, y, ...) ## S4 method for signature 'SummarizedExperiment' plotRowTile(object, x, y, ...)
object |
a
|
x |
|
y |
|
... |
additional arguments for plotting. See
|
A ggplot2 object or plotly object, if more than one
prevalences was defined.
data(GlobalPatterns) se <- GlobalPatterns plotColTile(se,"SampleType","Primer")data(GlobalPatterns) se <- GlobalPatterns plotColTile(se,"SampleType","Primer")
To plot DMN fits generated with mia use plotDMNFit.
plotDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"), ...) ## S4 method for signature 'SummarizedExperiment' plotDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"))plotDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"), ...) ## S4 method for signature 'SummarizedExperiment' plotDMNFit(x, name = "DMN", type = c("laplace", "AIC", "BIC"))
x |
a
|
name |
|
type |
|
... |
optional arguments not used. |
plotDMNFit returns a ggplot2 plot.
library(mia) library(bluster) # Get dataset data("peerj13075", package = "mia") tse <- peerj13075 # Cluster the samples tse <- addCluster( tse, assay.type = "counts", DmmParam(k = 1:4), name = "DMM", full = TRUE ) # Plot the fit plotDMNFit(tse, name = "DMM", type = "laplace")library(mia) library(bluster) # Get dataset data("peerj13075", package = "mia") tse <- peerj13075 # Cluster the samples tse <- addCluster( tse, assay.type = "counts", DmmParam(k = 1:4), name = "DMM", full = TRUE ) # Plot the fit plotDMNFit(tse, name = "DMM", type = "laplace")
plotForest() creates a feature- or sample-wise forest plot, showing
estimated results from a statistical test with their confidence intervals.
Additionally, the plot can be enriched with the tree structure and labelled
with Confidence Intervals (CIs), p-values and other side information.
plotForest(x, ...) ## S4 method for signature 'TreeSummarizedExperiment' plotForest( x, by = 1L, effect.var = "effect", ci.lower.var = "lower", ci.upper.var = "upper", err.var = NULL, pval.var = "pval", id.var = "rownames", label.by = NULL, order.by = NULL, facet.by = NULL, color.by = colour.by, colour.by = NULL, conf.level = 0.95, tree.name = "phylo", show.tree = TRUE, ... ) ## S4 method for signature 'SummarizedExperiment' plotForest( x, by = 1L, effect.var = "effect", ci.lower.var = "lower", ci.upper.var = "upper", err.var = NULL, pval.var = "pval", id.var = "rownames", label.by = NULL, order.by = NULL, facet.by = NULL, color.by = colour.by, colour.by = NULL, conf.level = 0.95 ) ## S4 method for signature 'data.frame' plotForest( x, effect.var = "effect", ci.lower.var = "lower", ci.upper.var = "upper", err.var = NULL, pval.var = "pval", id.var = "rownames", label.by = NULL, order.by = NULL, facet.by = NULL, color.by = colour.by, colour.by = NULL, conf.level = 0.95 )plotForest(x, ...) ## S4 method for signature 'TreeSummarizedExperiment' plotForest( x, by = 1L, effect.var = "effect", ci.lower.var = "lower", ci.upper.var = "upper", err.var = NULL, pval.var = "pval", id.var = "rownames", label.by = NULL, order.by = NULL, facet.by = NULL, color.by = colour.by, colour.by = NULL, conf.level = 0.95, tree.name = "phylo", show.tree = TRUE, ... ) ## S4 method for signature 'SummarizedExperiment' plotForest( x, by = 1L, effect.var = "effect", ci.lower.var = "lower", ci.upper.var = "upper", err.var = NULL, pval.var = "pval", id.var = "rownames", label.by = NULL, order.by = NULL, facet.by = NULL, color.by = colour.by, colour.by = NULL, conf.level = 0.95 ) ## S4 method for signature 'data.frame' plotForest( x, effect.var = "effect", ci.lower.var = "lower", ci.upper.var = "upper", err.var = NULL, pval.var = "pval", id.var = "rownames", label.by = NULL, order.by = NULL, facet.by = NULL, color.by = colour.by, colour.by = NULL, conf.level = 0.95 )
x |
a
|
... |
additional parameters passed to |
by |
|
effect.var |
|
ci.lower.var |
|
ci.upper.var |
|
err.var |
|
pval.var |
|
id.var |
|
label.by |
|
order.by |
|
facet.by |
|
color.by |
|
colour.by |
|
conf.level |
|
tree.name |
|
show.tree |
|
a ggplot object.
library(mia) library(maaslin3) # Import dataset data("Tengeler2020", package = "mia") tse <- Tengeler2020 # Agglomerate by genus and subset by prevalence tse <- subsetByPrevalent(tse, rank = "Genus", prevalence = 10/100) # Transform count assay to relative abundances tse <- transformAssay(tse, assay.type = "counts", method = "relabundance") # Run maaslin3 maaslin3_out <- maaslin3( input_data = tse, output = "maaslin_results", formula = "~ patient_status", ) # Retrieve abundance results maaslin3_abund <- maaslin3_out$fit_data_abundance$results maaslin3_abund <- maaslin3_abund[!is.na(maaslin3_abund$coef), ] # Visualize abundance results plotForest( maaslin3_abund, effect.var = "coef", err.var = "stderr", pval.var = "qval_joint", id.var = "feature", label.by = c("CI", "P-Value"), order.by = "coef" ) # Add abundance results to TreeSE rowData rownames(maaslin3_abund) <- maaslin3_abund$feature tax_order <- match(rownames(tse), rownames(maaslin3_abund)) rowData(tse) <- cbind(rowData(tse), maaslin3_abund[tax_order, ]) # Visualise abundance results with tree structure plotForest( tse, effect.var = "coef", err.var = "stderr", pval.var = "qval_joint", label.by = c("CI", "P-Value") ) # Retrieve prevalence results maaslin3_prev <- maaslin3_out$fit_data_prevalence$results maaslin3_prev <- maaslin3_prev[!is.na(maaslin3_prev$coef), ] # Combine abundance and prevalence results maaslin3_res <- rbind(maaslin3_abund, maaslin3_prev) maaslin3_res$association <- c( rep("Abundance", nrow(maaslin3_abund)), rep("Prevalence", nrow(maaslin3_prev)) ) # Visualize combined results plotForest( maaslin3_res, effect.var = "coef", err.var = "stderr", pval.var = "qval_joint", id.var = "feature", label.by = c("CI", "P-Value"), order.by = "coef", facet.by = "association", colour.by = "association" )library(mia) library(maaslin3) # Import dataset data("Tengeler2020", package = "mia") tse <- Tengeler2020 # Agglomerate by genus and subset by prevalence tse <- subsetByPrevalent(tse, rank = "Genus", prevalence = 10/100) # Transform count assay to relative abundances tse <- transformAssay(tse, assay.type = "counts", method = "relabundance") # Run maaslin3 maaslin3_out <- maaslin3( input_data = tse, output = "maaslin_results", formula = "~ patient_status", ) # Retrieve abundance results maaslin3_abund <- maaslin3_out$fit_data_abundance$results maaslin3_abund <- maaslin3_abund[!is.na(maaslin3_abund$coef), ] # Visualize abundance results plotForest( maaslin3_abund, effect.var = "coef", err.var = "stderr", pval.var = "qval_joint", id.var = "feature", label.by = c("CI", "P-Value"), order.by = "coef" ) # Add abundance results to TreeSE rowData rownames(maaslin3_abund) <- maaslin3_abund$feature tax_order <- match(rownames(tse), rownames(maaslin3_abund)) rowData(tse) <- cbind(rowData(tse), maaslin3_abund[tax_order, ]) # Visualise abundance results with tree structure plotForest( tse, effect.var = "coef", err.var = "stderr", pval.var = "qval_joint", label.by = c("CI", "P-Value") ) # Retrieve prevalence results maaslin3_prev <- maaslin3_out$fit_data_prevalence$results maaslin3_prev <- maaslin3_prev[!is.na(maaslin3_prev$coef), ] # Combine abundance and prevalence results maaslin3_res <- rbind(maaslin3_abund, maaslin3_prev) maaslin3_res$association <- c( rep("Abundance", nrow(maaslin3_abund)), rep("Prevalence", nrow(maaslin3_prev)) ) # Visualize combined results plotForest( maaslin3_res, effect.var = "coef", err.var = "stderr", pval.var = "qval_joint", id.var = "feature", label.by = c("CI", "P-Value"), order.by = "coef", facet.by = "association", colour.by = "association" )
assay, rowData or colData
This methods visualizes abundances or variables from rowData or
colData.
plotHistogram(x, ...) plotBarplot(x, ...) ## S4 method for signature 'SummarizedExperiment' plotHistogram( x, assay.type = NULL, features = NULL, row.var = NULL, col.var = NULL, ... ) ## S4 method for signature 'SummarizedExperiment' plotBarplot( x, assay.type = NULL, features = NULL, row.var = NULL, col.var = NULL, ... )plotHistogram(x, ...) plotBarplot(x, ...) ## S4 method for signature 'SummarizedExperiment' plotHistogram( x, assay.type = NULL, features = NULL, row.var = NULL, col.var = NULL, ... ) ## S4 method for signature 'SummarizedExperiment' plotBarplot( x, assay.type = NULL, features = NULL, row.var = NULL, col.var = NULL, ... )
x |
a
|
... |
Additional parameters for plotting.
|
assay.type |
|
features |
|
row.var |
|
col.var |
|
Histogram and bar plot are a basic visualization techniques in quality
control. It helps to visualize the distribution of data. plotAbundance
allows researcher to visualise the abundance from assay, or variables
from rowData or colData. For visualizing categorical values,
one can utilize plotBarplot.
plotAbundanceDensity function is related
to plotHistogram. However, the former visualizes the most prevalent
features, while the latter can be used more freely to explore the
distributions.
A ggplot2 object.
data(GlobalPatterns) tse <- GlobalPatterns # Visualize the counts data. There are lots of zeroes. plotHistogram(tse, assay.type = "counts") # Apply transformation tse <- transformAssay(tse, method = "clr", pseudocount = TRUE) # And plot specified rows plotHistogram( tse, assay.type = "clr", features = rownames(tse)[1:5], facet.by = "rownames" ) # Calculate shannon diversity and visualize its distribution with density # plot. Different sample types are separated with color. tse <- addAlpha(tse, index = "shannon") plotHistogram( tse, col.var = "shannon", layout = "density", fill.by = "SampleType" ) # For categorical values, one can utilize a bar plot plotBarplot(tse, col.var = "SampleType")data(GlobalPatterns) tse <- GlobalPatterns # Visualize the counts data. There are lots of zeroes. plotHistogram(tse, assay.type = "counts") # Apply transformation tse <- transformAssay(tse, method = "clr", pseudocount = TRUE) # And plot specified rows plotHistogram( tse, assay.type = "clr", features = rownames(tse)[1:5], facet.by = "rownames" ) # Calculate shannon diversity and visualize its distribution with density # plot. Different sample types are separated with color. tse <- addAlpha(tse, index = "shannon") plotHistogram( tse, col.var = "shannon", layout = "density", fill.by = "SampleType" ) # For categorical values, one can utilize a bar plot plotBarplot(tse, col.var = "SampleType")
This function is used after performing a reduction method. If TreeSE
is given it retrieves the feature loadings matrix to plot values.
A tree from rowTree can be added to heatmap layout.
plotLoadings(x, ...) ## S4 method for signature 'TreeSummarizedExperiment' plotLoadings( x, dimred, layout = "barplot", ncomponents = 5, tree.name = "phylo", row.var = NULL, add.tree = FALSE, ... ) ## S4 method for signature 'SingleCellExperiment' plotLoadings(x, dimred, layout = "barplot", ncomponents = 5, ...) ## S4 method for signature 'matrix' plotLoadings(x, layout = "barplot", ncomponents = 5, ...)plotLoadings(x, ...) ## S4 method for signature 'TreeSummarizedExperiment' plotLoadings( x, dimred, layout = "barplot", ncomponents = 5, tree.name = "phylo", row.var = NULL, add.tree = FALSE, ... ) ## S4 method for signature 'SingleCellExperiment' plotLoadings(x, dimred, layout = "barplot", ncomponents = 5, ...) ## S4 method for signature 'matrix' plotLoadings(x, layout = "barplot", ncomponents = 5, ...)
x |
|
... |
additional parameters for plotting.
|
dimred |
|
layout |
|
ncomponents |
|
tree.name |
|
row.var |
|
add.tree |
|
These method visualize feature loadings of dimension reduction results.
Inspired by the plotASVcircular method using phyloseq.
TreeSummarizedExperiment object is expected to have
content in reducedDim slot calculated with standardized methods from
mia or scater package.
A ggplot2 object.
library(mia) library(scater) data("GlobalPatterns", package = "mia") tse <- GlobalPatterns # Calculate PCA tse <- agglomerateByPrevalence(tse, rank="Phylum", update.tree = TRUE) tse <- transformAssay(tse, method = "clr", pseudocount = 1) tse <- runPCA(tse, ncomponents = 5, assay.type = "clr") # Plotting feature loadings plotLoadings(tse, dimred = "PCA", layout = "heatmap", add.tree = FALSE) |> # Remove this line to see messages suppressMessages() # Plotting matrix as a barplot loadings_matrix <- attr(reducedDim(tse, "PCA"), "rotation") plotLoadings(loadings_matrix) # Plotting more features but less components plotLoadings(tse, dimred = "PCA", ncomponents = 2, n = 12) # Plotting matrix as heatmap without tree plotLoadings(loadings_matrix, layout = "heatmap") # Plot with less components plotLoadings(tse, "PCA", layout = "heatmap", ncomponents = 2)library(mia) library(scater) data("GlobalPatterns", package = "mia") tse <- GlobalPatterns # Calculate PCA tse <- agglomerateByPrevalence(tse, rank="Phylum", update.tree = TRUE) tse <- transformAssay(tse, method = "clr", pseudocount = 1) tse <- runPCA(tse, ncomponents = 5, assay.type = "clr") # Plotting feature loadings plotLoadings(tse, dimred = "PCA", layout = "heatmap", add.tree = FALSE) |> # Remove this line to see messages suppressMessages() # Plotting matrix as a barplot loadings_matrix <- attr(reducedDim(tse, "PCA"), "rotation") plotLoadings(loadings_matrix) # Plotting more features but less components plotLoadings(tse, dimred = "PCA", ncomponents = 2, n = 12) # Plotting matrix as heatmap without tree plotLoadings(loadings_matrix, layout = "heatmap") # Plot with less components plotLoadings(tse, "PCA", layout = "heatmap", ncomponents = 2)
plotMediation() generates a heatmap from the results of mediation
analysis produced with mia:getMediation() or
mia:addMediation(). It displays effect size and significance of the
Actual Causal Mediation Effect (ACME) and the Actual Direct Effect (ADE) for
each mediator included in the object x.
plotMediation(x, ...) ## S4 method for signature 'SummarizedExperiment' plotMediation(x, name = "mediation", ...) ## S4 method for signature 'data.frame' plotMediation(x, layout = "heatmap", ...)plotMediation(x, ...) ## S4 method for signature 'SummarizedExperiment' plotMediation(x, name = "mediation", ...) ## S4 method for signature 'data.frame' plotMediation(x, layout = "heatmap", ...)
x |
a
|
... |
Additional parameters for plotting.
|
name |
|
layout |
|
plotMediation creates a heatmap starting from the
output of the mediation functions, which are
mia wrappers for the basic mediate function.
Either a
SummarizedExperiment
or a data.frame object is supported as input. When the input is a
SummarizedExperiment, this should contain the output of addMediation
in the metadata slot and the argument name needs to be defined.
When the input is a data.frame, this should be returned as output from
getMediation.
A ggplot2 object.
## Not run: library(mia) library(scater) # Load dataset data(hitchip1006, package = "miaTime") tse <- hitchip1006 # Agglomerate features by family (merely to speed up execution) tse <- agglomerateByRank(tse, rank = "Phylum") # Convert BMI variable to numeric tse[["bmi_group"]] <- as.numeric(tse[["bmi_group"]]) # Apply clr transformation to counts assay tse <- transformAssay(tse, method = "clr", pseudocount = 1) # Analyse mediated effect of nationality on BMI via clr-transformed features # 100 permutations were done to speed up execution, but ~1000 are recommended tse <- addMediation( tse, name = "assay_mediation", outcome = "bmi_group", treatment = "nationality", assay.type = "clr", covariates = c("sex", "age"), treat.value = "Scandinavia", control.value = "CentralEurope", boot = TRUE, sims = 100, p.adj.method = "fdr" ) # Visualise results as heatmap plotMediation(tse, "assay_mediation") # Visualise results as forest plot plotMediation(tse, "assay_mediation", layout = "forest") ## End(Not run)## Not run: library(mia) library(scater) # Load dataset data(hitchip1006, package = "miaTime") tse <- hitchip1006 # Agglomerate features by family (merely to speed up execution) tse <- agglomerateByRank(tse, rank = "Phylum") # Convert BMI variable to numeric tse[["bmi_group"]] <- as.numeric(tse[["bmi_group"]]) # Apply clr transformation to counts assay tse <- transformAssay(tse, method = "clr", pseudocount = 1) # Analyse mediated effect of nationality on BMI via clr-transformed features # 100 permutations were done to speed up execution, but ~1000 are recommended tse <- addMediation( tse, name = "assay_mediation", outcome = "bmi_group", treatment = "nationality", assay.type = "clr", covariates = c("sex", "age"), treat.value = "Scandinavia", control.value = "CentralEurope", boot = TRUE, sims = 100, p.adj.method = "fdr" ) # Visualise results as heatmap plotMediation(tse, "assay_mediation") # Visualise results as forest plot plotMediation(tse, "assay_mediation", layout = "forest") ## End(Not run)
Wrapper for scater::plotReducedDim()
plotNMDS(x, ..., ncomponents = 2)plotNMDS(x, ..., ncomponents = 2)
x |
a
|
... |
additional arguments passed to scater::plotReducedDim(). |
ncomponents |
|
plotPrevalence and plotRowPrevalence visualize prevalence
information.
plotRowPrevalence(x, ...) plotPrevalentAbundance(x, ...) plotPrevalence(x, ...) ## S4 method for signature 'SummarizedExperiment' plotPrevalence( x, detection = detections, detections = c(0.01, 0.1, 1, 2, 5, 10, 20), prevalence = prevalences, prevalences = seq(0.1, 1, 0.1), assay.type = assay_name, assay_name = "counts", rank = NULL, BPPARAM = BiocParallel::SerialParam(), ... ) ## S4 method for signature 'SummarizedExperiment' plotPrevalentAbundance( x, rank = NULL, assay.type = assay_name, assay_name = "counts", colour.by = colour_by, colour_by = NULL, size.by = size_by, size_by = NULL, shape.by = shape_by, shape_by = NULL, show.label = label, label = NULL, facet.by = facet_by, facet_by = NULL, ... ) ## S4 method for signature 'SummarizedExperiment' plotRowPrevalence( x, rank = NULL, assay.type = assay_name, assay_name = "counts", detection = detections, detections = c(0.01, 0.1, 1, 2, 5, 10, 20), min.prevalence = min_prevalence, min_prevalence = 0, BPPARAM = BiocParallel::SerialParam(), ... )plotRowPrevalence(x, ...) plotPrevalentAbundance(x, ...) plotPrevalence(x, ...) ## S4 method for signature 'SummarizedExperiment' plotPrevalence( x, detection = detections, detections = c(0.01, 0.1, 1, 2, 5, 10, 20), prevalence = prevalences, prevalences = seq(0.1, 1, 0.1), assay.type = assay_name, assay_name = "counts", rank = NULL, BPPARAM = BiocParallel::SerialParam(), ... ) ## S4 method for signature 'SummarizedExperiment' plotPrevalentAbundance( x, rank = NULL, assay.type = assay_name, assay_name = "counts", colour.by = colour_by, colour_by = NULL, size.by = size_by, size_by = NULL, shape.by = shape_by, shape_by = NULL, show.label = label, label = NULL, facet.by = facet_by, facet_by = NULL, ... ) ## S4 method for signature 'SummarizedExperiment' plotRowPrevalence( x, rank = NULL, assay.type = assay_name, assay_name = "counts", detection = detections, detections = c(0.01, 0.1, 1, 2, 5, 10, 20), min.prevalence = min_prevalence, min_prevalence = 0, BPPARAM = BiocParallel::SerialParam(), ... )
x |
a
|
detection |
|
detections |
Deprecated. Use |
prevalence |
|
prevalences |
Deprecated. Use |
assay.type |
|
assay_name |
Deprecated. Use |
rank, ...
|
additional arguments
|
BPPARAM |
A
|
colour.by |
|
colour_by |
Deprecated. Use |
size.by |
|
size_by |
Deprecated. Use |
shape.by |
|
shape_by |
Deprecated. Use |
show.label |
|
label |
Deprecated. Use |
facet.by |
|
facet_by |
Deprecated. Use |
min.prevalence |
|
min_prevalence |
Deprecated. Use |
Whereas plotPrevalence produces a line plot, plotRowPrevalence
returns a heatmap.
Agglomeration on different taxonomic levels is available through the
rank argument.
To exclude certain taxa, preprocess x to your liking, for example
with subsetting via getPrevalent or
agglomerateByPrevalence.
A ggplot2 object or plotly object, if more than one
prevalence was defined.
getPrevalence,
agglomerateByPrevalence,
agglomerateByRank
data(GlobalPatterns, package = "mia") # Apply relative transformation GlobalPatterns <- transformAssay(GlobalPatterns, method = "relabundance") # plotting N of prevalence exceeding taxa on the Phylum level plotPrevalence(GlobalPatterns, rank = "Phylum") plotPrevalence(GlobalPatterns, rank = "Phylum") + scale_x_log10() # plotting prevalence per taxa for different detection thresholds as heatmap plotRowPrevalence(GlobalPatterns, rank = "Phylum") # by default a continuous scale is used for different detection levels, # but this can be adjusted plotRowPrevalence( GlobalPatterns, rank = "Phylum", assay.type = "relabundance", detection = c(0, 0.001, 0.01, 0.1, 0.2)) # point layout for plotRowPrevalence can be used to visualize by additional # information plotPrevalentAbundance( GlobalPatterns, rank = "Family", colour.by = "Phylum") + scale_x_log10() # When using function plotPrevalentAbundace, it is possible to create facets # with 'facet.by'. plotPrevalentAbundance( GlobalPatterns, rank = "Family", colour.by = "Phylum", facet.by = "Kingdom") + scale_x_log10()data(GlobalPatterns, package = "mia") # Apply relative transformation GlobalPatterns <- transformAssay(GlobalPatterns, method = "relabundance") # plotting N of prevalence exceeding taxa on the Phylum level plotPrevalence(GlobalPatterns, rank = "Phylum") plotPrevalence(GlobalPatterns, rank = "Phylum") + scale_x_log10() # plotting prevalence per taxa for different detection thresholds as heatmap plotRowPrevalence(GlobalPatterns, rank = "Phylum") # by default a continuous scale is used for different detection levels, # but this can be adjusted plotRowPrevalence( GlobalPatterns, rank = "Phylum", assay.type = "relabundance", detection = c(0, 0.001, 0.01, 0.1, 0.2)) # point layout for plotRowPrevalence can be used to visualize by additional # information plotPrevalentAbundance( GlobalPatterns, rank = "Family", colour.by = "Phylum") + scale_x_log10() # When using function plotPrevalentAbundace, it is possible to create facets # with 'facet.by'. plotPrevalentAbundance( GlobalPatterns, rank = "Family", colour.by = "Phylum", facet.by = "Kingdom") + scale_x_log10()
Based on the stored data in a TreeSummarizedExperiment a tree can
be plotted. From the rowData, the assays as well as the
colData information can be taken for enriching the tree plots with
additional information.
plotRowTree(x, ...) plotColTree(x, ...) ## S4 method for signature 'TreeSummarizedExperiment' plotColTree(x, tree.name = "phylo", ...) ## S4 method for signature 'TreeSummarizedExperiment' plotRowTree(x, tree.name = "phylo", ...)plotRowTree(x, ...) plotColTree(x, ...) ## S4 method for signature 'TreeSummarizedExperiment' plotColTree(x, tree.name = "phylo", ...) ## S4 method for signature 'TreeSummarizedExperiment' plotRowTree(x, tree.name = "phylo", ...)
x |
|
... |
additional arguments for plotting.
|
tree.name |
|
If show.label or show.highlight.label have the same length
as the number of nodes, the vector will be used to relabel the nodes.
a ggtree plot
library(scater) library(mia) # preparation of some data data(GlobalPatterns) GlobalPatterns <- agglomerateByRanks(GlobalPatterns) altExp(GlobalPatterns,"Genus") <- addPerFeatureQC( altExp(GlobalPatterns,"Genus")) rowData(altExp(GlobalPatterns,"Genus"))$log_mean <- log( rowData(altExp(GlobalPatterns,"Genus"))$mean) rowData(altExp(GlobalPatterns,"Genus"))$detected <- rowData( altExp(GlobalPatterns,"Genus"))$detected / 100 top_genus <- getTop( altExp(GlobalPatterns,"Genus"), method = "mean", top = 100L, assay.type = "counts" ) # x <- altExp(GlobalPatterns,"Genus") plotRowTree( x[rownames(x) %in% top_genus,], tip.colour.by = "log_mean", tip.size.by = "detected" ) # plot with tip labels plotRowTree( x[rownames(x) %in% top_genus,], tip.colour.by = "log_mean", tip.size.by = "detected", show.label = TRUE ) # plot with selected labels labels <- c("Genus:Providencia", "Genus:Morganella", "0.961.60") plotRowTree( x[rownames(x) %in% top_genus,], tip.colour.by = "log_mean", tip.size.by = "detected", show.label = labels, layout = "rectangular" ) # plot with labeled edges plotRowTree( x[rownames(x) %in% top_genus,], edge.colour.by = "Phylum", tip.colour.by = "log_mean" ) # if edges are sized, colours might disappear depending on plotting device plotRowTree( x[rownames(x) %in% top_genus,], node.colour.by = "Phylum", edge.size.by = "detected", edge.colour.by = "log_mean" ) # aggregating data over the taxonomic levels for plotting a taxonomic tree # please note that the original tree of GlobalPatterns is dropped by # unsplitByRanks altExps(GlobalPatterns) <- splitByRanks(GlobalPatterns) top_phyla <- getTop( altExp(GlobalPatterns,"Phylum"), method = "mean", top = 10L, assay.type="counts" ) altExps(GlobalPatterns) <- lapply(altExps(GlobalPatterns), addPerFeatureQC) altExps(GlobalPatterns) <- lapply( altExps(GlobalPatterns), function(y){ rowData(y)$log_mean <- log(rowData(y)$mean) rowData(y)$detected <- rowData(y)$detected / 100 return(y) }) x <- unsplitByRanks(GlobalPatterns) x <- addHierarchyTree(x) highlights <- c( "Phylum:Firmicutes","Phylum:Bacteroidetes", "Family:Pseudomonadaceae","Order:Bifidobacteriales") plotRowTree( x[rowData(x)$Phylum %in% top_phyla,], tip.colour.by = "log_mean", node.colour.by = "log_mean", show.highlights = highlights, show.highlight.label = highlights, colour.highlights.by = "Phylum" ) # If you do not want to show internal nodes plotRowTree( x[rowData(x)$Phylum %in% top_phyla,], edge.colour.by = "Phylum", edge.size.by = "detected", node.colour.by = "log_mean", show.nodes = FALSE )library(scater) library(mia) # preparation of some data data(GlobalPatterns) GlobalPatterns <- agglomerateByRanks(GlobalPatterns) altExp(GlobalPatterns,"Genus") <- addPerFeatureQC( altExp(GlobalPatterns,"Genus")) rowData(altExp(GlobalPatterns,"Genus"))$log_mean <- log( rowData(altExp(GlobalPatterns,"Genus"))$mean) rowData(altExp(GlobalPatterns,"Genus"))$detected <- rowData( altExp(GlobalPatterns,"Genus"))$detected / 100 top_genus <- getTop( altExp(GlobalPatterns,"Genus"), method = "mean", top = 100L, assay.type = "counts" ) # x <- altExp(GlobalPatterns,"Genus") plotRowTree( x[rownames(x) %in% top_genus,], tip.colour.by = "log_mean", tip.size.by = "detected" ) # plot with tip labels plotRowTree( x[rownames(x) %in% top_genus,], tip.colour.by = "log_mean", tip.size.by = "detected", show.label = TRUE ) # plot with selected labels labels <- c("Genus:Providencia", "Genus:Morganella", "0.961.60") plotRowTree( x[rownames(x) %in% top_genus,], tip.colour.by = "log_mean", tip.size.by = "detected", show.label = labels, layout = "rectangular" ) # plot with labeled edges plotRowTree( x[rownames(x) %in% top_genus,], edge.colour.by = "Phylum", tip.colour.by = "log_mean" ) # if edges are sized, colours might disappear depending on plotting device plotRowTree( x[rownames(x) %in% top_genus,], node.colour.by = "Phylum", edge.size.by = "detected", edge.colour.by = "log_mean" ) # aggregating data over the taxonomic levels for plotting a taxonomic tree # please note that the original tree of GlobalPatterns is dropped by # unsplitByRanks altExps(GlobalPatterns) <- splitByRanks(GlobalPatterns) top_phyla <- getTop( altExp(GlobalPatterns,"Phylum"), method = "mean", top = 10L, assay.type="counts" ) altExps(GlobalPatterns) <- lapply(altExps(GlobalPatterns), addPerFeatureQC) altExps(GlobalPatterns) <- lapply( altExps(GlobalPatterns), function(y){ rowData(y)$log_mean <- log(rowData(y)$mean) rowData(y)$detected <- rowData(y)$detected / 100 return(y) }) x <- unsplitByRanks(GlobalPatterns) x <- addHierarchyTree(x) highlights <- c( "Phylum:Firmicutes","Phylum:Bacteroidetes", "Family:Pseudomonadaceae","Order:Bifidobacteriales") plotRowTree( x[rowData(x)$Phylum %in% top_phyla,], tip.colour.by = "log_mean", node.colour.by = "log_mean", show.highlights = highlights, show.highlight.label = highlights, colour.highlights.by = "Phylum" ) # If you do not want to show internal nodes plotRowTree( x[rowData(x)$Phylum %in% top_phyla,], edge.colour.by = "Phylum", edge.size.by = "detected", node.colour.by = "log_mean", show.nodes = FALSE )
plotScree generates a scree plot to visualize the eigenvalues.
The eigenvalues can be provided either as a part of a
TreeSummarizedExperiment object or as a separate vector.
This plot illustrates the decline in eigenvalues across components,
helping to assess the importance of each component.
plotScree(x, ...) ## S4 method for signature 'SingleCellExperiment' plotScree(x, dimred, ...) ## S4 method for signature 'ANY' plotScree(x, ...)plotScree(x, ...) ## S4 method for signature 'SingleCellExperiment' plotScree(x, dimred, ...) ## S4 method for signature 'ANY' plotScree(x, ...)
x |
a
|
... |
additional parameters for plotting
|
dimred |
|
plotScree generates a scree plot to visualize the relative importance
of components in dimensionality reduction techniques such as Principal
Component Analysis (PCA) or Principal Coordinate Analysis (PCoA). If the
input is a TreeSummarizedExperiment object, the function extracts
eigenvalues from the specified reduced dimension slot, which requires that
dimensionality reduction has been performed beforehand using a dedicated
function. Alternatively, if the input is a vector or an
eigenvals object, these values are directly used as eigenvalues for
the plot.
The plot can include a combination of barplot, points, connecting lines,
and labels, which can be controlled using the show.* parameters.
An option to show cumulative explained variance is also available by setting
add.cumulative = TRUE.
A ggplot2 object
library(miaViz) library(scater) data("enterotype", package = "mia") tse <- enterotype # Run PCA and store results into TreeSE tse <- transformAssay(tse, method = "clr", pseudocount = TRUE) tse <- runPCA(tse, assay.type = "clr") # Plot scree plot plotScree(tse, "PCA", add.cumulative = TRUE)library(miaViz) library(scater) data("enterotype", package = "mia") tse <- enterotype # Run PCA and store results into TreeSE tse <- transformAssay(tse, method = "clr", pseudocount = TRUE) tse <- runPCA(tse, assay.type = "clr") # Plot scree plot plotScree(tse, "PCA", add.cumulative = TRUE)
This function plots time series data.
plotSeries(x, ...) ## S4 method for signature 'SummarizedExperiment' plotSeries( x, time.col, assay.type = NULL, col.var = NULL, features = NULL, facet.by = NULL, ... )plotSeries(x, ...) ## S4 method for signature 'SummarizedExperiment' plotSeries( x, time.col, assay.type = NULL, col.var = NULL, features = NULL, facet.by = NULL, ... )
x |
a
|
... |
additional parameters for plotting.
See |
time.col |
|
assay.type |
|
col.var |
|
features |
|
facet.by |
|
This function creates series plot, where x-axis includes e.g. time points, and y-axis abundances of selected taxa. If there are multiple observations for single system and time point, mean and standard deviation is plotted.
A ggplot2 object
## Not run: library(mia) # Load data from miaTime package library("miaTime") data(SilvermanAGutData) tse <- SilvermanAGutData # Plots 2 most abundant taxa, which are colored by their family plotSeries( tse, assay.type = "counts", time.col = "DAY_ORDER", features = getTop(tse, 2), colour.by = "Family" ) # Counts relative abundances tse <- transformAssay(tse, method = "relabundance") # Selects taxa taxa <- c("seq_1", "seq_2", "seq_3", "seq_4", "seq_5") # Plots relative abundances of phylums plotSeries( tse[taxa,], time.col = "DAY_ORDER", colour.by = "Family", linetype.by = "Phylum", assay.type = "relabundance" ) # In addition to 'colour.by' and 'linetype.by', 'size.by' can also be used # to group taxa. plotSeries( tse, time.col = "DAY_ORDER", features = getTop(tse, 5), colour.by = "Family", size.by = "Phylum", assay.type = "counts" ) # If the data includes multiple systems, e.g., patients or bioreactors, # one can plot each system separately plotSeries( tse, time.col = "DAY_ORDER", assay.type = "relabundance", features = getTop(tse, 5), facet.by = "Vessel", colour.by = "rownames", colour.lab = "Feature", linetype.by = "Pre_Post_Challenge", scales = "free" ) # One can visualize colData variables by specifying col.var # First calculate alpha diversity index to visualize. tse <- addAlpha(tse, index = "shannon") # Then create a plot plotSeries( tse, col.var = "shannon", time.col = "DAY_ORDER", facet.by = "Vessel", ) ## End(Not run)## Not run: library(mia) # Load data from miaTime package library("miaTime") data(SilvermanAGutData) tse <- SilvermanAGutData # Plots 2 most abundant taxa, which are colored by their family plotSeries( tse, assay.type = "counts", time.col = "DAY_ORDER", features = getTop(tse, 2), colour.by = "Family" ) # Counts relative abundances tse <- transformAssay(tse, method = "relabundance") # Selects taxa taxa <- c("seq_1", "seq_2", "seq_3", "seq_4", "seq_5") # Plots relative abundances of phylums plotSeries( tse[taxa,], time.col = "DAY_ORDER", colour.by = "Family", linetype.by = "Phylum", assay.type = "relabundance" ) # In addition to 'colour.by' and 'linetype.by', 'size.by' can also be used # to group taxa. plotSeries( tse, time.col = "DAY_ORDER", features = getTop(tse, 5), colour.by = "Family", size.by = "Phylum", assay.type = "counts" ) # If the data includes multiple systems, e.g., patients or bioreactors, # one can plot each system separately plotSeries( tse, time.col = "DAY_ORDER", assay.type = "relabundance", features = getTop(tse, 5), facet.by = "Vessel", colour.by = "rownames", colour.lab = "Feature", linetype.by = "Pre_Post_Challenge", scales = "free" ) # One can visualize colData variables by specifying col.var # First calculate alpha diversity index to visualize. tse <- addAlpha(tse, index = "shannon") # Then create a plot plotSeries( tse, col.var = "shannon", time.col = "DAY_ORDER", facet.by = "Vessel", ) ## End(Not run)
TreeSummarizedExperiment
To facilitate the dressing of the tree data stored in a
TreeSummarizedExperiment object, rowTreeData and
colTreeData can be used.
rowTreeData(x, ...) colTreeData(x, ...) rowTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value colTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value combineTreeData(x, other.fields = other_fields, other_fields = list()) combineTreeData(x, other.fields = other_fields, other_fields = list()) ## S4 method for signature 'TreeSummarizedExperiment' colTreeData(x, tree.name = tree_name, tree_name = "phylo") ## S4 method for signature 'TreeSummarizedExperiment' rowTreeData(x, tree.name = tree_name, tree_name = "phylo") ## S4 replacement method for signature 'TreeSummarizedExperiment' colTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value ## S4 replacement method for signature 'TreeSummarizedExperiment' rowTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value ## S4 method for signature 'phylo' combineTreeData(x, other.fields = other_fields, other_fields = list()) ## S4 method for signature 'treedata' combineTreeData(x, other.fields = other_fields, other_fields = list())rowTreeData(x, ...) colTreeData(x, ...) rowTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value colTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value combineTreeData(x, other.fields = other_fields, other_fields = list()) combineTreeData(x, other.fields = other_fields, other_fields = list()) ## S4 method for signature 'TreeSummarizedExperiment' colTreeData(x, tree.name = tree_name, tree_name = "phylo") ## S4 method for signature 'TreeSummarizedExperiment' rowTreeData(x, tree.name = tree_name, tree_name = "phylo") ## S4 replacement method for signature 'TreeSummarizedExperiment' colTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value ## S4 replacement method for signature 'TreeSummarizedExperiment' rowTreeData(x, tree.name = tree_name, tree_name = "phylo") <- value ## S4 method for signature 'phylo' combineTreeData(x, other.fields = other_fields, other_fields = list()) ## S4 method for signature 'treedata' combineTreeData(x, other.fields = other_fields, other_fields = list())
x |
a
|
... |
additional arguments, currently not used. |
tree.name |
|
tree_name |
Deprecated. Use |
other.fields, value
|
a |
other_fields |
Deprecated. Use |
To match information to nodes, the id information in other.fields are
used. These can either be a column, named ‘node’ or ‘label’
(‘node’ taking precedent), or rownames. If all rownames can be coerced
to integer, they are considered as ‘node’ values, otherwise as
‘label’ values. The id information must be unique and match available
values of rowTreeData(c)
The result of the accessors, rowTreeData and colTreeData,
contain at least a ‘node’ and ‘label’ column.
a data.frame for the accessor and the modified
TreeSummarizedExperiment
object
data(GlobalPatterns) td <- rowTreeData(GlobalPatterns) td td$test <- rnorm(nrow(td)) rowTreeData(GlobalPatterns) <- td rowTreeData(GlobalPatterns) combineTreeData(rowTree(GlobalPatterns), td)data(GlobalPatterns) td <- rowTreeData(GlobalPatterns) td td$test <- rnorm(nrow(td)) rowTreeData(GlobalPatterns) <- td rowTreeData(GlobalPatterns) combineTreeData(rowTree(GlobalPatterns), td)