Skip to contents

This is a modified version of harmony::RunHarmony specifically designed for compatibility with RunSymphonyMap.

Usage

RunHarmony2(object, ...)

# S3 method for class 'Seurat'
RunHarmony2(
  object,
  group.by.vars,
  assay = NULL,
  reduction = "pca",
  dims.use = 1:30,
  project.dim = TRUE,
  reduction.name = "Harmony",
  reduction.save = NULL,
  reduction.key = "Harmony_",
  verbose = TRUE,
  seed.use = 11,
  ...
)

Arguments

object

A Seurat object.

...

Passed to harmony::RunHarmony.

group.by.vars

The batch variable name.

assay

Assay to use. NULL uses the default assay.

reduction

Linear reduction used as input.

dims.use

The dimensions to be used.

project.dim

Whether to project dimension reduction loadings.

reduction.name

Reduction to be stored in the Seurat object.

reduction.save

Deprecated alias for reduction.name, retained for compatibility with harmony::RunHarmony.Seurat.

reduction.key

The prefix for the column names of the Harmony embeddings.

verbose

Whether to print the message. Default is TRUE.

seed.use

Random seed.

Examples

data(panc8_sub)
panc8_sub <- RunStandardWorkflow(panc8_sub)
#>  [2026-08-30 05:01:50] Start standard processing workflow...
#>  [2026-08-30 05:01:50] Checking a list of <Seurat>...
#> ! [2026-08-30 05:01:50] Data 1/1 of the `srt_list` is "unknown"
#> Warning: Data 1/1 of the `srt_list` is "unknown"
#>  [2026-08-30 05:01:50] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#>  [2026-08-30 05:01:50] Perform `FindVariableFeatures()` on 1/1 of `srt_list`...
#>  [2026-08-30 05:01:50] Use the separate HVF from `srt_list`
#>  [2026-08-30 05:01:50] Number of available HVF: 2000
#>  [2026-08-30 05:01:50] Finished check
#>  [2026-08-30 05:01:50] Perform `ScaleData()`
#>  [2026-08-30 05:01:50] Perform pca linear dimension reduction
#>  [2026-08-30 05:01:51] Use stored estimated dimensions 1:26 for Standardpca
#>  [2026-08-30 05:01:52] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#>  [2026-08-30 05:01:52] Reorder clusters...
#>  [2026-08-30 05:01:52] Skip `log1p()` because `layer = data` is not "counts"
#>  [2026-08-30 05:01:52] Perform umap nonlinear dimension reduction
#>  [2026-08-30 05:02:01] Standard processing workflow completed
panc8_sub <- RunHarmony2(
  panc8_sub,
  group.by.vars = "tech",
  reduction = "pca"
)
#> Warning: internal error 1 in R_decompress1 with libdeflate
#> Error in run_harmony(data_mat = data_use[, dims.use, drop = FALSE], meta_data = metavars_df,     vars_use = group.by.vars, verbose = verbose, return_object = TRUE,     ...): lazy-load database '/home/runner/work/_temp/Library/harmony/R/harmony.rdb' is corrupt

CellDimPlot(
  panc8_sub,
  group.by = c("tech", "celltype"),
  reduction = "pca"
)


CellDimPlot(
  panc8_sub,
  group.by = c("tech", "celltype"),
  reduction = "Harmony"
)


panc8_sub <- RunStandardWorkflow(
  panc8_sub,
  prefix = "Harmony",
  linear_reduction = "Harmony"
)
#>  [2026-08-30 05:02:38] Start standard processing workflow...
#> Error in RunStandardWorkflow(panc8_sub, prefix = "Harmony", linear_reduction = "Harmony"): `linear_reduction` must be one of: "pca", "svd", "ica", "nmf", "mds",
#> and "glmpca"

CellDimPlot(
  panc8_sub,
  group.by = c("tech", "celltype"),
  reduction = "StandardpcaUMAP2D"
)


CellDimPlot(
  panc8_sub,
  group.by = c("tech", "celltype"),
  reduction = "HarmonyUMAP2D"
)