-
Notifications
You must be signed in to change notification settings - Fork 4
add singler python implementation #118
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c2b1ad1
add singler python implementation
dariarom94 7f54992
script to run the benchmark
dariarom94 d6be588
workflow file
dariarom94 37f0739
workflow configuration
dariarom94 6f4f082
improvements
dariarom94 87382c1
Adjust docs and repo in singler
LouisK92 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
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| __merge__: /src/api/comp_method_cell_type_annotation.yaml | ||
|
|
||
| name: singler | ||
| label: "singler" | ||
| summary: "Cell type annotations using single-cell reference with SingleR" | ||
| description: "Cell type annotations using single-cell reference with SingleR" | ||
|
|
||
| links: | ||
| documentation: "https://github.com/SingleR-inc/singler-py" | ||
| repository: "https://github.com/SingleR-inc/singler-py" | ||
| references: | ||
| doi: "10.1038/s41590-018-0276-y" | ||
|
|
||
| arguments: | ||
| - name: --labels_key | ||
| type: string | ||
| description: The key of the cell labels in the input data. | ||
| default: cell_labels | ||
|
|
||
| resources: | ||
| - type: python_script | ||
| path: script.py | ||
|
|
||
| engines: | ||
| - type: docker | ||
| image: openproblems/base_python:1 | ||
| setup: | ||
| - type: python | ||
| pypi: [singler] | ||
| __merge__: | ||
| - /src/base/setup_spatialdata_partial.yaml | ||
| - type: native | ||
|
|
||
| runners: | ||
| - type: executable | ||
| - type: nextflow | ||
| directives: | ||
| label: [ midtime, midcpu, midmem ] | ||
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,53 @@ | ||
| import anndata as ad | ||
| import os | ||
| import shutil | ||
|
|
||
| import singlecellexperiment as sce | ||
| import singler | ||
|
|
||
| ## VIASH START | ||
| # The following code has been auto-generated by Viash. | ||
| par = { | ||
| 'input_spatial_normalized_counts': r'resources_test/task_ist_preprocessing/mouse_brain_combined/spatial_normalized_counts.h5ad', | ||
| 'input_transcript_assignments': r'resources_test/task_ist_preprocessing/mouse_brain_combined/transcript_assignments.zarr', | ||
| 'input_scrnaseq_reference': r'resources_test/task_ist_preprocessing/mouse_brain_combined/scrnaseq_reference.h5ad', | ||
| 'celltype_key': r'cell_type', | ||
| 'output': r'resources_test/task_ist_preprocessing/mouse_brain_combined/spatial_with_cell_types.h5ad', | ||
| 'labels_key': r'cell_labels' | ||
| } | ||
| meta = { | ||
| 'name': r'singleR', | ||
| 'functionality_name': r'singleR' | ||
| } | ||
| dep = { | ||
|
|
||
| } | ||
|
|
||
| ## VIASH END | ||
| sce_h5ad = sce.read_h5ad(par['input_spatial_normalized_counts']) | ||
| adata_sp = ad.read_h5ad(par['input_spatial_normalized_counts']) | ||
|
|
||
| sce_ref = sce.read_h5ad(par['input_scrnaseq_reference']) | ||
|
|
||
| features = [str(x) for x in sce_h5ad.row_data.row_names] | ||
|
|
||
| mat = sce_h5ad.assay("counts") ##example has raw, not sure | ||
LouisK92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mat = mat.sorted_indices() ## magic line to make sure the matrix is in the right format for SingleR | ||
|
|
||
| mat_ref = sce_ref.assay("normalized") | ||
| mat_ref = mat_ref.sorted_indices() ## magic line to make sure the matrix is in the right format for SingleR | ||
|
|
||
| ## create the reference from our sc data | ||
| built = singler.train_single(ref_data = mat_ref, | ||
| ref_labels = sce_ref.get_column_data().column("cell_type"), | ||
| ref_features = sce_ref.get_row_names(), | ||
| test_features = features,) | ||
|
|
||
| ## annotate the dataset | ||
| output = singler.classify_single(mat, ref_prebuilt=built) | ||
|
|
||
| adata_sp.obs["cell_type"] = output['best'] | ||
|
|
||
| # Write output | ||
| print('Writing output', flush=True) | ||
| adata_sp.write(par['output']) | ||
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 |
|---|---|---|
|
|
@@ -376,7 +376,8 @@ workflow run_wf { | |
| tacco, | ||
| moscot, | ||
| mapmycells, | ||
| tangram | ||
| tangram, | ||
| singler | ||
| ] | ||
|
|
||
| cta_ch = normalization_ch | ||
|
|
||
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.