Mercurial > repos > iuc > sceasy_convert
comparison sceasy.xml @ 0:d70139524747 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/sceasy/ commit e83761e8057df5ce516fc6681636435078c81534
author | iuc |
---|---|
date | Fri, 10 Nov 2023 20:24:21 +0000 |
parents | |
children | 2062be7efc84 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d70139524747 |
---|---|
1 <tool id="sceasy_convert" name="SCEasy Converter" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05"> | |
2 <description> | |
3 Convert between common single cell formats | |
4 </description> | |
5 <macros> | |
6 <token name="@TOOL_VERSION@">0.0.7</token> | |
7 <token name="@VERSION_SUFFIX@">1</token> | |
8 <macro name="mac_input_form" token_format="@FORMAT@" > | |
9 <param name="input_object_file" type="data" format="@FORMAT@" label="Input object in @FORMAT@ format"/> | |
10 </macro> | |
11 </macros> | |
12 <requirements> | |
13 <requirement type="package" version="0.0.7">r-sceasy</requirement> | |
14 <requirement type="package" version="3.0.6" >loompy</requirement> | |
15 <requirement type="package" version="0.10.0" >anndata</requirement> | |
16 <requirement type="package" version="3.10" >python</requirement> | |
17 <requirement type="package" version="0.7.5.4" >r-anndata</requirement> | |
18 <requirement type="package" version="1.32.0" >r-reticulate</requirement> | |
19 </requirements> | |
20 <command detect_errors="exit_code"> | |
21 Rscript '$script_file' | |
22 </command> | |
23 <configfiles> | |
24 <configfile name="script_file"><![CDATA[ | |
25 direction='$conversion.direction' | |
26 tokens = unlist(strsplit(direction, split="2")) | |
27 format.from = tokens[1] | |
28 format.to = tokens[2] | |
29 | |
30 library(sceasy) | |
31 library(reticulate) | |
32 | |
33 ## HACK: CI biocontainers do not contain a useable conda binary, just the env. | |
34 ## see: https://github.com/galaxyproject/tools-iuc/issues/5585#issuecomment-1803773923 | |
35 is_biocontainer = grepl("^# cmd: /opt/conda/bin/", | |
36 paste0(reticulate:::python_info_condaenv_find("/usr/local/"), | |
37 "-none")) | |
38 if (is_biocontainer) { | |
39 ## conda detection false positive | |
40 assignInNamespace("is_conda_python", function(x) FALSE, ns="reticulate") | |
41 use_python("/usr/local/bin/python") | |
42 } else { | |
43 conda_path = Sys.getenv("CONDA_PREFIX") | |
44 if (conda_path != "") { | |
45 ## Active conda env found | |
46 use_python(file.path(conda_path, "bin", "python3")) | |
47 } else { | |
48 ## Not biocontainer or conda, assume system python | |
49 use_python("/usr/bin/python3") | |
50 } | |
51 } | |
52 loompy = reticulate::import('loompy') | |
53 infile = '$input_object_file' | |
54 | |
55 outfile_ext_map=list( | |
56 "anndata" = "h5ad", | |
57 "seurat" = "rds", | |
58 "sce" = "rds", | |
59 "cds" = "rds", | |
60 "loom" = "loom") ## this has to be a .loom ending for the export to work. | |
61 | |
62 outfile = paste0("outfile.", outfile_ext_map[format.to]) | |
63 | |
64 | |
65 ## IDIOSYNCRACIES: | |
66 ## Some input formats need be loaded first and then converted, | |
67 ## and other formats need to be specified as filenames only, | |
68 ## and even then as formats with specific extensions, | |
69 ## and some formats need to be objects, or stripped down objects, | |
70 ## and probably more issues will be discovered in time. | |
71 | |
72 do_infile_as_first_arg = as.logical(direction == "loom2sce") | |
73 do_filename_as_first_arg = as.logical(direction %in% c("anndata2cds", "anndata2seurat", "loom2anndata")) | |
74 do_dietseurat_in_first_arg = as.logical(direction == "seurat2sce") | |
75 | |
76 if (do_infile_as_first_arg) { | |
77 if (format.from == "loom") { | |
78 ## LoomExperiment::import only correctly imports when ext is set | |
79 loom_file = tempfile(tmpdir="/tmp", fileext=".loom") | |
80 file.copy(from=infile, to=loom_file) ## rename doesn't work in containers | |
81 infile = loom_file | |
82 } | |
83 convertFormat(inFile = infile, from = format.from, to = format.to, outFile = outfile) | |
84 } else if (do_filename_as_first_arg) { | |
85 convertFormat(infile, from = format.from, to = format.to, outFile = outfile) | |
86 } else { | |
87 ## We need to physically load the object (either Seurat or SCE, both which should be | |
88 ## of RDS input type) | |
89 rds = readRDS(infile) | |
90 | |
91 if (do_dietseurat_in_first_arg){ | |
92 library(Seurat) | |
93 rds = DietSeurat(rds) | |
94 } | |
95 convertFormat(rds, from = format.from, to = format.to, outFile = outfile) | |
96 } | |
97 | |
98 ]]></configfile> | |
99 </configfiles> | |
100 <inputs> | |
101 <conditional name="conversion" > | |
102 <param name="direction" type="select" label="Convert From / To" > | |
103 <option value="anndata2cds" >AnnData to CellDataSet</option> | |
104 <option value="anndata2seurat" >AnnData to Seurat</option> | |
105 <option value="loom2anndata" >Loom to AnnData</option> | |
106 <option value="loom2sce">Loom to SingleCellexperiment</option> | |
107 <option value="sce2anndata" >SingleCellexperiment to AnnData</option> | |
108 <option value="sce2loom" >SingleCellexperiment to Loom</option> | |
109 <option value="seurat2anndata">Seurat to AnnData</option> | |
110 <option value="seurat2sce" >Seurat to SingleCellexperiment</option> | |
111 </param> | |
112 <when value="anndata2cds" > | |
113 <expand macro="mac_input_form" token_format="h5ad" /> | |
114 </when> | |
115 <when value="anndata2seurat" > | |
116 <expand macro="mac_input_form" token_format="h5ad" /> | |
117 </when> | |
118 <when value="loom2anndata"> | |
119 <expand macro="mac_input_form" token_format="h5" /> | |
120 </when> | |
121 <when value="loom2sce"> | |
122 <expand macro="mac_input_form" token_format="h5" /> | |
123 </when> | |
124 <when value="sce2anndata"> | |
125 <expand macro="mac_input_form" token_format="sce" /> | |
126 </when> | |
127 <when value="sce2loom"> | |
128 <expand macro="mac_input_form" token_format="sce" /> | |
129 </when> | |
130 <when value="seurat2anndata"> | |
131 <expand macro="mac_input_form" token_format="rds" /> | |
132 </when> | |
133 <when value="seurat2sce"> | |
134 <expand macro="mac_input_form" token_format="rds" /> | |
135 </when> | |
136 </conditional> | |
137 </inputs> | |
138 <outputs> | |
139 <data name="output_sce" format="rdata" from_work_dir="outfile.rds" label="${tool.name} on ${on_string}: SingleCellExperiment"> | |
140 <filter> | |
141 conversion['direction'].endswith('sce') | |
142 </filter> | |
143 </data> | |
144 <data name="output_cds" format="rdata" from_work_dir="outfile.rds" label="${tool.name} on ${on_string}: CellDataSet"> | |
145 <filter> | |
146 conversion['direction'].endswith('cds') | |
147 </filter> | |
148 </data> | |
149 <data name="output_loom" format="h5" from_work_dir="outfile.loom" label="${tool.name} on ${on_string}: Loom"> | |
150 <filter> | |
151 conversion['direction'].endswith('loom') | |
152 </filter> | |
153 </data> | |
154 <data name="output_anndata" format="h5" from_work_dir="outfile.h5ad" label="${tool.name} on ${on_string}: AnnData"> | |
155 <filter> | |
156 conversion['direction'].endswith('anndata') | |
157 </filter> | |
158 </data> | |
159 <data name="output_seurat" format="rdata" from_work_dir="outfile.rds" label="${tool.name} on ${on_string}: Seurat"> | |
160 <filter> | |
161 conversion['direction'].endswith('seurat') | |
162 </filter> | |
163 </data> | |
164 </outputs> | |
165 <tests> | |
166 <test expect_num_outputs="1"> | |
167 <param name="direction" value="anndata2cds"/> | |
168 <param name="input_object_file" value="test_anndata.h5ad"/> | |
169 <output name="output_cds" file="ad2cds.rds" ftype="rdata" compare="sim_size"/> | |
170 </test> | |
171 <test expect_num_outputs="1"> | |
172 <param name="direction" value="anndata2seurat"/> | |
173 <param name="input_object_file" value="test_anndata.h5ad"/> | |
174 <output name="output_seurat" file="ad2seurat.rds" ftype="rdata" compare="sim_size"/> | |
175 </test> | |
176 <test expect_num_outputs="1"> | |
177 <param name="direction" value="loom2anndata"/> | |
178 <param name="input_object_file" value="sce2loom.rds"/> | |
179 <output name="output_anndata" file="loom2anndata.h5ad" ftype="h5" compare="sim_size"/> | |
180 </test> | |
181 <test expect_num_outputs="1"> | |
182 <param name="direction" value="loom2sce"/> | |
183 <param name="input_object_file" value="sce2loom.rds"/> | |
184 <output name="output_sce" file="loom2sce.rds" ftype="rdata" compare="sim_size"/> | |
185 </test> | |
186 <test expect_num_outputs="1"> | |
187 <param name="direction" value="sce2anndata"/> | |
188 <param name="input_object_file" value="test_sce.rds"/> | |
189 <output name="output_anndata" file="sce2anndata.h5ad" ftype="h5" compare="sim_size"/> | |
190 </test> | |
191 <test expect_num_outputs="1"> | |
192 <param name="direction" value="sce2loom"/> | |
193 <param name="input_object_file" value="test_sce.rds"/> | |
194 <output name="output_loom" file="sce2loom.rds" ftype="h5" compare="sim_size"/> | |
195 </test> | |
196 <test expect_num_outputs="1"> | |
197 <param name="direction" value="seurat2anndata"/> | |
198 <param name="input_object_file" value="test_seurat.rds"/> | |
199 <output name="output_seurat" file="test_anndata.h5ad" ftype="h5" compare="sim_size"/> | |
200 </test> | |
201 <test expect_num_outputs="1"> | |
202 <param name="direction" value="seurat2sce"/> | |
203 <param name="input_object_file" value="test_seurat.rds"/> | |
204 <output name="output_sce" file="test_sce.rds" ftype="rdata" compare="sim_size"/> | |
205 </test> | |
206 </tests> | |
207 <help> | |
208 SCeasy | |
209 ====== | |
210 | |
211 Convert scRNA data object between formats `sceasy::convertFormat()` | |
212 | |
213 Supports the following conversion: | |
214 | |
215 .. image:: $PATH_TO_IMAGES/conv.png | |
216 :width: 80 % | |
217 :align: center | |
218 | |
219 | |
220 </help> | |
221 <citations> | |
222 <citation type="doi"> doi:10.1093/nargab/lqaa052</citation> | |
223 </citations> | |
224 </tool> |