Skip to content

Commit

Permalink
Merge pull request #827 from AlexsLemonade/sjspielman/harmony-code-bump
Browse files Browse the repository at this point in the history
Harmony fix
  • Loading branch information
sjspielman authored Dec 6, 2024
2 parents e139c88 + 736fdd1 commit 06967b5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion module-cheatsheets/scRNA-seq-advanced-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ Read the [`harmony` package documentation](https://rdrr.io/github/immunogenomics
|----------------------|--------------------|---------------------|---------------|
| `batchelor`| [`MultiBatchPCA()`](https://rdrr.io/bioc/batchelor/man/multiBatchPCA.html)| Multi-batch PCA | Perform PCA across multiple gene expression matrices, weighted by batch size |
| `batchelor`| [`fastMNN()`](https://rdrr.io/bioc/batchelor/man/fastMNN.html)| Fast mutual nearest neighbors correction | Perform integration on an SCE object with mutual nearest neighbors using the `fastMNN` algorithm, returning an SCE object with batch-corrected principal components |
| `harmony`| [`HarmonyMatrix()`](https://rdrr.io/github/immunogenomics/harmony/man/HarmonyMatrix.html)| Perform `harmony` integration on a matrix | Perform integration with `harmony` on either a matrix of principle components or gene expression, returning a matrix of batch-corrected principal components |
| `harmony`| [`RunHarmony()`](https://rdrr.io/github/immunogenomics/harmony/man/RunHarmony.html)| Run the `harmony` algorithm | Perform integration with the `harmony` algorithm on a matrix of single-cell genomics cell embeddings, returning a matrix of batch-corrected principal components |


## `SingleR`

Expand Down
Binary file modified module-cheatsheets/scRNA-seq-advanced-cheatsheet.pdf
Binary file not shown.
9 changes: 3 additions & 6 deletions scRNA-seq-advanced/02-dataset_integration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,8 @@ Like `fastMNN`, `harmony` performs integration on a merged PCA matrix.
However, unlike `fastMNN`, `harmony` does not "back-calculate" corrected expression from the corrected PCA matrix and it only returns the corrected PCA matrix itself.
For input, `harmony` needs a couple pieces of information:

- First, `harmony` can either take a matrix of normalized expression values, from which it will calculate a batch-weighted PCA matrix to integrate, or it can take a batch-weighted PCA matrix directly to perform integration.
- First, `harmony` takes batch-weighted PCA matrix directly to perform integration.
Since we already calculated a batch-weighted PCA matrix (our `merged_PCA` reduced dimension), we'll provide this information directly.
- We will need to specify the additional argument `do_pca=FALSE` to tell `harmony` that the input matrix we provided already is a PCA matrix.
- Second, we need to tell `harmony` about the covariates to use - `sample` and `patient`.
To do this, we provide two arguments:
- `meta_data`, a data frame that contains covariates across samples.
Expand All @@ -752,11 +751,9 @@ To do this, we provide two arguments:
Let's go!

```{r run harmony, live = TRUE}
# integrate with harmony, setting the argument `do_pca = FALSE`
# since we are providing a PCA matrix directly
harmony_pca <- harmony::HarmonyMatrix(
# Run harmony integration
harmony_pca <- harmony::RunHarmony(
data_mat = reducedDim(merged_sce, "merged_PCA"),
do_pca = FALSE,
meta_data = colData(merged_sce),
vars_use = c("sample", "patient")
)
Expand Down

0 comments on commit 06967b5

Please sign in to comment.