These functions calculate simple quality control metrics, such as library sizes, for samples or features.

addQC(x, ...)

getQC(x, ...)

# S4 method for class 'SummarizedExperiment'
addQC(x, by = "cols", ...)

# S4 method for class 'SummarizedExperiment'
getQC(x, assay.type = "counts", by = "cols", ...)

Arguments

x

a SummarizedExperiment object.

...

additional arguments passed to getQC:

  • name: Specifies the names of the metrics in the result. Must have the same length as the number of metrics. (Default: c("total", "detected", "mean", "sd", "cv", "q0", "q25", "q50", "q100"))

  • na.rm: Logical scalar. Should NA values be omitted? (Default: TRUE)

by

Character scalar. Determines if metrics are calculated for samples ("cols") or features ("rows"). (Default: "cols")

assay.type

Character scalar. Specifies the name of assay used in calculation. (Default: "counts")

Value

getQC returns a DataFrame with one row per sample (or feature). addQC returns x with the metrics added to colData(x) (or rowData(x)).

Details

The following metrics are calculated for each sample (or feature):

  • total: Sum of values, e.g., library size.

  • detected: Number of values greater than zero.

  • mean: Mean of values.

  • median: Median of values.

  • sd: Standard deviation of values.

  • cv: Coefficient of variation of values.

  • q*: Quantiles. By default, 0%, 25%, 50%, and 100%

Examples

data(GlobalPatterns)
tse <- GlobalPatterns

# Calculate metrics for samples
getQC(tse)
#> DataFrame with 26 rows and 10 columns
#>             total  detected      mean        sd        cv        q0       q25
#>         <numeric> <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
#> CL3        864077      6964   44.9665   453.457  10.08431         0         0
#> CC1       1135457      7679   59.0891   563.725   9.54024         0         0
#> SV1        697509      5729   36.2983   304.332   8.38418         0         0
#> M31Fcsw   1543451      2667   80.3211  2994.947  37.28716         0         0
#> M11Fcsw   2076476      2574  108.0597  4499.180  41.63604         0         0
#> ...           ...       ...       ...       ...       ...       ...       ...
#> TS28       937466      2679   48.7857   1261.12   25.8501         0         0
#> TS29      1211071      2629   63.0241   2499.54   39.6600         0         0
#> Even1     1216137      4213   63.2877   1563.27   24.7009         0         0
#> Even2      971073      3130   50.5346   1329.77   26.3141         0         0
#> Even3     1078241      2776   56.1116   1404.61   25.0323         0         0
#>               q50       q75      q100
#>         <numeric> <numeric> <numeric>
#> CL3             0         3     33783
#> CC1             0         4     36632
#> SV1             0         1     11788
#> M31Fcsw         0         0    354695
#> M11Fcsw         0         0    452219
#> ...           ...       ...       ...
#> TS28            0         0     92915
#> TS29            0         0    251215
#> Even1           0         0    141771
#> Even2           0         0    114624
#> Even3           0         0    124394

# Add metrics for features to rowData
tse <- addQC(tse, by = "rows")
rowData(tse)
#> DataFrame with 19216 rows and 17 columns
#>            Kingdom        Phylum        Class        Order        Family
#>        <character>   <character>  <character>  <character>   <character>
#> 549322     Archaea Crenarchaeota Thermoprotei           NA            NA
#> 522457     Archaea Crenarchaeota Thermoprotei           NA            NA
#> 951        Archaea Crenarchaeota Thermoprotei Sulfolobales Sulfolobaceae
#> 244423     Archaea Crenarchaeota        Sd-NA           NA            NA
#> 586076     Archaea Crenarchaeota        Sd-NA           NA            NA
#> ...            ...           ...          ...          ...           ...
#> 278222    Bacteria           SR1           NA           NA            NA
#> 463590    Bacteria           SR1           NA           NA            NA
#> 535321    Bacteria           SR1           NA           NA            NA
#> 200359    Bacteria           SR1           NA           NA            NA
#> 271582    Bacteria           SR1           NA           NA            NA
#>              Genus                Species     total  detected      mean
#>        <character>            <character> <numeric> <numeric> <numeric>
#> 549322          NA                     NA       259         5 9.9615385
#> 522457          NA                     NA         8         2 0.3076923
#> 951     Sulfolobus Sulfolobusacidocalda..         1         1 0.0384615
#> 244423          NA                     NA        51         2 1.9615385
#> 586076          NA                     NA         3         2 0.1153846
#> ...            ...                    ...       ...       ...       ...
#> 278222          NA                     NA        80         4  3.076923
#> 463590          NA                     NA         6         2  0.230769
#> 535321          NA                     NA       180         4  6.923077
#> 200359          NA                     NA       669        11 25.730769
#> 271582          NA                     NA        17         3  0.653846
#>               sd        cv        q0       q25       q50       q75      q100
#>        <numeric> <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
#> 549322 31.654991   3.17772         0         0         0         0       130
#> 522457  1.225373   3.98246         0         0         0         0         6
#> 951     0.196116   5.09902         0         0         0         0         1
#> 244423  6.999890   3.56857         0         0         0         0        29
#> 586076  0.431455   3.73928         0         0         0         0         2
#> ...          ...       ...       ...       ...       ...       ...       ...
#> 278222 14.880653   4.83621         0         0         0      0.00        76
#> 463590  0.992278   4.29987         0         0         0      0.00         5
#> 535321 33.090087   4.77968         0         0         0      0.00       169
#> 200359 75.399500   2.93032         0         0         0      2.75       279
#> 271582  2.415654   3.69453         0         0         0      0.00        12