generated from openproblems-bio/task_template
-
Notifications
You must be signed in to change notification settings - Fork 14
Add semi-supervised STACAS (ssSTACAS) as new method component #59
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
Open
JGarnica22
wants to merge
13
commits into
openproblems-bio:main
Choose a base branch
from
carmonalab:ss_stacas
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
827cef0
add method semi-supervised STACAS (ssSTACAS)
JGarnica22 cfa41e5
update changelog
JGarnica22 65008f3
Merge remote-tracking branch 'upstream/main' into ss_stacas
JGarnica22 dee1e1c
Update: base_r container
JGarnica22 aaacd54
add: method_types configuration
JGarnica22 1291bf8
fix: move ssSTACAS below kBET
JGarnica22 4a40ddc
add: PR #
JGarnica22 340de8f
fix: remove boilerplat comments
JGarnica22 93d5477
udpate: latest STACAS version
JGarnica22 81e03c9
Merge remote-tracking branch 'upstream/main' into ss_stacas
JGarnica22 7b1357c
fix: do not load unneeded counts, and specificy anchor.features
JGarnica22 52f0b33
Merge remote-tracking branch 'upstream/main' into ss_stacas
JGarnica22 5e31e19
resolve conflict
JGarnica22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,7 @@ | |
| /output | ||
| trace-* | ||
| .ipynb_checkpoints | ||
| __pycache__ | ||
| __pycache__ | ||
| .Rproj.user | ||
| .Rhistory | ||
| *.Rproj | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,6 @@ | |
| set -e | ||
|
|
||
| common/scripts/create_component \ | ||
| --name my_r_method \ | ||
| --name ss_stacas \ | ||
| --language r \ | ||
| --type method | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| __merge__: ../../api/comp_method.yaml | ||
| name: ss_stacas | ||
| label: ssSTACAS | ||
| summary: Accurate semi-supervised integration of single-cell transcriptomics data | ||
| description: | | ||
| STACAS is a method for scRNA-seq integration, | ||
| especially suited to accurately integrate datasets with large cell type imbalance | ||
| (e.g. in terms of proportions of distinct cell populations). | ||
| Prior cell type knowledge, given as cell type labels, can be provided to the algorithm to perform | ||
| semi-supervised integration, leading to increased preservation of biological variability | ||
| in the resulting integrated space. | ||
| STACAS is robust to incomplete cell type labels and can be applied to large-scale integration tasks. | ||
| references: | ||
| doi: 10.1038/s41467-024-45240-z | ||
| # Andreatta M, Hérault L, Gueguen P, Gfeller D, Berenstein AJ, Carmona SJ. | ||
| # Semi-supervised integration of single-cell transcriptomics data. | ||
| # Nature Communications*. 2024;15(1):1-13. doi:10.1038/s41467-024-45240-z | ||
| links: | ||
| documentation: https://carmonalab.github.io/STACAS.demo/STACAS.demo.html | ||
| repository: https://github.com/carmonalab/STACAS | ||
| info: | ||
| preferred_normalization: log_cp10k | ||
JGarnica22 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| method_types: [embedding] | ||
| resources: | ||
| - type: r_script | ||
| path: script.R | ||
| engines: | ||
| - type: docker | ||
| image: openproblems/base_r:1 | ||
| setup: | ||
| - type: r | ||
| github: carmonalab/STACAS@2.3.0 | ||
| runners: | ||
| - type: executable | ||
| - type: nextflow | ||
| directives: | ||
| label: [midtime,midmem,midcpu] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| requireNamespace("anndata", quietly = TRUE) | ||
| suppressPackageStartupMessages({ | ||
| library(STACAS) | ||
| library(Matrix) | ||
| library(SeuratObject) | ||
| library(Seurat) | ||
| }) | ||
|
|
||
| ## VIASH START | ||
| par <- list( | ||
| input = "resources_test/task_batch_integration/cxg_immune_cell_atlas/dataset.h5ad", | ||
| output = "output.h5ad" | ||
| ) | ||
| meta <- list( | ||
| name = "ss_stacas" | ||
| ) | ||
| ## VIASH END | ||
|
|
||
| cat("Reading input file\n") | ||
| adata <- anndata::read_h5ad(par[["input"]]) | ||
|
|
||
| cat("Create Seurat object\n") | ||
| # Only loading normalized values, as raw counts are not needed | ||
|
|
||
| # Transpose because Seurat expects genes in rows, cells in columns | ||
| normalized <- Matrix::t(adata$layers[["normalized"]]) | ||
| # Convert to a regular sparse matrix first and then to dgCMatrix | ||
| normalized <- as(as(normalized, "CsparseMatrix"), "dgCMatrix") | ||
|
|
||
| # Create Seurat object | ||
| seurat_obj <- Seurat::CreateSeuratObject(counts = normalized, | ||
| meta.data = adata$obs) | ||
| # Manually assign pre-normalized values to the "data" slot | ||
| seurat_obj@assays$RNA$data <- normalized | ||
| seurat_obj@assays$RNA$counts <- NULL # remove counts | ||
|
|
||
|
|
||
| # Obtain anchor features from the preprocessing pipeline | ||
| anchor.features <- head(adata$var[order(adata$var$hvg_score, decreasing = T), "feature_id"], 2000) | ||
|
|
||
| cat("Run STACAS\n") | ||
| object_integrated <- seurat_obj |> | ||
| Seurat::SplitObject(split.by = "batch") |> | ||
| STACAS::Run.STACAS(cell.labels = "cell_type", | ||
| anchor.features = anchor.features) | ||
|
|
||
| cat("Store outputs\n") | ||
| output <- anndata::AnnData( | ||
| uns = list( | ||
| dataset_id = adata$uns[["dataset_id"]], | ||
| normalization_id = adata$uns[["normalization_id"]], | ||
| method_id = meta$name | ||
| ), | ||
| obs = adata$obs, | ||
| var = adata$var, | ||
| obsm = list( | ||
| X_emb = object_integrated@reductions$pca@cell.embeddings | ||
| ) | ||
| ) | ||
|
|
||
| cat("Write output AnnData to file\n") | ||
| output$write_h5ad(par[["output"]], compression = "gzip") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.