isOutlier: Identify if a cell is an outlier based on a metric

Description Usage Arguments Value Examples

View source: R/qc.R

Description

Convenience function to determine which values for a metric are outliers based on median-absolute-deviation (MAD).

Usage

1
2
isOutlier(metric, nmads = 5, type = c("both", "lower", "higher"),
  log = FALSE, subset = NULL, batch = NULL, min.diff = NA)

Arguments

metric

numeric or integer vector of values for a metric

nmads

scalar, number of median-absolute-deviations away from median required for a value to be called an outlier

type

character scalar, choice indicate whether outliers should be looked for at both tails (default: "both") or only at the lower end ("lower") or the higher end ("higher")

log

logical, should the values of the metric be transformed to the log10 scale before computing median-absolute-deviation for outlier detection?

subset

logical or integer vector, which subset of values should be used to calculate the median/MAD? If NULL, all values are used. Missing values will trigger a warning and will be automatically ignored.

batch

factor of length equal to metric, specifying the batch to which each observation belongs. A median/MAD is calculated for each batch, and outliers are then identified within each batch.

min.diff

numeric scalar indicating the minimum difference from the median to consider as an outlier. The outlier threshold is defined from the larger of nmads MADs and min.diff, to avoid calling many outliers when the MAD is very small. If NA, it is ignored.

Value

a logical vector of the same length as the metric argument

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data("sc_example_counts")
data("sc_example_cell_info")
example_sce <- SingleCellExperiment(
assays = list(counts = sc_example_counts), colData = sc_example_cell_info)
example_sce <- calculateQCMetrics(example_sce)

## with a set of feature controls defined
example_sce <- calculateQCMetrics(example_sce, 
feature_controls = list(set1 = 1:40))
isOutlier(example_sce$total_counts, nmads = 3)

scater documentation built on Dec. 5, 2017, 2 a.m.