A wrapper function for isOutlier. Identify outliers from numeric vectors stored in the SingleCellExperiment object.

detectCellOutlier(
  inSCE,
  slotName,
  itemName,
  sample = NULL,
  nmads = 3,
  type = "both",
  overwrite = TRUE
)

Arguments

inSCE

A SingleCellExperiment object.

slotName

Desired slot of SingleCellExperiment used for plotting. Possible options: "assays", "colData", "metadata", "reducedDims". Required.

itemName

Desired vector within the slot used for plotting. Required.

sample

A single character specifying a name that can be found in colData(inSCE) to directly use the cell annotation; or a character vector with as many elements as cells to indicates which sample each cell belongs to. Default NULL. decontX will be run on cells from each sample separately.

nmads

Integer. Number of median absolute deviation. Parameter may be adjusted for more lenient or stringent outlier cutoff. Default 3.

type

Character. Type/direction of outlier detection; whether the lower/higher outliers should be detected, or both. Options are "both", "lower", "higher".

overwrite

Boolean. If TRUE, and this function has previously generated an outlier decision on the same itemName, the outlier decision will be overwritten. Default TRUE.

Value

A SingleCellExperiment object with '' added to the

colData slot. Additionally, the decontaminated counts will be added as an assay called 'decontXCounts'.

Examples

data(scExample, package = "singleCellTK")
sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'")
sce <- runDecontX(sce[,sample(ncol(sce),20)])
#> Fri Feb  2 14:16:37 2024 ... Running 'DecontX'
#> --------------------------------------------------
#> Starting DecontX
#> --------------------------------------------------
#> Fri Feb  2 14:16:38 2024 .. Analyzing all cells
#> Fri Feb  2 14:16:38 2024 .... Generating UMAP and estimating cell types
#> Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
#> Also defined by ‘spam’
#> Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
#> Also defined by ‘spam’
#> Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
#> Also defined by ‘spam’
#> Fri Feb  2 14:16:42 2024 .... Estimating contamination
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 10 | converge: 0.01404
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 20 | converge: 0.004718
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 30 | converge: 0.002207
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 40 | converge: 0.001589
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 50 | converge: 0.001587
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 60 | converge: 0.001492
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 70 | converge: 0.001387
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 80 | converge: 0.001332
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 90 | converge: 0.001254
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 100 | converge: 0.00122
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 110 | converge: 0.00108
#> Fri Feb  2 14:16:42 2024 ...... Completed iteration: 117 | converge: 0.0009928
#> Fri Feb  2 14:16:42 2024 .. Calculating final decontaminated matrix
#> --------------------------------------------------
#> Completed DecontX. Total time: 3.99827 secs
#> --------------------------------------------------
sce <- detectCellOutlier(sce, slotName = "colData", sample = sce$sample,
 nmads = 4, itemName = "decontX_contamination", type = "both")