comparison network.xml @ 0:2c289e3b566a draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/snapatac2 commit e0f59fae19e57f54ae0c351a16dd1805d12aba1d
author iuc
date Tue, 25 Nov 2025 16:39:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2c289e3b566a
1 <tool id="snapatac2_network" name="SnapATAC2 network" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
2 <description>analysis</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="xrefs"/>
7 <requirements>
8 <expand macro="requirements"/>
9 </requirements>
10 <command detect_errors="exit_code"><![CDATA[
11 gunzip -c '$motifs.fields.path' > 'input.meme' &&
12 #if $gff_file_condi.gffSource == 'cached':
13 ln -s '$gff_file_condi.gff_pre_installed.fields.path' anno.gff &&
14 #else:
15 ln -s '$gff_file_condi.gff_history' anno.gff &&
16 #end if
17 #if $fasta_file_condi.fastaSource == 'indexed':
18 zcat '$fasta_file_condi.fasta_pre_installed.fields.path' > fasta.fa &&
19 #else:
20 zcat '$fasta_file_condi.fasta_history' > fasta.fa &&
21 #end if
22 mkdir -p network_dir &&
23 cp '$adata_rna' 'anndata_rna.h5ad' &&
24 cp '$adata_atac' 'anndata_atac.h5ad' &&
25 @CMD@
26 ]]></command>
27 <configfiles>
28 <configfile name="script_file"><![CDATA[
29 @CONF_IMPORTS@
30 ## import motifs
31 from snapatac2._snapatac2 import read_motifs, PyDNAMotif
32 #if $motifs == 'cisbp':
33 @CONF_IMPORT_MEME@
34 #end if
35 rna = snap.read('anndata_rna.h5ad', backed = None)
36 atac = snap.read('anndata_atac.h5ad', backed = None)
37
38 marker_peaks = snap.tl.marker_regions(
39 atac,
40 groupby = '$groupby',
41 pvalue = $pvalue_marker
42 )
43
44
45 for cluster_id, peaks_index in marker_peaks.items():
46 print(f"Processing cluster {cluster_id} with {len(peaks_index)} peaks...")
47
48 # Convert pandas Index to list of strings
49 regions_list = peaks_index.tolist()
50
51 # Create network for this cluster
52 network = snap.tl.init_network_from_annotation(
53 regions = regions_list,
54 anno_file = 'anno.gff',
55 upstream = $upstream,
56 downstream = $downstream,
57 id_type = '$id_type',
58 coding_gene_only = $coding_gene_only
59 )
60
61 # add cor scores
62 snap.tl.add_cor_scores(
63 network,
64 gene_mat=rna,
65 peak_mat=atac,
66 select=None, # Will get available if requested by users
67 overwrite=False
68 )
69 # add regr scores
70
71 snap.tl.add_regr_scores(
72 network,
73 gene_mat=rna,
74 peak_mat=atac,
75 select=None, # Will get available if requested by users
76 method = '$method',
77 scale_X = $scale_X,
78 scale_Y = $scale_Y,
79 alpha = $alpha,
80 l1_ratio = $l1_ratio,
81 overwrite=False
82 )
83
84 # add tf binding
85 snap.tl.add_tf_binding(
86 network,
87 motifs = motifs,
88 genome_fasta = 'fasta.fa',
89 pvalue = $pvalue_tf
90 )
91
92 ## No good documentation, will get updated in next version if a tutorial is available for it
93 ## # link TF to gene
94 ## genetic_network = snap.tl.link_tf_to_gene(
95 ## network
96 ## )
97
98 # Create plot for this cluster
99 snap.pl.network_edge_stat(
100 network = network,
101 width = $width,
102 height = $height,
103 show = False,
104 interactive = False,
105 out_file = f'network_dir/plot_network_cluster_{cluster_id}.png',
106 )
107
108 ## No good documentation, will get updated in next version if a tutorial is available for it
109 ## snap.pl.network_edge_stat(
110 ## network = genetic_network,
111 ## width = $width,
112 ## height = $height,
113 ## show = False,
114 ## interactive = False,
115 ## out_file = f'network_dir/plot_genetic_network_cluster_{cluster_id}.png',
116 ## )
117 print(f"Completed cluster {cluster_id}")
118
119 print("All clusters processed!")
120 ]]></configfile>
121 </configfiles>
122 <inputs>
123 <param name="adata_rna" type="data" format="h5ad" label="Annotated data matrix containing RNA data"/>
124 <param name="adata_atac" type="data" format="h5ad" label="Annotated data matrix containing ATAC data"/>
125 <expand macro="param_groupby"/>
126 <param argument="pvalue_marker" type="float" value="0.01" label="P-value threshold to detect marker regions"/>
127 <expand macro="param_gene_anno"/>
128 <expand macro="param_genome_fasta"/>
129 <param name="upstream" type="integer" value="250000" min="0" label="Upstream extension to the transcription start site"/>
130 <param name="downstream" type="integer" value="250000" min="0" label="Downstream extension to the transcription start site"/>
131 <param name="id_type" type="select" label="ID type of the gene in the annotation file">
132 <option value="gene_name">Gene name</option>
133 <option value="gene_id">Gene ID</option>
134 <option value="transcript_id">Transcript ID</option>
135 </param>
136 <param name="coding_gene_only" type="boolean" checked="true" truevalue="True" falsevalue="False" label="Retain only coding genes in the network"/>
137 <param name="method" type="select" label="Regresson model">
138 <!-- <option value="elastic_net">elastic_net</option> has problem with sparse matrix-->
139 <option value="gb_tree">gb_tree</option>
140 </param>
141 <param name="scale_X" type="boolean" checked="false" truevalue="True" falsevalue="False" label="Whether to scale the features"/>
142 <param name="scale_Y" type="boolean" checked="false" truevalue="True" falsevalue="False" label="Whether to scale the response variable"/>
143 <param name="alpha" type="float" value="1.5" label="Constant that multiplies the penalty terms in ‘elastic_net’"/>
144 <param name="l1_ratio" type="float" min="0" max="1" value="0.5" label="L1 penalty ratio" help="If set to 0, L2 penalty is used, if set to 1, L1 penalty is used, and if set between 0 and 1, a combination of both penalties is used."/>
145 <expand macro="param_meme_table"/>
146 <param argument="pvalue_tf" type="float" value="0.01" label="P-value threshold to detect TF binding"/>
147 <expand macro="param_render_plot"/>
148 <expand macro="param_common_advanced"/>
149 </inputs>
150 <outputs>
151 <data name="hidden_output" format="txt" label="Log file" >
152 <filter>advanced_common['show_log']</filter>
153 </data>
154 <collection name="out_network" type="list" label="${tool.name} (${method}) on ${on_string} - Network">
155 <discover_datasets pattern="__name_and_ext__" directory="network_dir/"/>
156 <filter>out_file != 'svg' and out_file != 'html'</filter>
157 </collection>
158 <collection name="out_network_svg" type="list" label="${tool.name} (${method}) on ${on_string} - Network - svg">
159 <discover_datasets pattern="__name_and_ext__" directory="network_dir/"/>
160 <filter>out_file == 'svg'</filter>
161 </collection>
162 <collection name="out_network_html" type="list" label="${tool.name} (${method}) on ${on_string} - Network - html">
163 <discover_datasets pattern="__name_and_ext__" directory="network_dir/"/>
164 <filter>out_file == 'html'</filter>
165 </collection>
166 </outputs>
167 <tests>
168 <!-- metrics.frag_size_distr cached -->
169 <test expect_num_outputs="2">
170 <param name="adata_rna" location="https://zenodo.org/records/17512085/files/snap_datasets_pbmc10k_multiome_RNA.h5ad.gz"/>
171 <param name="adata_atac" location="https://zenodo.org/records/17512085/files/snap_datasets_pbmc10k_multiome_ATAC.h5ad.gz"/>
172 <param name="groupby" value="cell_type"/>
173 <param name="pvalue_marker" value="0.1"/>
174 <conditional name="gff_file_condi">
175 <param name="gffSource" value="cached"/>
176 <param name="gff_pre_installed" value="hg38"/>
177 </conditional>
178 <conditional name="fasta_file_condi">
179 <param name="fastaSource" value="indexed"/>
180 <param name="fasta_pre_installed" value="hg38"/>
181 </conditional>
182 <param name="out_file" value="png"/>
183 <expand macro="test_param_render_plot"/>
184 <section name="advanced_common">
185 <param name="show_log" value="true" />
186 </section>
187 <output name="hidden_output">
188 <assert_contents>
189 <has_text_matching expression="snap.tl.marker_regions"/>
190 <has_text_matching expression="snap.tl.init_network_from_annotation"/>
191 <has_text_matching expression="snap.tl.add_cor_scores"/>
192 <has_text_matching expression="snap.tl.add_regr_scores"/>
193 <has_text_matching expression="add_tf_binding"/>
194 <!-- <has_text_matching expression="snap.tl.link_tf_to_gene"/> -->
195 <has_text_matching expression="snap.pl.network_edge_stat"/>
196 <has_text_matching expression="groupby = 'cell_type'"/>
197 <expand macro="test_render_plot_matching_text"/>
198 </assert_contents>
199 </output>
200 <output_collection name="out_network" type="list" count="8">
201 <element name="plot_network_cluster_CD14 Mono">
202 <assert_contents>
203 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
204 <has_image_channels channels="4"/>
205 <has_image_height height="450" delta="20"/>
206 <has_image_width width="650" delta="20"/>
207 </assert_contents>
208 </element>
209 <element name="plot_network_cluster_CD16 Mono">
210 <assert_contents>
211 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
212 <has_image_channels channels="4"/>
213 <has_image_height height="450" delta="20"/>
214 <has_image_width width="650" delta="20"/>
215 </assert_contents>
216 </element>
217 <element name="plot_network_cluster_CD4 Naive">
218 <assert_contents>
219 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
220 <has_image_channels channels="4"/>
221 <has_image_height height="450" delta="20"/>
222 <has_image_width width="650" delta="20"/>
223 </assert_contents>
224 </element>
225 <element name="plot_network_cluster_CD4 TCM">
226 <assert_contents>
227 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
228 <has_image_channels channels="4"/>
229 <has_image_height height="450" delta="20"/>
230 <has_image_width width="650" delta="20"/>
231 </assert_contents>
232 </element>
233 <element name="plot_network_cluster_CD8 Naive">
234 <assert_contents>
235 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
236 <has_image_channels channels="4"/>
237 <has_image_height height="450" delta="20"/>
238 <has_image_width width="650" delta="20"/>
239 </assert_contents>
240 </element>
241 <element name="plot_network_cluster_NK">
242 <assert_contents>
243 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
244 <has_image_channels channels="4"/>
245 <has_image_height height="450" delta="20"/>
246 <has_image_width width="650" delta="20"/>
247 </assert_contents>
248 </element>
249 <element name="plot_network_cluster_Treg">
250 <assert_contents>
251 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
252 <has_image_channels channels="4"/>
253 <has_image_height height="450" delta="20"/>
254 <has_image_width width="650" delta="20"/>
255 </assert_contents>
256 </element>
257 <element name="plot_network_cluster_cDC">
258 <assert_contents>
259 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
260 <has_image_channels channels="4"/>
261 <has_image_height height="450" delta="20"/>
262 <has_image_width width="650" delta="20"/>
263 </assert_contents>
264 </element>
265 </output_collection>
266 </test>
267 <!-- metrics.frag_size_distr history -->
268 <test expect_num_outputs="2">
269 <param name="adata_rna" location="https://zenodo.org/records/17512085/files/snap_datasets_pbmc10k_multiome_RNA.h5ad.gz"/>
270 <param name="adata_atac" location="https://zenodo.org/records/17512085/files/snap_datasets_pbmc10k_multiome_ATAC.h5ad.gz"/>
271 <param name="groupby" value="cell_type"/>
272 <param name="pvalue_marker" value="0.1"/>
273 <conditional name="gff_file_condi">
274 <param name="gffSource" value="history"/>
275 <param name="gff_history" location="https://zenodo.org/records/17512085/files/chr21.gff3.gz"/>
276 </conditional>
277 <conditional name="fasta_file_condi">
278 <param name="fastaSource" value="history"/>
279 <param name="fasta_history" location="https://zenodo.org/records/17512085/files/chr21.fasta.gz"/>
280 </conditional>
281 <param name="out_file" value="png"/>
282 <expand macro="test_param_render_plot"/>
283 <section name="advanced_common">
284 <param name="show_log" value="true" />
285 </section>
286 <output name="hidden_output">
287 <assert_contents>
288 <has_text_matching expression="snap.tl.marker_regions"/>
289 <has_text_matching expression="snap.tl.init_network_from_annotation"/>
290 <has_text_matching expression="snap.tl.add_cor_scores"/>
291 <has_text_matching expression="snap.tl.add_regr_scores"/>
292 <has_text_matching expression="add_tf_binding"/>
293 <!-- <has_text_matching expression="snap.tl.link_tf_to_gene"/> -->
294 <has_text_matching expression="snap.pl.network_edge_stat"/>
295 <has_text_matching expression="groupby = 'cell_type'"/>
296 <expand macro="test_render_plot_matching_text"/>
297 </assert_contents>
298 </output>
299 <output_collection name="out_network" type="list" count="8">
300 <element name="plot_network_cluster_CD14 Mono">
301 <assert_contents>
302 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
303 <has_image_channels channels="4"/>
304 <has_image_height height="450" delta="20"/>
305 <has_image_width width="650" delta="20"/>
306 </assert_contents>
307 </element>
308 <element name="plot_network_cluster_CD16 Mono">
309 <assert_contents>
310 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
311 <has_image_channels channels="4"/>
312 <has_image_height height="450" delta="20"/>
313 <has_image_width width="650" delta="20"/>
314 </assert_contents>
315 </element>
316 <element name="plot_network_cluster_CD4 Naive">
317 <assert_contents>
318 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
319 <has_image_channels channels="4"/>
320 <has_image_height height="450" delta="20"/>
321 <has_image_width width="650" delta="20"/>
322 </assert_contents>
323 </element>
324 <element name="plot_network_cluster_CD4 TCM">
325 <assert_contents>
326 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
327 <has_image_channels channels="4"/>
328 <has_image_height height="450" delta="20"/>
329 <has_image_width width="650" delta="20"/>
330 </assert_contents>
331 </element>
332 <element name="plot_network_cluster_CD8 Naive">
333 <assert_contents>
334 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
335 <has_image_channels channels="4"/>
336 <has_image_height height="450" delta="20"/>
337 <has_image_width width="650" delta="20"/>
338 </assert_contents>
339 </element>
340 <element name="plot_network_cluster_NK">
341 <assert_contents>
342 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
343 <has_image_channels channels="4"/>
344 <has_image_height height="450" delta="20"/>
345 <has_image_width width="650" delta="20"/>
346 </assert_contents>
347 </element>
348 <element name="plot_network_cluster_Treg">
349 <assert_contents>
350 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
351 <has_image_channels channels="4"/>
352 <has_image_height height="450" delta="20"/>
353 <has_image_width width="650" delta="20"/>
354 </assert_contents>
355 </element>
356 <element name="plot_network_cluster_cDC">
357 <assert_contents>
358 <has_image_center_of_mass center_of_mass="325,225" eps="20"/>
359 <has_image_channels channels="4"/>
360 <has_image_height height="450" delta="20"/>
361 <has_image_width width="650" delta="20"/>
362 </assert_contents>
363 </element>
364 </output_collection>
365 </test>
366 </tests>
367 <help><![CDATA[
368 Build CRE-gene network from gene annotations, using `SnapATAC2`
369 ===============================================================
370
371 Link CREs to genes if they are close to genes’ promoter regions.
372
373 More details on the `SnapATAC2 documentation
374 <https://scverse.org/SnapATAC2/api/_autosummary/snapatac2.tl.init_network_from_annotation.html>`__
375
376
377 Compute correlation scores for any two connected nodes in the network.
378
379 More details on the `SnapATAC2 documentation
380 <https://scverse.org/SnapATAC2/api/_autosummary/snapatac2.tl.add_cor_scores.html>`__
381
382
383 Perform regression analysis for nodes and their parents in the network.
384
385 More details on the `SnapATAC2 documentation
386 <https://scverse.org/SnapATAC2/api/_autosummary/snapatac2.tl.add_regr_scores.html>`__
387
388
389 Add TF motif binding information.
390
391 More details on the `SnapATAC2 documentation
392 <https://scverse.org/SnapATAC2/api/_autosummary/snapatac2.tl.add_tf_binding.html>`__
393
394 ]]></help>
395 <expand macro="citations"/>
396 </tool>
397