Generally, we expect similar count spreads for all genes between samples unless the library sizes or total RNA expression are different.

# S4 method for SummarizedExperiment
plotCountsPerGene(object, assay = 1L,
  interestingGroups = NULL, geom = c("boxplot", "density", "violin"),
  trans = c("identity", "log2", "log10"),
  color = getOption("basejump.color.discrete", NULL),
  fill = getOption("basejump.fill.discrete", NULL),
  flip = getOption("basejump.flip", TRUE), countsAxisLabel = "counts",
  title = "counts per gene")

# S4 method for SingleCellExperiment
plotCountsPerGene(object, assay = 1L,
  interestingGroups = NULL, geom = c("boxplot", "density", "violin"),
  trans = c("identity", "log2", "log10"),
  color = getOption("basejump.color.discrete", NULL),
  fill = getOption("basejump.fill.discrete", NULL),
  flip = getOption("basejump.flip", TRUE), countsAxisLabel = "counts",
  title = "counts per gene")

Arguments

object

Object.

assay

vector(1). Name or index of count matrix slotted in assays(). When passing in a string, the name must be defined in assayNames().

interestingGroups

character. Groups of interest that define the samples. If left unset, defaults to sampleName.

geom

character(1). Type of ggplot2 geometric object to use.

trans

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

For more information:

help(topic = "scale_x_continuous", package = "ggplot2")
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(basejump.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(basejump.fill.discrete = ggplot2::scale_fill_viridis_d())
flip

logical(1). Flip x and y axes. Recommended for plots containing many samples.

countsAxisLabel

character(1). Counts axis label.

title

character(1). Plot title.

Value

ggplot.

Examples

data(rse, sce) ## SummarizedExperiment ==== plotCountsPerGene(rse, geom = "boxplot")
#> 499 non-zero genes detected.
plotCountsPerGene(rse, geom = "density")
#> 499 non-zero genes detected.
## SingleCellExperiment ==== plotCountsPerGene(sce)
#> Aggregating counts using sum().
#> 477 non-zero genes detected.