Quality control metrics

metrics(object, ...)

metricsPerSample(object, ...)

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

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

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

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.

...

Additional arguments.

Value

Object of class determined by return argument.

Details

metrics() takes data stored in colData() and consistently returns a tbl_df or DataFrame with 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.

Functions

  • metrics,SummarizedExperiment-method: Sample-level metrics.

  • metrics,SingleCellExperiment-method: Cell-level metrics.

  • metricsPerSample,SingleCellExperiment-method: Sample-level metrics.

Note

These functions will error intentionally if no numeric columns are defined in colData().

Updated 2020-01-20.

Examples

data( RangedSummarizedExperiment, SingleCellExperiment, package = "acidtest" ) ## SummarizedExperiment ==== object <- RangedSummarizedExperiment object <- calculateMetrics(object)
#> → Calculating 12 sample metrics.
#> 496 coding features detected.
#> 0 mitochondrial features detected.
x <- metrics(object) print(x)
#> # A tibble: 12 x 10 #> sampleID condition nCount nFeature nCoding nMito log10FeaturesPe… mitoRatio #> <chr> <fct> <int> <int> <int> <int> <dbl> <dbl> #> 1 sample01 A 20880 443 20721 NA 0.613 NA #> 2 sample02 A 22628 454 22484 NA 0.610 NA #> 3 sample03 A 21473 439 21242 NA 0.610 NA #> 4 sample04 A 21704 456 21504 NA 0.613 NA #> 5 sample05 A 22963 453 22858 NA 0.609 NA #> 6 sample06 A 22679 456 22516 NA 0.610 NA #> 7 sample07 B 27369 443 27211 NA 0.596 NA #> 8 sample08 B 28830 441 28614 NA 0.593 NA #> 9 sample09 B 28040 436 27877 NA 0.593 NA #> 10 sample10 B 28829 447 28626 NA 0.594 NA #> 11 sample11 B 28508 448 28340 NA 0.595 NA #> 12 sample12 B 29765 447 29523 NA 0.592 NA #> # … with 2 more variables: sampleName <fct>, interestingGroups <fct>
## SingleCellExperiment ==== object <- SingleCellExperiment object <- calculateMetrics(object)
#> → Calculating 100 sample metrics.
#> 496 coding features detected.
#> 0 mitochondrial features detected.
x <- metrics(object) print(x)
#> # A tibble: 100 x 10 #> cellID sampleID nCount nFeature nCoding nMito log10FeaturesPe… mitoRatio #> <chr> <fct> <int> <int> <int> <int> <dbl> <dbl> #> 1 cell0… sample1 46839 245 46748 NA 0.512 NA #> 2 cell0… sample2 71187 274 71090 NA 0.502 NA #> 3 cell0… sample1 74599 270 74472 NA 0.499 NA #> 4 cell0… sample1 60845 265 60765 NA 0.507 NA #> 5 cell0… sample1 62201 245 62098 NA 0.498 NA #> 6 cell0… sample2 48714 259 48620 NA 0.515 NA #> 7 cell0… sample2 43630 228 43570 NA 0.508 NA #> 8 cell0… sample1 49508 255 49410 NA 0.513 NA #> 9 cell0… sample1 55399 250 55318 NA 0.506 NA #> 10 cell0… sample2 65374 287 65245 NA 0.510 NA #> # … with 90 more rows, and 2 more variables: sampleName <fct>, #> # interestingGroups <fct>
x <- metricsPerSample(object, fun = "mean")
#> → Calculating mean per sample.
#> # A tibble: 2 x 9 #> sampleID sampleName interestingGrou… nCount nFeature nCoding nMito #> <chr> <fct> <fct> <dbl> <dbl> <dbl> <dbl> #> 1 sample1 sample1 sample1 60587. 261. 60495. NA #> 2 sample2 sample2 sample2 54304. 260. 54213 NA #> # … with 2 more variables: log10FeaturesPerCount <dbl>, mitoRatio <dbl>