Skip to content

Commit 16867f5

Browse files
committed
add tests and do not copy anndata
1 parent e0f5044 commit 16867f5

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

tools/celltypist/celltypist.xml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
<requirement type="package" version="@TOOL_VERSION@">celltypist</requirement>
1111
</requirements>
1212
<command><![CDATA[
13-
cp '$adata' 'anndata.h5ad' &&
1413
cat '$script_file' &&
15-
python '$script_file' &&
14+
python '$script_file'
1615
]]>
1716
</command>
1817
<configfiles>
@@ -21,12 +20,17 @@ import scanpy as sc
2120
import celltypist
2221
from celltypist import models
2322
24-
adata = sc.read_h5ad('anndata.h5ad') models.download_models(models='$model_name', cache_dir='./celltypist_models_cache')
25-
model = models.Model.load(models='$model_name', cache_dir='./celltypist_models_cache')
23+
adata = sc.read_h5ad('$adata')
24+
models.download_models(model='$model_name')
25+
model = models.Model.load(model='$model_name')
2626
predictions = celltypist.annotate(adata,
2727
model=model,
28-
majority_voting=$majority_voting,
28+
#if $majority_voting
29+
majority_voting=True,
30+
#end if
31+
#if $transpose_input
2932
transpose_input=$transpose_input,
33+
#end if
3034
mode='$mode',
3135
p_thres=$p_thres,
3236
min_prop=$min_prop)
@@ -52,24 +56,43 @@ adata.write_h5ad('$anndata_out', compression='gzip')
5256
<option value="best match">Choose the cell type with the largest score/probability as the final prediction</option>
5357
<option value="prob match">Enable a multi-label classification utilising a probability threshold</option>
5458
</param>
55-
<param name="p_thres" type="float" label="Probability threshold" value="0.5" />
56-
<param name="min_prop" type="float" label="Minimum proportion for cell type assignment" value="0.05" />
57-
<param name="reference" type="text" label="Reference column in AnnData.obs for dotplot" value="cell_type" />
58-
<param name="prediction" type="text" label="Prediction column in AnnData.obs for dotplot" value="predicted_labels" />
59+
<param name="p_thres" type="float" value="0.5" min="0" max="1" label="Probability threshold for the multi-label classification" help="Ignored if mode is best match." />
60+
<param name="min_prop" type="float" value="0" min="0" max="1" label="The minimum proportion of cells required to support naming of the subcluster by this cell type" help="Ignored if majority_voting is set to False"/>
5961
</inputs>
6062
<outputs>
6163
<data name="anndata_out" format="h5ad" label="${tool.name} on ${on_string}: AnnData with celltype annotations" />
6264
</outputs>
6365
<tests>
64-
<test>
66+
<test expect_num_outputs="1">
6567
<param name="adata" location="https://celltypist.cog.sanger.ac.uk/Notebook_demo_data/demo_500_cells.h5ad"/>
6668
<param name="model_name" value="Immune_All_Low.pkl" />
6769
<param name="majority_voting" value="True" />
68-
<param name="transpose_input" value="False" />
6970
<param name="mode" value="best match" />
7071
<param name="p_thres" value="0.5" />
7172
<param name="min_prop" value="0.05" />
72-
<output name="anndata_out" file="expected_celltypist_output.h5ad" />
73+
<output name="anndata_out" ftype="h5ad">
74+
<assert_contents>
75+
<has_h5_keys keys="obs/predicted_labels"/>
76+
<has_h5_keys keys="obs/over_clustering"/>
77+
<has_h5_keys keys="obs/majority_voting"/>
78+
<has_h5_keys keys="obs/conf_score"/>
79+
</assert_contents>
80+
</output>
81+
</test>
82+
<test expect_num_outputs="1">
83+
<param name="adata" location="https://celltypist.cog.sanger.ac.uk/Notebook_demo_data/demo_500_cells.h5ad"/>
84+
<param name="model_name" value="Immune_All_High.pkl" />
85+
<param name="majority_voting" value="False" />
86+
<param name="mode" value="prob match" />
87+
<param name="p_thres" value="0.5" />
88+
<param name="min_prop" value="0.05" />
89+
<output name="anndata_out" ftype="h5ad">
90+
<assert_contents>
91+
<has_h5_keys keys="obs/predicted_labels"/>
92+
<has_h5_keys keys="obs/conf_score"/>
93+
</assert_contents>
94+
</output>
95+
<output name="anndata_out" file="celltypist_annotated.h5ad" />
7396
</test>
7497
</tests>
7598
<help><![CDATA[

0 commit comments

Comments
 (0)