Helper function for estimating the spillover matrix. After assigning each pixel to a spotted mass, this function will filter incorrectly assigned pixels and remove small pixel sets.

filterPixels(
  object,
  bc_id = "bc_id",
  spot_mass = "sample_mass",
  minevents = 40,
  correct_pixels = TRUE
)

Arguments

object

a SingleCellExperiment object containing pixel intensities per channel. Individual pixels are stored as columns and channels are stored as rows.

bc_id

character string indicating which colData(object) entry stores the estimated mass

spot_mass

character string indicating which colData(object) entry stores the true isotope mass of the spotted metal.

minevents

single numeric indicating the threshold under which pixel sets are excluded from spillover estimation.

correct_pixels

logical indicating if incorrectly assigned pixels should be excluded from spillover estimation.

Value

returns a SingleCellExperiment object in which colData(object)$bc_id has been adjusted based on the filter criteria.

Author

Vito Zanotelli, adapted by Nils Eling (nils.eling@dqbm.uzh.ch)

Examples

path <- system.file("extdata/spillover", package = "imcRtools")
sce <- readSCEfromTXT(path)
#> Spotted channels:  Dy161, Dy162, Dy163, Dy164
#> Acquired channels:  Dy161, Dy162, Dy163, Dy164
#> Channels spotted but not acquired:  
#> Channels acquired but not spotted:  
assay(sce, "exprs") <- asinh(counts(sce)/5)

# Pre-process via CATALYST
library(CATALYST)

bc_key <- as.numeric(unique(sce$sample_mass))
sce <- assignPrelim(sce, bc_key = bc_key)
#> Debarcoding data...
#>  o ordering
#>  o classifying events
#> Normalizing...
#> Computing deltas...
sce <- estCutoffs(sce)
sce <- applyCutoffs(sce)

sce <- filterPixels(sce)

table(sce$sample_mass, sce$bc_id)
#>      
#>         0 161 162 163 164
#>   161   0 100   0   0   0
#>   162   0   0 100   0   0
#>   163   0   0   0 100   0
#>   164   2   0   0   0  98