This function plots time series data.

plotSeries(x, ...)

# S4 method for class 'SummarizedExperiment'
plotSeries(
  x,
  time.col,
  assay.type = NULL,
  col.var = NULL,
  features = NULL,
  facet.by = NULL,
  ...
)

Arguments

x

a SummarizedExperiment object.

...

additional parameters for plotting.

  • rank Character scalar. A taxonomic rank, that is used to agglomerate the data. (Default: NULL)

  • colour.by Character scalar. A column name from rowData(x) or colData(x), that is used to divide observations to different colors. If NULL, this is not applied. (Default: NULL)

  • linetype.by Character scalar. A column name from rowData(x) or colData(x), that is used to divide observations to different line types. If NULL, this is not applied. (Default: NULL)

  • size.by: Character scalar. A column name from rowData(x) or colData(x), that is used to divide observations to different size types. If NULL, this is not applied. (Default: NULL)

  • ncol: Numeric scalar. if facets are applied, ncol defines many columns should be for plotting the different facets. (Default: 1L)

  • scales Character scalar. Defines the behavior of the scales of each facet. The value is passed into facet_wrap. (Default: "fixed")

See mia-plot-args for more details i.e. call help("mia-plot-args")

time.col

Character scalar. Selecting the column from colData that will specify values of x-axis.

assay.type

Character scalar. Specifies the assay to be plotted.

col.var

Character scalar. Selecting the column from colData that will be plotted. This can be used instead of assay.type for visualizing temporal changes in sample metadata variable.

features

Character scalar. Selects the taxa from rownames. This parameter specifies taxa whose abundances will be plotted.

facet.by

Character scalar. Specifies a sample grouping. Must be value from rowData or colData. If NULL, grouping is not applied. (Default: NULL)

Value

A ggplot2 object

Details

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.

Examples

if (FALSE) { # \dontrun{
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",
)

} # }