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,
  reduction = "pca",
  dims.use = 1:30,
  project.dim = TRUE,
  reduction.name = "Harmony",
  reduction.key = "Harmony_",
  verbose = TRUE,
  seed.use = 11L,
  ...
)

Arguments

object

A Seurat object.

...

Additional arguments to be passed to harmony::RunHarmony.

group.by.vars

The batch variable name.

reduction

The reduction to be used. Default is "pca".

dims.use

The dimensions to be used. Default is 1:30.

project.dim

Whether to project dimension reduction loadings. Default is TRUE.

reduction.name

The name of the reduction to be stored in the Seurat object. Default is "Harmony".

reduction.key

The prefix for the column names of the Harmony embeddings. Default is "Harmony_".

verbose

Whether to print the message. Default is TRUE.

seed.use

The random seed to be used. Default is 11.

Examples

panc8_sub <- RunHarmony2(
  panc8_sub,
  group.by.vars = "tech",
  reduction = "pca"
)
#>  [2025-09-20 13:42:59] Installing: harmony...
#>  
#> → Will install 2 packages.
#> → All 2 packages (0 B) are cached.
#> + RhpcBLASctl   0.23-42 
#> + harmony       1.2.3   
#>   
#>  No downloads are needed, 2 pkgs are cached
#>  Got RhpcBLASctl 0.23-42 (x86_64-pc-linux-gnu-ubuntu-24.04) (14.56 kB)
#>  Got harmony 1.2.3 (x86_64-pc-linux-gnu-ubuntu-24.04) (4.80 MB)
#>  Installed RhpcBLASctl 0.23-42  (1s)
#>  Installed harmony 1.2.3  (1.1s)
#>  1 pkg + 29 deps: kept 27, added 2, dld 2 (4.81 MB) [3.3s]
#>  [2025-09-20 13:43:02] harmony@1.1.0 installed successfully
#> Error in object[[reduction]]: ‘pca’ not found in this Seurat object
#>  
CellDimPlot(
  panc8_sub,
  group.by = c("tech", "celltype"),
  reduction = "pca"
)
#> Error in DefaultReduction(srt, pattern = reduction): Unable to find any reductions
CellDimPlot(
  panc8_sub,
  group.by = c("tech", "celltype"),
  reduction = "Harmony"
)
#> Error in DefaultReduction(srt, pattern = reduction): Unable to find any reductions