Skip to content

Add Seurat components - #77

Merged
rcannood merged 6 commits into
mainfrom
add-seurat-methods
Aug 21, 2026
Merged

Add Seurat components#77
rcannood merged 6 commits into
mainfrom
add-seurat-methods

Conversation

@rcannood

@rcannood rcannood commented Aug 20, 2025

Copy link
Copy Markdown
Member

Describe your changes

Adds two Seurat anchor-based integration methods, methods/seurat_cca and methods/seurat_rpca, implemented on the Seurat v5 workflow from https://satijalab.org/seurat/articles/seurat5_integration:

  1. Split the RNA assay into one layer per batch (split(obj[["RNA"]], f = obj$batch))
  2. ScaleData + RunPCA
  3. IntegrateLayers(method = CCAIntegration | RPCAIntegration, orig.reduction = "pca")
  4. Return the corrected reduction (integrated.cca / integrated.rpca) as X_emb

Two deliberate deviations from the vignette, so the components use the same input as every other method in the benchmark:

  • the normalized layer (log_cp10k, which is Seurat's LogNormalize) is assigned to the data layer instead of calling NormalizeData()
  • var$hvg is used as VariableFeatures instead of FindVariableFeatures()

--dims, --k_anchor, --k_filter and --k_score are forwarded only when set, so Seurat's own defaults apply otherwise.

Checklist before requesting a review

  • I have performed a self-review of my code

  • Check the correct box. Does this PR contain:

    • Breaking changes
    • New functionality
    • Major changes
    • Minor changes
    • Bug fixes
  • Proposed changes are described in the CHANGELOG.md

  • CI Tests succeed and look good!

@rcannood
rcannood requested a review from mumichae August 20, 2025 15:10
Comment thread src/methods/seurat_cca/script.R Outdated
Comment thread src/methods/seurat_cca/script.R Outdated
Comment thread src/methods/seurat_cca/script.R Outdated
Comment thread src/methods/seurat_cca/script.R Outdated
Comment thread src/methods/seurat_cca/script.R Outdated
Comment thread src/methods/seurat_rpca/script.R Outdated
Comment thread src/methods/seurat_cca/script.R Outdated
Comment thread src/methods/seurat_rpca/script.R Outdated
@mumichae

Copy link
Copy Markdown
Collaborator

@rcannood Could you consider updating to the Seurat v5 implementation? That would also resolve most of our reviews

…orkflow

Follow the Seurat v5 integration vignette: split the RNA assay into one
layer per batch, ScaleData + RunPCA, then IntegrateLayers with
CCAIntegration / RPCAIntegration and return the corrected reduction as
X_emb. This replaces the v4 SplitObject / FindIntegrationAnchors /
IntegrateData path and drops the UMAP that was previously exported as
the embedding.

Also:
- convert dgRMatrix to dgCMatrix sparse-to-sparse instead of via a
  dense copy
- stop loading the counts layer in seurat_rpca; it was unused
- forward --dims/--k_anchor/--k_filter/--k_score only when set so
  Seurat's own defaults apply (k.filter is NA in v5, not 200)
- drop the unused X_pca reduction in seurat_rpca
read_h5ad() + as_Seurat() with layers_mapping = c(data = "normalized")
builds the Seurat object directly from the h5ad, replacing the manual
transpose / sparse conversion / CreateSeuratObject / drop-counts block.
Also cite the Seurat v4 paper for seurat_rpca, where RPCA integration
was introduced.
@rcannood
rcannood requested a review from mumichae August 21, 2026 12:08
@rcannood

Copy link
Copy Markdown
Member Author

Merging this already so it can be included in the next run; please let me know if you'd like to see anything changed.

@rcannood
rcannood merged commit 7a905cd into main Aug 21, 2026
3 checks passed
@rcannood
rcannood deleted the add-seurat-methods branch August 21, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants