Skip to contents

Provides a wrapper around harmony::RunHarmony() that harmonizes existing embedding matrices using either a metadata column or an explicit vector of group assignments.

Usage

run_harmony(x, ...)

# S3 method for class 'matrix'
run_harmony(x, group_values, ...)

# S3 method for class 'dgCMatrix'
run_harmony(x, ...)

# S3 method for class 'IterableMatrix'
run_harmony(x, ...)

# S3 method for class 'MarchRDataset'
run_harmony(
  x,
  group_by = character(0),
  group_values = NULL,
  assay_name = character(0),
  output_assay_name = "Harmony",
  ...
)

# S3 method for class 'MarchRProject'
run_harmony(
  x,
  group_by = character(0),
  group_values = NULL,
  dataset_names = character(0),
  assay_name = character(0),
  output_assay_name = "Harmony",
  ...
)

Arguments

x

(matrix; IterableMatrix; dgCMatrix; MarchRDataset; MarchRProject) Object containing embeddings to harmonize.

...

Additional arguments forwarded to harmony::RunHarmony(); its verbose defaults to FALSE.

group_values

(vector) Group assignments for each cell. When unnamed, values are matched to the order of the embeddings.

group_by

(character) Name of the metadata column describing group assignments. Provide only one of group_by or group_values.

assay_name

(character) Name of the assay containing the embeddings to harmonize. Defaults to the first assay shared across the selected datasets.

output_assay_name

(character) Name for the harmonized assay to create or overwrite within each selected dataset.

dataset_names

(character) Subset of project datasets to harmonize. When empty, all datasets in the project are used.

Value

For matrix-like inputs, a harmonized matrix. For dataset and project inputs, the updated object with a harmonized assay.