Batch correction for GeoMX data

geomxBatchCorrection(
  spe,
  k,
  factors,
  NCGs,
  n_assay = 2,
  batch = NULL,
  batch2 = NULL,
  covariates = NULL,
  design = matrix(1, ncol(spe), 1),
  method = c("RUV4", "Limma")
)

Arguments

spe

A Spatial Experiment object.

k

The number of unwanted factors to use. Can be 0. This is required for the RUV4 method.

factors

Column name(s) to indicate the factors of interest. This is required for the RUV4 method.

NCGs

Negative control genes. This is required for the RUV4 method.

n_assay

Integer to indicate the nth count table in the assay(spe) to be used.

batch

A vector indicating batches. This is required for the Limma method.

batch2

A vector indicating the second series of batches. This is specific for the Limma method.

covariates

A matrix or vector of numeric covariates to be adjusted for.

design

A design matrix relating to treatment conditions to be preserved, can be generated using stats::model.matrix function with all biological factors included.

method

Can be either RUV4 or Limma, by default is RUV4.

Value

A Spatial Experiment object, containing the ruv4-normalized count and normalization factor.

References

Gagnon-Bartsch, J. A., Jacob, L., & Speed, T. P. (2013). Removing unwanted variation from high dimensional data with negative controls. Berkeley: Tech Reports from Dep Stat Univ California, 1-112.

Ritchie, M. E., Phipson, B., Wu, D. I., Hu, Y., Law, C. W., Shi, W., & Smyth, G. K. (2015). limma powers differential expression analyses for RNA-sequencing and microarray studies. Nucleic acids research, 43(7), e47-e47.

Examples

data("dkd_spe_subset")
spe <- findNCGs(dkd_spe_subset, top_n = 100)
#> New names:
#>  `cv` -> `cv...1`
#>  `cv` -> `cv...2`
#>  `cv` -> `cv...3`
#>  `cv` -> `cv...4`
#>  `cv` -> `cv...5`
#>  `cv` -> `cv...6`
#>  `cv` -> `cv...7`
spe_ruv <- geomxBatchCorrection(spe,
  k = 3,
  factors = c("disease_status", "region"),
  NCGs = S4Vectors::metadata(spe)$NCGs
)