comparison plot.xml @ 0:8b9b8d358883 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/liana commit 8dc656081d3147b402485bd25affe05a22e5194e
author iuc
date Tue, 10 Mar 2026 13:41:01 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b9b8d358883
1 <tool id="liana_plot" name="Liana Plot" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
2 <description>visualize ligand-receptor interactions</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="bio_tools"/>
7 <expand macro="creators"/>
8 <expand macro="requirements"/>
9 <expand macro="version_command"/>
10 <command detect_errors="exit_code"><![CDATA[
11 #if str($method.method) in ['pl.target_metrics', 'pl.contributions', 'pl.interactions']:
12 cp '$method.mdata' 'misty.h5mu' &&
13 #else:
14 cp '$method.adata' 'anndata.h5ad' &&
15 #end if
16 cat '$script_file' > '$hidden_output' &&
17 python '$script_file' >> '$hidden_output' &&
18 ls . >> '$hidden_output' &&
19 touch 'anndata_info.txt' &&
20 cat 'anndata_info.txt' @CMD_PRETTIFY_STDOUT@
21 ]]></command>
22 <configfiles>
23 <configfile name="script_file"><![CDATA[
24 @CMD_IMPORTS@
25 import mudata as mu
26 if os.path.exists("misty.h5mu"):
27 import mudata as mu
28 mdata = mu.read_h5mu("misty.h5mu")
29 # Wrap MuData into LIANA MistyData (this is what plotting expects)
30 else:
31 adata = sc.read_h5ad('anndata.h5ad')
32
33
34 #if str($method.method) == 'pl.dotplot':
35 fig = li.plotting.dotplot(
36 adata=adata,
37 uns_key='$method.uns_key',
38 #if str($method.colour) != '':
39 colour='$method.colour',
40 #end if
41 #if str($method.size) != '':
42 size='$method.size',
43 #end if
44 @CMD_PLOT_SOURCE_TARGET_LABELS@
45 @CMD_PLOT_LIGAND_RECEPTOR_COMPLEX@
46 @CMD_PLOT_TOP_N_ORDERBY@
47 inverse_colour=$method.inverse_colour,
48 inverse_size=$method.inverse_size,
49 cmap='$method.cmap',
50 size_range=($method.size_range_min, $method.size_range_max),
51 figure_size=($method.figure_size_width, $method.figure_size_height),
52 return_fig=True)
53
54 #else if str($method.method) == 'pl.dotplot_by_sample':
55 fig = li.plotting.dotplot_by_sample(
56 adata=adata,
57 uns_key='$method.uns_key',
58 sample_key='$method.sample_key',
59 #if str($method.colour) != '':
60 colour='$method.colour',
61 #end if
62 #if str($method.size) != '':
63 size='$method.size',
64 #end if
65 @CMD_PLOT_SOURCE_TARGET_LABELS@
66 @CMD_PLOT_LIGAND_RECEPTOR_COMPLEX@
67 inverse_colour=$method.inverse_colour,
68 inverse_size=$method.inverse_size,
69 cmap='$method.cmap',
70 size_range=($method.size_range_min, $method.size_range_max),
71 figure_size=($method.figure_size_width, $method.figure_size_height),
72 return_fig=True)
73
74 #else if str($method.method) == 'pl.tileplot':
75 fig = li.plotting.tileplot(
76 adata=adata,
77 uns_key='$method.uns_key',
78 #if str($method.fill) != '':
79 fill='$method.fill',
80 #end if
81 #if str($method.label) != '':
82 label='$method.label',
83 #end if
84 @CMD_PLOT_SOURCE_TARGET_LABELS@
85 @CMD_PLOT_LIGAND_RECEPTOR_COMPLEX@
86 @CMD_PLOT_TOP_N_ORDERBY@
87 #if str($method.source_title) != '':
88 source_title='$method.source_title',
89 #end if
90 #if str($method.target_title) != '':
91 target_title='$method.target_title',
92 #end if
93 cmap='$method.cmap',
94 label_size=$method.label_size,
95 figure_size=($method.figure_size_width, $method.figure_size_height),
96 return_fig=True)
97
98 #else if str($method.method) == 'pl.connectivity':
99 fig = li.plotting.connectivity(
100 adata=adata,
101 idx=$method.idx,
102 spatial_key='$method.spatial_key',
103 connectivity_key='$method.connectivity_key',
104 size=$method.size,
105 figure_size=($method.figure_size_width, $method.figure_size_height),
106 return_fig=True)
107
108 #else if str($method.method) == 'pl.target_metrics':
109 fig = li.plotting.target_metrics(
110 misty=mdata,
111 #if str($method.key) != '':
112 key='$method.key',
113 #end if
114 #if str($method.stat) != '':
115 stat='$method.stat',
116 #end if
117 #if str($method.top_n) != '':
118 top_n=$method.top_n,
119 #end if
120 ascending=$method.ascending,
121 figure_size=($method.figure_size_width, $method.figure_size_height),
122 return_fig=True)
123
124 #else if str($method.method) == 'pl.contributions':
125 fig = li.plotting.contributions(
126 misty=mdata,
127 #if str($method.key) != '':
128 key='$method.key',
129 #end if
130 #if str($method.view_names) != '':
131 view_names=[x.strip() for x in '$method.view_names'.split(',')],
132 #end if
133 figure_size=($method.figure_size_width, $method.figure_size_height),
134 return_fig=True)
135
136 #else if str($method.method) == 'pl.interactions':
137 fig = li.plotting.interactions(
138 misty=mdata,
139 #if str($method.key) != '':
140 key='$method.key',
141 #end if
142 #if str($method.view) != '':
143 view='$method.view',
144 #end if
145 #if str($method.top_n) != '':
146 top_n=$method.top_n,
147 #end if
148 ascending=$method.ascending,
149 figure_size=($method.figure_size_width, $method.figure_size_height),
150 return_fig=True)
151 #end if
152
153 ## Save the figure
154 fig.save('plot.$format', dpi=150)
155
156 ]]>
157 </configfile>
158 </configfiles>
159 <inputs>
160 <param name="format" type="select" label="Format for saving figure">
161 <option value="png" selected="true">png</option>
162 <option value="pdf">pdf</option>
163 <option value="svg">svg</option>
164 </param>
165 <conditional name="method">
166 <param argument="method" type="select" label="Plotting method">
167 <option value="pl.dotplot">Dotplot: Interactions by source and target cells (dotplot)</option>
168 <option value="pl.dotplot_by_sample">Dotplot by sample: Interactions grouped by sample (dotplot_by_sample)</option>
169 <option value="pl.tileplot">Tileplot: Interactions as tiles by source and target (tileplot)</option>
170 <option value="pl.connectivity">Connectivity: Spatial connectivity weights (connectivity)</option>
171 <option value="pl.target_metrics">MISTy Target Metrics: Plot target metrics from MISTy results (target_metrics)</option>
172 <option value="pl.contributions">MISTy Contributions: Plot view contributions per target (contributions)</option>
173 <option value="pl.interactions">MISTy Interactions: Plot interaction importances (interactions)</option>
174 </param>
175 <when value="pl.dotplot">
176 <expand macro="inputs_anndata"/>
177 <expand macro="param_uns_key"/>
178 <expand macro="param_plot_colour"/>
179 <expand macro="param_plot_size"/>
180 <expand macro="param_source_labels"/>
181 <expand macro="param_target_labels"/>
182 <expand macro="param_ligand_complex"/>
183 <expand macro="param_receptor_complex"/>
184 <expand macro="param_top_n"/>
185 <expand macro="param_orderby"/>
186 <expand macro="param_orderby_ascending"/>
187 <expand macro="param_orderby_absolute"/>
188 <expand macro="param_inverse_colour"/>
189 <expand macro="param_inverse_size"/>
190 <expand macro="param_cmap"/>
191 <expand macro="param_size_range"/>
192 <expand macro="param_figure_size"/>
193 </when>
194 <when value="pl.dotplot_by_sample">
195 <expand macro="inputs_anndata"/>
196 <expand macro="param_uns_key"/>
197 <expand macro="param_sample_key" VALUE="sample"/>
198 <expand macro="param_plot_colour"/>
199 <expand macro="param_plot_size"/>
200 <expand macro="param_source_labels"/>
201 <expand macro="param_target_labels"/>
202 <expand macro="param_ligand_complex"/>
203 <expand macro="param_receptor_complex"/>
204 <expand macro="param_inverse_colour"/>
205 <expand macro="param_inverse_size"/>
206 <expand macro="param_cmap"/>
207 <expand macro="param_size_range"/>
208 <expand macro="param_figure_size"/>
209 </when>
210 <when value="pl.tileplot">
211 <expand macro="inputs_anndata"/>
212 <expand macro="param_uns_key"/>
213 <param argument="fill" type="text" value="" optional="true" label="Fill by column" help="Column in liana_res for tile color. E.g., 'magnitude_rank', 'specificity_rank', or p-value columns.">
214 <expand macro="sanitize_query"/>
215 </param>
216 <param argument="label" type="text" value="" optional="true" label="Label by column" help="Column in liana_res to display inside tiles (e.g., 'lr_names', 'magnitude_rank').">
217 <expand macro="sanitize_query"/>
218 </param>
219 <expand macro="param_source_labels"/>
220 <expand macro="param_target_labels"/>
221 <expand macro="param_ligand_complex"/>
222 <expand macro="param_receptor_complex"/>
223 <expand macro="param_top_n"/>
224 <expand macro="param_orderby"/>
225 <expand macro="param_orderby_ascending"/>
226 <expand macro="param_orderby_absolute"/>
227 <param argument="source_title" type="text" value="" optional="true" label="Source axis title" help="Custom title for sender/source cell types axis. Default: 'Source'.">
228 <expand macro="sanitize_query"/>
229 </param>
230 <param argument="target_title" type="text" value="" optional="true" label="Target axis title" help="Custom title for receiver/target cell types axis. Default: 'Target'.">
231 <expand macro="sanitize_query"/>
232 </param>
233 <expand macro="param_cmap"/>
234 <param argument="label_size" type="integer" value="12" min="1" label="Label text size" help="Font size for labels in tiles. Default: 12.">
235 </param>
236 <expand macro="param_figure_size" width="5" height="5"/>
237 </when>
238 <when value="pl.connectivity">
239 <expand macro="inputs_anndata"/>
240 <param argument="idx" type="integer" value="0" min="0" label="Cell index" help="Index of the cell to plot connectivity for."/>
241 <param argument="spatial_key" type="text" value="spatial" label="Spatial key" help="Key in adata.obsm that contains the spatial coordinates.">
242 <expand macro="sanitize_query"/>
243 </param>
244 <param argument="connectivity_key" type="text" value="spatial_connectivities" label="Connectivity key" help="Key in adata.obsp that contains the spatial connectivity matrix.">
245 <expand macro="sanitize_query"/>
246 </param>
247 <param argument="size" type="float" value="1" min="0" label="Point size" help="Size of the points."/>
248 <expand macro="param_figure_size" width="5.4" height="5"/>
249 </when>
250 <when value="pl.target_metrics">
251 <param name="mdata" type="data" format="h5mu" optional="true" label="MISTy (MuData .h5mu) file" help="" />
252 <expand macro="param_misty_key"/>
253 <param argument="stat" type="select" optional="true" label="Statistic to plot" help="Target metric to visualize. gain_R2: improvement from multi-view; intra_R2: intra-view variance explained; multi_R2: total variance explained.">
254 <option value="">-- Select statistic --</option>
255 <option value="gain_R2">gain_R2 - R² gain from spatial context</option>
256 <option value="intra_R2">intra_R2 - Intra-view R²</option>
257 <option value="multi_R2">multi_R2 - Total multi-view R²</option>
258 <option value="p_value">p_value - Statistical significance</option>
259 </param>
260 <param argument="top_n" type="integer" value="" optional="true" min="1" label="Top N targets" help="Number of top targets to display. Empty = all targets.">
261 </param>
262 <param argument="ascending" type="boolean" truevalue="True" falsevalue="False" checked="false" label="Sort ascending" help="If enabled: sort by increasing values. If disabled: sort by decreasing values (default, shows highest ranking first).">
263 </param>
264 <expand macro="param_figure_size" width="5" height="5"/>
265 </when>
266 <when value="pl.contributions">
267 <param name="mdata" type="data" format="h5mu" optional="true" label="MISTy (MuData .h5mu) file" help="" />
268 <expand macro="param_misty_key"/>
269 <param argument="view_names" type="text" value="" optional="true" label="Views to include" help="Comma-separated view names (intra, juxta, para) to plot. Empty = all views. Useful for focusing on specific spatial scales.">
270 <expand macro="sanitize_query"/>
271 </param>
272 <expand macro="param_figure_size" width="5" height="5"/>
273 </when>
274 <when value="pl.interactions">
275 <param name="mdata" type="data" format="h5mu" optional="true" label="MISTy (MuData .h5mu) file" help="" />
276 <expand macro="param_misty_key"/>
277 <param argument="view" type="text" value="" optional="true" label="View name" help="Specific view (e.g., 'intra', 'juxta', 'para') to visualize interaction importances. Empty = combined importance across all views.">
278 <expand macro="sanitize_query"/>
279 </param>
280 <param argument="top_n" type="integer" value="" optional="true" min="1" label="Top N interactions" help="Number of top interactions to display. Empty = show all.">
281 </param>
282 <param argument="ascending" type="boolean" truevalue="True" falsevalue="False" checked="false" label="Sort ascending" help="If enabled: smallest to largest. If disabled: largest to smallest (default, shows most important first).">
283 </param>
284 <expand macro="param_figure_size" width="5" height="5"/>
285 </when>
286 </conditional>
287 <expand macro="inputs_common_advanced"/>
288 </inputs>
289 <outputs>
290 <data name="out_png" format="png" from_work_dir="plot.png" label="${tool.name} (${method.method}) on ${on_string}: PNG">
291 <filter>format == 'png'</filter>
292 </data>
293 <data name="out_pdf" format="pdf" from_work_dir="plot.pdf" label="${tool.name} (${method.method}) on ${on_string}: PDF">
294 <filter>format == 'pdf'</filter>
295 </data>
296 <data name="out_svg" format="svg" from_work_dir="plot.svg" label="${tool.name} (${method.method}) on ${on_string}: SVG">
297 <filter>format == 'svg'</filter>
298 </data>
299 <data name="hidden_output" format="txt" label="Log file">
300 <filter>advanced_common['show_log']</filter>
301 </data>
302 </outputs>
303 <tests>
304 <!-- 1) dotplot -> PNG -->
305 <test expect_num_outputs="2">
306 <param name="format" value="png"/>
307 <conditional name="method">
308 <param name="method" value="pl.dotplot"/>
309 <param name="adata" location="https://zenodo.org/records/18388645/files/pbmc_liana_results.h5ad"/>
310 <param name="uns_key" value="liana_res"/>
311 <param name="colour" value="magnitude_rank"/>
312 <param name="size" value="specificity_rank"/>
313 <param name="inverse_colour" value="true"/>
314 <param name="inverse_size" value="true"/>
315 <param name="cmap" value="viridis"/>
316 <param name="size_range_min" value="1"/>
317 <param name="size_range_max" value="5"/>
318 <param name="figure_size_width" value="8"/>
319 <param name="figure_size_height" value="6"/>
320 </conditional>
321 <section name="advanced_common">
322 <param name="show_log" value="true"/>
323 </section>
324 <output name="out_png" ftype="png">
325 <assert_contents>
326 <has_size size="390000" delta="150000"/>
327 </assert_contents>
328 </output>
329 <output name="hidden_output">
330 <assert_contents>
331 <has_text_matching expression="li.plotting.dotplot"/>
332 </assert_contents>
333 </output>
334 </test>
335 <!-- 2) dotplot_by_sample -> PDF -->
336 <test expect_num_outputs="2">
337 <param name="format" value="pdf"/>
338 <conditional name="method">
339 <param name="method" value="pl.dotplot_by_sample"/>
340 <param name="adata" location="https://zenodo.org/records/18388645/files/multi_sample_test.h5ad"/>
341 <param name="uns_key" value="liana_res"/>
342 <param name="sample_key" value="sample"/>
343 <param name="colour" value="magnitude_rank"/>
344 <param name="size" value="specificity_rank"/>
345 <param name="inverse_colour" value="true"/>
346 <param name="inverse_size" value="true"/>
347 <param name="cmap" value="viridis"/>
348 <param name="size_range_min" value="1"/>
349 <param name="size_range_max" value="5"/>
350 <param name="figure_size_width" value="8"/>
351 <param name="figure_size_height" value="6"/>
352 </conditional>
353 <section name="advanced_common">
354 <param name="show_log" value="true"/>
355 </section>
356 <output name="out_pdf" ftype="pdf">
357 <assert_contents>
358 <has_size size="280000" delta="100000"/>
359 </assert_contents>
360 </output>
361 <output name="hidden_output">
362 <assert_contents>
363 <has_text_matching expression="li.plotting.dotplot_by_sample"/>
364 </assert_contents>
365 </output>
366 </test>
367 <!-- 3) tileplot -> SVG -->
368 <test expect_num_outputs="2">
369 <param name="format" value="svg"/>
370 <conditional name="method">
371 <param name="method" value="pl.tileplot"/>
372 <param name="adata" location="https://zenodo.org/records/18388645/files/pbmc_liana_results.h5ad"/>
373 <param name="uns_key" value="liana_res"/>
374 <param name="fill" value="magnitude_rank"/>
375 <param name="label" value="magnitude_rank"/>
376 <param name="top_n" value="15"/>
377 <param name="orderby" value="magnitude_rank"/>
378 <param name="orderby_ascending" value="true"/>
379 <param name="cmap" value="viridis"/>
380 <param name="label_size" value="10"/>
381 <param name="figure_size_width" value="6"/>
382 <param name="figure_size_height" value="6"/>
383 </conditional>
384 <section name="advanced_common">
385 <param name="show_log" value="true"/>
386 </section>
387 <output name="out_svg" ftype="svg">
388 <assert_contents>
389 <has_size size="3300000" delta="1000000"/>
390 </assert_contents>
391 </output>
392 <output name="hidden_output">
393 <assert_contents>
394 <has_text_matching expression="li.plotting.tileplot"/>
395 </assert_contents>
396 </output>
397 </test>
398 <!-- 4) connectivity -> PNG -->
399 <test expect_num_outputs="2">
400 <param name="format" value="png"/>
401 <conditional name="method">
402 <param name="method" value="pl.connectivity"/>
403 <param name="adata" location="https://zenodo.org/records/18388645/files/spatial_small.h5ad"/>
404 <param name="idx" value="0"/>
405 <param name="spatial_key" value="spatial"/>
406 <param name="connectivity_key" value="spatial_connectivities"/>
407 <param name="size" value="1.5"/>
408 <param name="figure_size_width" value="6"/>
409 <param name="figure_size_height" value="5"/>
410 </conditional>
411 <section name="advanced_common">
412 <param name="show_log" value="true"/>
413 </section>
414 <output name="out_png" ftype="png">
415 <assert_contents>
416 <has_size size="56000" delta="40000"/>
417 </assert_contents>
418 </output>
419 <output name="hidden_output">
420 <assert_contents>
421 <has_text_matching expression="li.plotting.connectivity"/>
422 </assert_contents>
423 </output>
424 </test>
425 <!-- 5) MISTy target_metrics -> PDF -->
426 <test expect_num_outputs="2">
427 <param name="format" value="pdf"/>
428 <conditional name="method">
429 <param name="method" value="pl.target_metrics"/>
430 <param name="mdata" location="https://zenodo.org/records/18388645/files/genericMistyData_rf.h5mu"/>
431 <param name="stat" value="gain_R2"/>
432 <param name="ascending" value="false"/>
433 <param name="figure_size_width" value="5"/>
434 <param name="figure_size_height" value="5"/>
435 </conditional>
436 <section name="advanced_common">
437 <param name="show_log" value="true"/>
438 </section>
439 <output name="out_pdf" ftype="pdf">
440 <assert_contents>
441 <has_size size="17186" delta="5000"/>
442 </assert_contents>
443 </output>
444 <output name="hidden_output">
445 <assert_contents>
446 <has_text_matching expression="li.plotting.target_metrics"/>
447 </assert_contents>
448 </output>
449 </test>
450 <!-- 6) MISTy contributions -> SVG -->
451 <test expect_num_outputs="2">
452 <param name="format" value="svg"/>
453 <conditional name="method">
454 <param name="method" value="pl.contributions"/>
455 <param name="mdata" location="https://zenodo.org/records/18388645/files/genericMistyData_rf.h5mu"/>
456 <param name="view_names" value="intra,juxta,para"/>
457 <param name="figure_size_width" value="5"/>
458 <param name="figure_size_height" value="5"/>
459 </conditional>
460 <section name="advanced_common">
461 <param name="show_log" value="true"/>
462 </section>
463 <output name="out_svg" ftype="svg">
464 <assert_contents>
465 <has_size size="58175" delta="10000"/>
466 </assert_contents>
467 </output>
468 <output name="hidden_output">
469 <assert_contents>
470 <has_text_matching expression="li.plotting.contributions"/>
471 </assert_contents>
472 </output>
473 </test>
474 <!-- 7) MISTy interactions -> PNG -->
475 <test expect_num_outputs="2">
476 <param name="format" value="png"/>
477 <conditional name="method">
478 <param name="method" value="pl.interactions"/>
479 <param name="mdata" location="https://zenodo.org/records/18388645/files/genericMistyData_rf.h5mu"/>
480 <param name="view" value="para"/>
481 <param name="top_n" value="20"/>
482 <param name="ascending" value="false"/>
483 <param name="figure_size_width" value="5"/>
484 <param name="figure_size_height" value="5"/>
485 </conditional>
486 <section name="advanced_common">
487 <param name="show_log" value="true"/>
488 </section>
489 <output name="out_png" ftype="png">
490 <assert_contents>
491 <has_size size="52184" delta="8000"/>
492 </assert_contents>
493 </output>
494 <output name="hidden_output">
495 <assert_contents>
496 <has_text_matching expression="li.plotting.interactions"/>
497 </assert_contents>
498 </output>
499 </test>
500 </tests>
501 <help><![CDATA[
502 Liana Plotting Tools
503 ====================
504
505 This tool provides visualization methods for LIANA ligand-receptor analysis results.
506
507 Available Methods
508 -----------------
509
510 **dotplot**
511 Create a dotplot of interactions by source and target cells. The dot size and color
512 can be mapped to different columns in the LIANA results (e.g., expression magnitude,
513 specificity scores).
514
515 **dotplot_by_sample**
516 Create a dotplot of interactions grouped by sample. Useful for comparing interactions
517 across different conditions or samples.
518
519 **tileplot**
520 Create a tileplot showing interactions as tiles organized by source and target cells.
521 The fill color and labels can be customized.
522
523 **connectivity**
524 Plot spatial connectivity weights for a specific cell. Requires spatial data with
525 connectivity information computed.
526
527 **target_metrics** (MISTy)
528 Plot target metrics from MISTy spatial modelling results. Shows statistics like
529 R² gain, intra R², multi R², or p-values for each target.
530
531 **contributions** (MISTy)
532 Plot view contributions per target from MISTy results. Shows how different spatial
533 views contribute to explaining each target variable.
534
535 **interactions** (MISTy)
536 Plot interaction importances from MISTy results. Shows the importance of predictor
537 variables for explaining targets within a specific view.
538
539 Common Parameters
540 -----------------
541
542 **uns_key**
543 Key in adata.uns that contains the LIANA results. Default is 'liana_res'.
544
545 **colour / size**
546 Columns in liana_res to define the color and size of dots/tiles.
547 Common options include: 'magnitude_rank', 'specificity_rank', 'lr_means', etc.
548
549 **source_labels / target_labels**
550 Filter interactions to only show specific source or target cell types.
551
552 **ligand_complex / receptor_complex**
553 Filter interactions to only show specific ligand or receptor complexes.
554
555 **top_n / orderby**
556 Show only the top N interactions, ordered by a specific column.
557
558 **inverse_colour / inverse_size**
559 Apply -log10 transformation to the colour/size values for better visualization.
560
561 **cmap**
562 Colormap to use for plotting (e.g., 'viridis', 'plasma', 'RdBu_r').
563
564 **figure_size**
565 Width and height of the figure in inches.
566
567 Output
568 ------
569
570 The tool outputs a plot in the selected format (PNG, PDF, or SVG).
571
572 ]]></help>
573 <expand macro="citations"/>
574 </tool>