generated from openproblems-bio/task_template
-
Notifications
You must be signed in to change notification settings - Fork 14
Add ComBat-Seq method #55
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
EpigeneMax
wants to merge
3
commits into
openproblems-bio:main
Choose a base branch
from
EpigeneMax:main
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
3 commits
Select commit
Hold shift + click to select a range
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
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,52 @@ | ||
| __merge__: ../../api/comp_method.yaml | ||
| name: combat_seq | ||
| label: ComBat-Seq | ||
| summary: Adjusting batch effects in RNA-Seq expression data using empirical Bayes | ||
| methods | ||
| description: | | ||
| ComBat-Seq extends the ComBat method for batch correction in RNA-Seq data. | ||
| While ComBat assumes normally distributed data, ComBat-Seq uses a negative | ||
| binomial distribution to model the data. While initially developed for | ||
| RNA-Seq data, ComBat-Seq can be applied to single-cell RNA-Seq data as well. | ||
|
|
||
| The method is implemented in Python as a part of the inmoose package. It is | ||
| based on the original R implementation, distributed through the sva package. | ||
|
|
||
| references: | ||
| doi: | ||
| - 10.1093/nargab/lqaa078 | ||
| - 10.1186/s12859-023-05578-5 | ||
|
|
||
| links: | ||
| documentation: https://inmoose.readthedocs.io/en/stable/pycombatseq.html | ||
| repository: https://github.com/epigenelabs/inmoose | ||
|
|
||
| # Metadata for your component | ||
| info: | ||
| # Which normalisation method this component prefers to use (required). | ||
| preferred_normalization: counts | ||
| method_types: [feature] | ||
|
|
||
| # Resources required to run the component | ||
| resources: | ||
| - type: python_script | ||
| path: script.py | ||
| - path: /src/utils/read_anndata_partial.py | ||
|
|
||
| engines: | ||
| # Specifications for the Docker image for this component. | ||
| - type: docker | ||
| image: openproblems/base_python:1.0.0 | ||
| # Add custom dependencies here (optional). For more information, see | ||
| # https://viash.io/reference/config/engines/docker/#setup . | ||
| setup: | ||
| - type: python | ||
| pip: inmoose | ||
|
|
||
| runners: | ||
| # This platform allows running the component natively | ||
| - type: executable | ||
| # Allows turning the component into a Nextflow module / pipeline. | ||
| - 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,42 @@ | ||
| import sys | ||
|
|
||
| import anndata as ad | ||
| import numpy as np | ||
| from inmoose.pycombat import pycombat_seq | ||
| from scipy.sparse import csr_matrix | ||
|
|
||
| # VIASH START | ||
| # Note: this section is auto-generated by viash at runtime. To edit it, make changes | ||
| # in config.vsh.yaml and then run `viash config inject config.vsh.yaml`. | ||
| par = {"input": "resources_test/.../input.h5ad", "output": "output.h5ad"} | ||
| meta = {"name": "combat-seq"} | ||
| # VIASH END | ||
|
|
||
| sys.path.append(meta["resources_dir"]) | ||
| from read_anndata_partial import read_anndata | ||
|
|
||
| print("Read input", flush=True) | ||
| adata = read_anndata( | ||
| par["input"], X="layers/normalized", obs="obs", var="var", uns="uns" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rcannood Could you confirm if this is the correct way to read the counts layer, given that |
||
| ) | ||
|
|
||
| print("Run Combat-Seq", flush=True) | ||
| counts = adata.T.to_df().astype(np.double).values | ||
| corrected_counts = pycombat_seq(counts, adata.obs["batch"]) | ||
|
|
||
| print("Store output", flush=True) | ||
| output = ad.AnnData( | ||
| obs=adata.obs[[]], | ||
| var=adata.var[[]], | ||
| uns={ | ||
| "dataset_id": adata.uns["dataset_id"], | ||
| "normalization_id": adata.uns["normalization_id"], | ||
| "method_id": meta["name"], | ||
| }, | ||
| layers={ | ||
| "corrected_counts": csr_matrix(corrected_counts.T), | ||
| }, | ||
| ) | ||
|
|
||
| print("Store outputs", flush=True) | ||
| 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.