Quality control metrics

# S4 method for SummarizedExperiment
metrics(object, return = c("tibble",
  "DataFrame"))

# S4 method for SingleCellExperiment
metrics(object, return = c("tibble",
  "DataFrame"))

# S4 method for SingleCellExperiment
metricsPerSample(object, fun = c("mean",
  "median", "sum"))

Arguments

object

Object.

return

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

fun

character(1). Mathematical function name to apply. Uses match.arg() internally.

Value

  • "tibble": grouped_df. Grouped by sampleID column.

  • "DataFrame": DataFrame. Row names are identical to the column names of the object, like colData().

Details

metrics() takes data stored in colData() and consistently returns a tibble grouped by sample by default (sampleID). It always returns sampleName and interestingGroups columns, even when these columns are not defined in colData. This is designed to integrate with plotting functions that use ggplot2 internally.

Methods (by class)

  • SummarizedExperiment: Metrics are sample level. sampleID column corresponds to colnames.

  • SingleCellExperiment: Metrics are cell level. cellID column corresponds to colnames. Tibble is returned grouped by sample (sampleID column).

Examples

data(rse, sce) ## SummarizedExperiment ==== x <- metrics(rse) print(x)
#> # A tibble: 12 x 4 #> # Groups: sampleID [12] #> sampleID condition sampleName interestingGroups #> <chr> <fct> <fct> <fct> #> 1 sample01 A sample01 A #> 2 sample02 A sample02 A #> 3 sample03 A sample03 A #> 4 sample04 A sample04 A #> 5 sample05 A sample05 A #> 6 sample06 A sample06 A #> 7 sample07 B sample07 B #> 8 sample08 B sample08 B #> 9 sample09 B sample09 B #> 10 sample10 B sample10 B #> 11 sample11 B sample11 B #> 12 sample12 B sample12 B
## SingleCellExperiment ==== x <- metrics(sce) print(x)
#> # A tibble: 100 x 5 #> # Groups: sampleID [2] #> cellID expLibSize sampleID sampleName interestingGroups #> <chr> <dbl> <fct> <fct> <fct> #> 1 cell001 68327. sample1 sample1 sample1 #> 2 cell002 72783. sample1 sample1 sample1 #> 3 cell003 58920. sample1 sample1 sample1 #> 4 cell004 55373. sample2 sample2 sample2 #> 5 cell005 42294. sample2 sample2 sample2 #> 6 cell006 72045. sample1 sample1 sample1 #> 7 cell007 53577. sample2 sample2 sample2 #> 8 cell008 53608. sample2 sample2 sample2 #> 9 cell009 50082. sample1 sample1 sample1 #> 10 cell010 77327. sample2 sample2 sample2 #> # … with 90 more rows
x <- metricsPerSample(sce, fun = "mean")
#> Calculating mean per sample.
#> # A tibble: 2 x 4 #> # Groups: sampleID [2] #> sampleID expLibSize sampleName interestingGroups #> <fct> <dbl> <fct> <fct> #> 1 sample1 60666. sample1 sample1 #> 2 sample2 58694. sample2 sample2