File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
src/methods_normalization/normalize_by_counts Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ __merge__ : /src/api/comp_method_normalization.yaml
2+
3+ name : normalize_by_counts
4+ label : " Normalize by Counts"
5+ summary : " Normalize the spatial transcriptomics data by the total counts"
6+ description : " Normalize the spatial transcriptomics data by the total counts"
7+ links :
8+ documentation : " https://github.com/openproblems-bio/task_ist_preprocessing"
9+ repository : " https://github.com/scverse/scanpy"
10+ references :
11+ doi : " 10.1186/s13059-017-1382-0"
12+
13+ arguments :
14+ - name : --target_sum
15+ type : double
16+
17+ resources :
18+ - type : python_script
19+ path : script.py
20+
21+ engines :
22+ - type : docker
23+ image : openproblems/base_python:1
24+ setup :
25+ - type : python
26+ pypi :
27+ - scanpy
28+ - type : native
29+
30+ runners :
31+ - type : executable
32+ - type : nextflow
33+ directives :
34+ label : [ midtime, lowcpu, lowmem ]
Original file line number Diff line number Diff line change 1+ import anndata as ad
2+ import scanpy as sc
3+
4+ ## VIASH START
5+ par = {
6+ 'input_spatial_aggregated_counts' : 'resources_test/task_ist_preprocessing/mouse_brain_combined/spatial_aggregated_counts.h5ad' ,
7+ 'output' : 'spatial_norm_counts.h5ad' ,
8+
9+ 'target_sum' : None ,
10+ }
11+ ## VIASH END
12+
13+ print ('Reading input files' , flush = True )
14+ adata = ad .read (par ['input_spatial_aggregated_counts' ])
15+
16+ print ('Normalizing by total counts' , flush = True )
17+ adata .layers ['normalized' ] = adata .layers ['counts' ].copy ()
18+ sc .pp .normalize_total (adata , layer = "normalized" , target_sum = par ["target_sum" ])
19+ sc .pp .log1p (adata , layer = "normalized" )
20+
21+ print ('Writing output' , flush = True )
22+ adata .write (par ['output' ])
You can’t perform that action at this time.
0 commit comments