Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmony fix #827

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading