comparison import.xml @ 3:b5c7ba11401d draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/anndata/ commit dc9d19d1f902f3ed54009cd0e68c8518c284b856"
author iuc
date Mon, 06 Jan 2020 13:45:13 -0500
parents e175d4067b00
children 32e547223c9e
comparison
equal deleted inserted replaced
2:e175d4067b00 3:b5c7ba11401d
1 <tool id="anndata_import" name="Import AnnData" version="@VERSION@+@GALAXY_VERSION@"> 1 <tool id="anndata_import" name="Import Anndata and loom" version="@VERSION@+@GALAXY_VERSION@">
2 <description>from different format</description> 2 <description>from different format</description>
3 <macros> 3 <macros>
4 <import>macros.xml</import> 4 <import>macros.xml</import>
5 <xml name="params_10x"> 5 <xml name="params_10x">
6 <param name="barcodes" type="data" format="tabular,txt" label="Barcodes"/> 6 <param name="barcodes" type="data" format="tabular,txt" label="Barcodes"/>
15 <expand macro="requirements"> 15 <expand macro="requirements">
16 <requirement type="package" version="1.4.4.post1">scanpy</requirement> 16 <requirement type="package" version="1.4.4.post1">scanpy</requirement>
17 </expand> 17 </expand>
18 <expand macro="version_command"/> 18 <expand macro="version_command"/>
19 <command detect_errors="exit_code"><![CDATA[ 19 <command detect_errors="exit_code"><![CDATA[
20 #if $in.adata_format == 'mtx' 20 #if $hd5_format.filetype == 'anndata'
21 mkdir mtx 21 #if $hd5_format.in.adata_format == 'mtx'
22 #if $in.tenx.use == 'legacy_10x' 22 mkdir mtx
23 && cp '$in.matrix' 'mtx/matrix.mtx' 23 #if $hd5_format.in.tenx.use == 'legacy_10x'
24 && cp '$in.tenx.genes' 'mtx/genes.tsv' 24 && cp '$hd5_format.in.matrix' 'mtx/matrix.mtx'
25 && cp '$in.tenx.barcodes' 'mtx/barcodes.tsv' 25 && cp '$hd5_format.in.tenx.genes' 'mtx/genes.tsv'
26 #else if $in.tenx.use == 'v3_10x' 26 && cp '$hd5_format.in.tenx.barcodes' 'mtx/barcodes.tsv'
27 && cp '$in.matrix' 'mtx/matrix.mtx' 27 #else if $hd5_format.in.tenx.use == 'v3_10x'
28 && gzip 'mtx/matrix.mtx' 28 && cp '$hd5_format.in.matrix' 'mtx/matrix.mtx'
29 && cp '$in.tenx.features' 'mtx/features.tsv' 29 && gzip 'mtx/matrix.mtx'
30 && gzip 'mtx/features.tsv' 30 && cp '$hd5_format.in.tenx.features' 'mtx/features.tsv'
31 && cp '$in.tenx.barcodes' 'mtx/barcodes.tsv' 31 && gzip 'mtx/features.tsv'
32 && gzip 'mtx/barcodes.tsv' 32 && cp '$hd5_format.in.tenx.barcodes' 'mtx/barcodes.tsv'
33 #end if 33 && gzip 'mtx/barcodes.tsv'
34 && 34 #end if
35 #else if $in.adata_format == 'umi_tools' 35 &&
36 gzip '$in.input' 36 #else if $hd5_format.in.adata_format == 'umi_tools'
37 && 37 gzip '$hd5_format.in.input'
38 #end if 38 &&
39 39 #end if
40 @CMD@ 40
41 41 @CMD@
42 #if $in.adata_format == 'mtx' 42
43 && rm -rf mtx 43 #if $hd5_format.in.adata_format == 'mtx'
44 && rm -rf mtx
45 #end if
46
47 #else:
48 python '$__tool_directory__/tsv_to_loompy.py'
49 -c '${hd5_format.coldata}'
50 -r '${hd5_format.rowdata}'
51 -f '${hd5_format.mainmatrix}'
52 #if $hd5_format.other_files:
53 '${hd5_format.other_files}'
54 #end if
44 #end if 55 #end if
45 ]]></command> 56 ]]></command>
46 <configfiles> 57 <configfiles>
47 <configfile name="script_file"><![CDATA[ 58 <configfile name="script_file"><![CDATA[
48 @CMD_imports@ 59 @CMD_imports@
49 #if $in.adata_format == 'loom' 60 #if $hd5_format.filetype == 'anndata'
61 #if $hd5_format.in.adata_format == 'loom'
50 adata = ad.read_loom( 62 adata = ad.read_loom(
51 '$in.input', 63 '$hd5_format.in.input',
52 sparse=$in.sparse, 64 sparse=$hd5_format.in.sparse,
53 cleanup=$in.cleanup, 65 cleanup=$hd5_format.in.cleanup,
54 X_name='$in.x_name', 66 X_name='$hd5_format.in.x_name',
55 obs_names='$in.obs_names', 67 obs_names='$hd5_format.in.obs_names',
56 var_names='$in.var_names') 68 var_names='$hd5_format.in.var_names')
57 69
58 #else if $in.adata_format == 'tabular' 70 #else if $hd5_format.in.adata_format == 'tabular'
59 #set delimiter=$in.input.metadata.delimiter 71 #set delimiter=$hd5_format.in.input.metadata.delimiter
60 #if $delimiter != ',' 72 #if $delimiter != ','
61 #set delimiter='\\t' 73 #set delimiter='\\t'
62 #end if 74 #end if
63 adata = ad.read_csv( 75 adata = ad.read_csv(
64 '$in.input', 76 '$hd5_format.in.input',
65 delimiter='$delimiter', 77 delimiter='$delimiter',
66 first_column_names=$in.first_column_names) 78 first_column_names=$hd5_format.in.first_column_names)
67 79
68 #else if $in.adata_format == 'mtx' 80 #else if $hd5_format.in.adata_format == 'mtx'
69 #if $in.tenx.use == 'no' 81 #if $hd5_format.in.tenx.use == 'no'
70 adata = ad.read_mtx(filename='$in.matrix') 82 adata = ad.read_mtx(filename='$hd5_format.in.matrix')
71 #else 83 #else
72 import scanpy as sc 84 import scanpy as sc
73 adata = sc.read_10x_mtx( 85 adata = sc.read_10x_mtx(
74 'mtx', 86 'mtx',
75 var_names='$in.tenx.var_names', 87 var_names='$hd5_format.in.tenx.var_names',
76 make_unique=$in.tenx.make_unique, 88 make_unique=$hd5_format.in.tenx.make_unique,
77 cache=False, 89 cache=False,
78 gex_only=$in.tenx.gex_only) 90 gex_only=$hd5_format.in.tenx.gex_only)
79 #end if 91 #end if
80 92
81 #else if $in.adata_format == 'umi_tools' 93 #else if $hd5_format.in.adata_format == 'umi_tools'
82 adata = ad.read_umi_tools('${in.input}.gz') 94 adata = ad.read_umi_tools('${hd5_format.in.input}.gz')
83 95
84 #end if 96 #end if
85
86 adata.write('anndata.h5ad') 97 adata.write('anndata.h5ad')
98 #end if
87 ]]></configfile> 99 ]]></configfile>
88 </configfiles> 100 </configfiles>
89 <inputs> 101 <inputs>
90 <conditional name="in"> 102 <conditional name="hd5_format">
91 <param name="adata_format" type="select" label="Format for the annotated data matrix"> 103 <param name="filetype" type="select" label="hd5 format to be created">
92 <option value="loom">Loom</option> 104 <option value="anndata" selected="true">Anndata file</option>
93 <option value="tabular">Tabular, CSV, TSV</option> 105 <option value="loom">Loom file</option>
94 <option value="mtx">Matrix Market (mtx), from Cell ranger or not</option>
95 <option value="umi_tools">UMI tools</option>
96 </param> 106 </param>
107 <when value="anndata">
108 <conditional name="in">
109 <param name="adata_format" type="select" label="Format for the annotated data matrix">
110 <option value="loom">Loom</option>
111 <option value="tabular">Tabular, CSV, TSV</option>
112 <option value="mtx">Matrix Market (mtx), from Cell ranger or not</option>
113 <option value="umi_tools">UMI tools</option>
114 </param>
115 <when value="loom">
116 <param name="input" type="data" format="loom" label="Annotated data matrix"/>
117 <param name="sparse" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Is the data matrix to read sparse?"/>
118 <param name="cleanup" type="boolean" truevalue="True" falsevalue="False" checked="false" label="Cleanup?"/>
119 <param name="x_name" type="text" value="spliced" label="X_name"/>
120 <param name="obs_names" type="text" value="CellID" label="obs_names"/>
121 <param name="var_names" type="text" value="Gene" label="var_names"/>
122 </when>
123 <when value="tabular">
124 <param name="input" type="data" format="tabular,csv,tsv" label="Annotated data matrix"/>
125 <param name="first_column_names" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Does the first column store the row names?"/>
126 </when>
127 <when value="mtx">
128 <param name="matrix" type="data" format="mtx" label="Matrix"/>
129 <conditional name="tenx">
130 <param name="use" type="select" label="Use 10x Genomics formatted mtx">
131 <option value="no">No</option>
132 <option value="legacy_10x">Output from Cell Ranger v2 or earlier versions</option>
133 <option value="v3_10x">Output from Cell Ranger v3 or later versions</option>
134 </param>
135 <when value="no"/>
136 <when value="legacy_10x">
137 <param name="genes" type="data" format="tabular" label="Genes"/>
138 <expand macro="params_10x"/>
139 </when>
140 <when value="v3_10x">
141 <param name="features" type="data" format="tabular" label="Features"/>
142 <expand macro="params_10x"/>
143 </when>
144 </conditional>
145 </when>
146 <when value="umi_tools">
147 <param name="input" type="data" format="tabular" label="condensed count matrix from UMI tools"/>
148 </when>
149 </conditional>
150 </when>
97 <when value="loom"> 151 <when value="loom">
98 <param name="input" type="data" format="loom" label="Annotated data matrix"/> 152 <param name="mainmatrix" type="data" format="tabular" label="File for main layer of loom file." help="All subsequent tsv must be the same dimensions as this file. When converted back to tsv using hd5 export, this will be labeled as 'mainmatrix.tsv'"/>
99 <param name="sparse" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Is the data matrix to read sparse?"/> 153 <param name="other_files" type="data" format="tabular" multiple="true" optional="true" label="Add layers" help="Adds layers of same dimension to the loom file. When converted to tsv using hd5 export, these layers will retain their names."/>
100 <param name="cleanup" type="boolean" truevalue="True" falsevalue="False" checked="false" label="Cleanup?"/> 154 <param name="coldata" type="data" format="tabular" label="Tsv of column data." help="First row is column attributes, subsequent are values."/>
101 <param name="x_name" type="text" value="spliced" label="X_name"/> 155 <param name="rowdata" type="data" format="tabular" label="Tsv of row data." help="First row is row attributes, subsequent are values."/>
102 <param name="obs_names" type="text" value="CellID" label="obs_names"/>
103 <param name="var_names" type="text" value="Gene" label="var_names"/>
104 </when>
105 <when value="tabular">
106 <param name="input" type="data" format="tabular,csv,tsv" label="Annotated data matrix"/>
107 <param name="first_column_names" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Does the first column store the row names?"/>
108 </when>
109 <when value="mtx">
110 <param name="matrix" type="data" format="mtx" label="Matrix"/>
111 <conditional name="tenx">
112 <param name="use" type="select" label="Use 10x Genomics formatted mtx">
113 <option value="no">No</option>
114 <option value="legacy_10x">Output from Cell Ranger v2 or earlier versions</option>
115 <option value="v3_10x">Output from Cell Ranger v3 or later versions</option>
116 </param>
117 <when value="no"/>
118 <when value="legacy_10x">
119 <param name="genes" type="data" format="tabular" label="Genes"/>
120 <expand macro="params_10x"/>
121 </when>
122 <when value="v3_10x">
123 <param name="features" type="data" format="tabular" label="Features"/>
124 <expand macro="params_10x"/>
125 </when>
126 </conditional>
127 </when>
128 <when value="umi_tools">
129 <param name="input" type="data" format="tabular" label="condensed count matrix from UMI tools"/>
130 </when> 156 </when>
131 </conditional> 157 </conditional>
132 </inputs> 158 </inputs>
133 <outputs> 159 <outputs>
134 <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="${tool.name} on ${on_string}"/> 160 <data name="anndata" format="h5ad" from_work_dir="anndata.h5ad" label="Anndata import on ${on_string}">
161 <filter>hd5_format['filetype'] == 'anndata'</filter>
162 </data>
163 <data name="loomdata" format="loom" from_work_dir="converted.loom" label="Loom import on ${on_string}">
164 <filter>hd5_format['filetype'] == 'loom'</filter>
165 </data>
135 </outputs> 166 </outputs>
136 <tests> 167 <tests>
137 <test> 168 <test expect_num_outputs="1">
138 <conditional name="in"> 169 <conditional name="in">
139 <param name="adata_format" value="loom"/> 170 <param name="adata_format" value="loom"/>
140 <param name="input" value="krumsiek11.loom" /> 171 <param name="input" value="krumsiek11.loom" />
141 <param name="sparse" value="True"/> 172 <param name="sparse" value="True"/>
142 <param name="cleanup" value="False"/> 173 <param name="cleanup" value="False"/>
152 <has_text_matching expression="obs_names='CellID'"/> 183 <has_text_matching expression="obs_names='CellID'"/>
153 <has_text_matching expression="var_names='Gene'"/> 184 <has_text_matching expression="var_names='Gene'"/>
154 </assert_stdout> 185 </assert_stdout>
155 <output name="anndata" value="import.loom.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/> 186 <output name="anndata" value="import.loom.krumsiek11.h5ad" ftype="h5ad" compare="sim_size"/>
156 </test> 187 </test>
157 <test> 188 <test expect_num_outputs="1">
158 <conditional name="in"> 189 <conditional name="in">
159 <param name="adata_format" value="tabular"/> 190 <param name="adata_format" value="tabular"/>
160 <param name="input" value="adata.csv"/> 191 <param name="input" value="adata.csv"/>
161 <param name="first_column_names" value="true"/> 192 <param name="first_column_names" value="true"/>
162 </conditional> 193 </conditional>
165 <has_text_matching expression="delimiter=','"/> 196 <has_text_matching expression="delimiter=','"/>
166 <has_text_matching expression="first_column_names=True"/> 197 <has_text_matching expression="first_column_names=True"/>
167 </assert_stdout> 198 </assert_stdout>
168 <output name="anndata" value="import.csv.h5ad" ftype="h5ad" compare="sim_size"/> 199 <output name="anndata" value="import.csv.h5ad" ftype="h5ad" compare="sim_size"/>
169 </test> 200 </test>
170 <test> 201 <test expect_num_outputs="1">
171 <conditional name="in"> 202 <conditional name="in">
172 <param name="adata_format" value="tabular"/> 203 <param name="adata_format" value="tabular"/>
173 <param name="input" value="adata.tsv"/> 204 <param name="input" value="adata.tsv"/>
174 <param name="first_column_names" value="true"/> 205 <param name="first_column_names" value="true"/>
175 </conditional> 206 </conditional>
178 <has_text_matching expression="delimiter='\\t'"/> 209 <has_text_matching expression="delimiter='\\t'"/>
179 <has_text_matching expression="first_column_names=True"/> 210 <has_text_matching expression="first_column_names=True"/>
180 </assert_stdout> 211 </assert_stdout>
181 <output name="anndata" value="import.tsv.h5ad" ftype="h5ad" compare="sim_size"/> 212 <output name="anndata" value="import.tsv.h5ad" ftype="h5ad" compare="sim_size"/>
182 </test> 213 </test>
183 <!--<test> 214 <!--<test expect_num_outputs="1">
184 <conditional name="in"> 215 <conditional name="in">
185 <param name="adata_format" value="mtx"/> 216 <param name="adata_format" value="mtx"/>
186 <param name="matrix" value="matrix_10x_v1.2.0.mtx"/> 217 <param name="matrix" value="matrix_10x_v1.2.0.mtx"/>
187 <conditional name="tenx"> 218 <conditional name="tenx">
188 <param name="use" value="no"/> 219 <param name="use" value="no"/>
218 <param name="gex_only" value="true"/> 249 <param name="gex_only" value="true"/>
219 </conditional> 250 </conditional>
220 </conditional> 251 </conditional>
221 <output name="anndata" value="import.mtx.v3_10x.h5ad" ftype="h5ad" compare="sim_size"/> 252 <output name="anndata" value="import.mtx.v3_10x.h5ad" ftype="h5ad" compare="sim_size"/>
222 </test>!--> 253 </test>!-->
223 <test> 254 <test expect_num_outputs="1">
255 <param name="filetype" value="anndata"/>
224 <conditional name="in"> 256 <conditional name="in">
225 <param name="adata_format" value="umi_tools"/> 257 <param name="adata_format" value="umi_tools"/>
226 <param name="input" value="umi_tools.tsv"/> 258 <param name="input" value="umi_tools.tsv"/>
227 </conditional> 259 </conditional>
228 <output name="anndata" value="import.umi_tools.h5ad" ftype="h5ad" compare="sim_size"/> 260 <output name="anndata" value="import.umi_tools.h5ad" ftype="h5ad" compare="sim_size"/>
261 </test>
262 <test expect_num_outputs="1">
263 <param name="filetype" value="loom"/>
264 <param name="mainmatrix" value="firstlayer.tsv"/>
265 <param name="other_files" value="secondlayer.tsv"/>
266 <param name="coldata" value="cols.tsv"/>
267 <param name="rowdata" value="rows.tsv"/>
268 <output name="loomdata" value="converted.loom.test" ftype="loom" compare="sim_size"/>
229 </test> 269 </test>
230 </tests> 270 </tests>
231 <help><![CDATA[ 271 <help><![CDATA[
232 **What it does** 272 **What it does**
233 273
234 This tool creates an AnnData dataset from several input types: 274 This tool creates an AnnData or loom dataset from several input types:
235 275
236 - Loom (`read_loom method <https://anndata.readthedocs.io/en/latest/anndata.read_loom.html>`__) 276 - Loom (`read_loom method <https://anndata.readthedocs.io/en/latest/anndata.read_loom.html>`__)
237 - Tabular (`read_csv method <https://anndata.readthedocs.io/en/latest/anndata.read_csv.html>`__) 277 - Tabular (`read_csv method <https://anndata.readthedocs.io/en/latest/anndata.read_csv.html>`__)
238 - Matrix Market (mtx), from Cell ranger or not (`read_mtx method <https://anndata.readthedocs.io/en/latest/anndata.read_mtx.html>`__) 278 - Matrix Market (mtx), from Cell ranger or not (`read_mtx method <https://anndata.readthedocs.io/en/latest/anndata.read_mtx.html>`__)
239 - UMI tools (`read_umi_tools method <https://anndata.readthedocs.io/en/latest/anndata.read_umi_tools.html>`__) 279 - UMI tools (`read_umi_tools method <https://anndata.readthedocs.io/en/latest/anndata.read_umi_tools.html>`__)
240 280
241 @HELP@ 281 @HELP@
242 ]]></help> 282 ]]></help>
243 <expand macro="citations"/> 283 <expand macro="citations"/>
244 </tool> 284 </tool>