Plot counts

plotCounts(object, ...)

# S4 method for SummarizedExperiment
plotCounts(
  object,
  genes,
  assay = 1L,
  interestingGroups = NULL,
  convertGenesToSymbols = TRUE,
  geom = c("point", "violin", "boxplot", "bar"),
  trans = c("identity", "log2", "log10"),
  line = c("none", "median", "mean", "geometricMean"),
  color = getOption(x = "acid.color.discrete", default = getOption(x =
    "ggplot2.discrete.colour", default = AcidPlots::scale_color_synesthesia_d())),
  fill = getOption(x = "acid.fill.discrete", default = getOption(x =
    "ggplot2.discrete.fill", default = AcidPlots::scale_fill_synesthesia_d())),
  legend = getOption(x = "acid.legend", default = TRUE),
  style = c("facet", "wide"),
  sort = FALSE,
  labels = list(title = NULL, subtitle = NULL, sampleAxis = NULL, countAxis = "counts")
)

Arguments

object

Object.

genes

character or missing. Gene identifiers. The function will automatically match identifiers corresponding to the rownames of the object, or gene symbols defined in the object.

assay

vector(1). Assay name or index position.

interestingGroups

character. Groups of interest to use for visualization. Corresponds to factors describing the columns of the object.

convertGenesToSymbols

logical(1). Attempt to automatically convert gene identifiers to gene symbols. Only applies when object contains mappings defined in rowRanges.

geom

character(1). Plot type. Uses match.arg() internally and defaults to the first argument in the character vector.

trans

character(1). Name of the axis scale transformation to apply.

For more information:

help(topic = "scale_x_continuous", package = "ggplot2")
line

character(1). Include average (median, mean, or geometric mean) line for each interesting group. Disabled by default and if samples are colored by sample name.

color

ScaleDiscrete. Desired ggplot2 color scale. Must supply discrete values. When set NULL, the default ggplot2 color palette will be used. If manual color definitions are desired, we recommend using ggplot2::scale_color_manual().

To set the discrete color palette globally, use:

options(acid.color.discrete = ggplot2::scale_color_viridis_d())
fill

ggproto/ScaleDiscrete. Desired ggplot2 fill scale. Must supply discrete values. When set to NULL, the default ggplot2 color palette will be used. If manual color definitions are desired, we recommend using ggplot2::scale_fill_manual().

To set the discrete fill palette globally, use:

options(acid.fill.discrete = ggplot2::scale_fill_viridis_d())
legend

logical(1). Include plot legend.

style

character(1). Plot style.

sort

logical(1). Sort the genes alphabetically. This setting applies to the gene symbols rather than the gene identifiers when convertGenesToSymbols is TRUE.

labels

list. ggplot2 labels. See ggplot2::labs() for details.

...

Additional arguments.

Value

  • style = "facet": ggplot grouped by sampleName, with ggplot2::facet_wrap() applied to panel the samples.

  • style = "wide": ggplot in wide format, with genes on the x-axis.

Note

Updated 2020-09-02.

See also

Examples

data(RangedSummarizedExperiment, package = "AcidTest") ## SummarizedExperiment ==== object <- RangedSummarizedExperiment rownames <- head(rownames(object)) print(rownames)
#> [1] "gene001" "gene002" "gene003" "gene004" "gene005" "gene006"
g2s <- basejump::Gene2Symbol(object) geneIDs <- head(g2s[["geneID"]]) print(geneIDs)
#> [1] "ENSG00000000003" "ENSG00000000005" "ENSG00000000419" "ENSG00000000457" #> [5] "ENSG00000000460" "ENSG00000000938"
geneNames <- head(g2s[["geneName"]]) print(geneNames)
#> [1] "TSPAN6" "TNMD" "DPM1" "SCYL3" "C1orf112" "FGR"
## Rownames, gene IDs, and gene names (symbols) are supported. plotCounts(object, genes = geneIDs, style = "facet")
plotCounts(object, genes = geneNames, style = "wide")