runHarmony: Apply Harmony batch effect correction method to...

View source: R/runBatchCorrection.R

runHarmonyR Documentation

Apply Harmony batch effect correction method to SingleCellExperiment object

Description

Harmony is an algorithm that projects cells into a shared embedding in which cells group by cell type rather than dataset-specific conditions.

Usage

runHarmony(
  inSCE,
  useAssay = NULL,
  useReducedDim = NULL,
  batch = "batch",
  reducedDimName = "HARMONY",
  nComponents = 50,
  lambda = 0.1,
  theta = 5,
  sigma = 0.1,
  nIter = 10,
  seed = 12345,
  verbose = TRUE,
  ...
)

Arguments

inSCE

Input SingleCellExperiment object

useAssay

A single character indicating the name of the assay requiring batch correction. Default NULL. It is recommended to use a reducedDim such as PCA through the 'useReducedDim' parameter of this function.

useReducedDim

A single character indicating the name of the reducedDim to be used. It is recommended to use a reducedDim instead of a full assay as using an assay might cause the algorithm to not converge and throw error. Specifying this will ignore useAssay. Default NULL.

batch

A single character indicating a field in colData that annotates the batches of each cell; or a vector/factor with the same length as the number of cells. Default "batch".

reducedDimName

A single character. The name for the corrected low-dimensional representation. Will be saved to reducedDim(inSCE). Default "HARMONY".

nComponents

An integer. The number of PCs to use and generate. Default 50L.

lambda

A Numeric scalar. Ridge regression penalty parameter. Must be strictly positive. Smaller values result in more aggressive correction. Default 0.1.

theta

A Numeric scalar. Diversity clustering penalty parameter. Larger values of theta result in more diverse clusters. theta=0 does not encourage any diversity. Default 5.

sigma

A Numeric scalar. Width of soft kmeans clusters. Larger values of sigma result in cells assigned to more clusters. Smaller values of sigma make soft kmeans cluster approach hard clustering. Default 0.1.

nIter

An integer. The max number of iterations to perform. Default 10L.

seed

Set seed for reproducibility. Default is 12345.

verbose

Whether to print progress messages. Default TRUE.

...

Other arguments passed to HarmonyMatrix. See details.

Details

Since some of the arguments of HarmonyMatrix is controlled by this wrapper function. The additional arguments users can work with only include: nclust, tau, block.size, max.iter.cluster, epsilon.cluster, epsilon.harmony, plot_convergence, reference_values and cluster_prior.

Value

The input SingleCellExperiment object with reducedDim(inSCE, reducedDimName) updated.

References

Ilya Korsunsky, et al., 2019

Examples

data('sceBatches', package = 'singleCellTK')
logcounts(sceBatches) <- log1p(counts(sceBatches))
## Not run: 
if (require("harmony"))
    sceCorr <- runHarmony(sceBatches)

## End(Not run)

compbiomed/singleCellTK documentation built on Oct. 27, 2024, 3:26 a.m.