diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot.xml	Tue Mar 10 13:41:01 2026 +0000
@@ -0,0 +1,574 @@
+<tool id="liana_plot" name="Liana Plot" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
+    <description>visualize ligand-receptor interactions</description>
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <expand macro="bio_tools"/>
+    <expand macro="creators"/>
+    <expand macro="requirements"/>
+    <expand macro="version_command"/>
+    <command detect_errors="exit_code"><![CDATA[
+#if str($method.method) in ['pl.target_metrics', 'pl.contributions', 'pl.interactions']:
+cp '$method.mdata' 'misty.h5mu' &&
+#else:
+cp '$method.adata' 'anndata.h5ad' &&
+#end if
+cat '$script_file' > '$hidden_output' &&
+python '$script_file' >> '$hidden_output' &&
+ls . >> '$hidden_output' &&
+touch 'anndata_info.txt' &&
+cat 'anndata_info.txt' @CMD_PRETTIFY_STDOUT@
+ ]]></command>
+    <configfiles>
+        <configfile name="script_file"><![CDATA[
+@CMD_IMPORTS@
+import mudata as mu
+if os.path.exists("misty.h5mu"):
+    import mudata as mu
+    mdata = mu.read_h5mu("misty.h5mu")
+    # Wrap MuData into LIANA MistyData (this is what plotting expects)
+else:
+    adata = sc.read_h5ad('anndata.h5ad')
+
+
+#if str($method.method) == 'pl.dotplot':
+fig = li.plotting.dotplot(
+    adata=adata,
+    uns_key='$method.uns_key',
+    #if str($method.colour) != '':
+    colour='$method.colour',
+    #end if
+    #if str($method.size) != '':
+    size='$method.size',
+    #end if
+    @CMD_PLOT_SOURCE_TARGET_LABELS@
+    @CMD_PLOT_LIGAND_RECEPTOR_COMPLEX@
+    @CMD_PLOT_TOP_N_ORDERBY@
+    inverse_colour=$method.inverse_colour,
+    inverse_size=$method.inverse_size,
+    cmap='$method.cmap',
+    size_range=($method.size_range_min, $method.size_range_max),
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+
+#else if str($method.method) == 'pl.dotplot_by_sample':
+fig = li.plotting.dotplot_by_sample(
+    adata=adata,
+    uns_key='$method.uns_key',
+    sample_key='$method.sample_key',
+    #if str($method.colour) != '':
+    colour='$method.colour',
+    #end if
+    #if str($method.size) != '':
+    size='$method.size',
+    #end if
+    @CMD_PLOT_SOURCE_TARGET_LABELS@
+    @CMD_PLOT_LIGAND_RECEPTOR_COMPLEX@
+    inverse_colour=$method.inverse_colour,
+    inverse_size=$method.inverse_size,
+    cmap='$method.cmap',
+    size_range=($method.size_range_min, $method.size_range_max),
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+
+#else if str($method.method) == 'pl.tileplot':
+fig = li.plotting.tileplot(
+    adata=adata,
+    uns_key='$method.uns_key',
+    #if str($method.fill) != '':
+    fill='$method.fill',
+    #end if
+    #if str($method.label) != '':
+    label='$method.label',
+    #end if
+    @CMD_PLOT_SOURCE_TARGET_LABELS@
+    @CMD_PLOT_LIGAND_RECEPTOR_COMPLEX@
+    @CMD_PLOT_TOP_N_ORDERBY@
+    #if str($method.source_title) != '':
+    source_title='$method.source_title',
+    #end if
+    #if str($method.target_title) != '':
+    target_title='$method.target_title',
+    #end if
+    cmap='$method.cmap',
+    label_size=$method.label_size,
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+
+#else if str($method.method) == 'pl.connectivity':
+fig = li.plotting.connectivity(
+    adata=adata,
+    idx=$method.idx,
+    spatial_key='$method.spatial_key',
+    connectivity_key='$method.connectivity_key',
+    size=$method.size,
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+
+#else if str($method.method) == 'pl.target_metrics':
+fig = li.plotting.target_metrics(
+    misty=mdata,
+    #if str($method.key) != '':
+    key='$method.key',
+    #end if
+    #if str($method.stat) != '':
+    stat='$method.stat',
+    #end if
+    #if str($method.top_n) != '':
+    top_n=$method.top_n,
+    #end if
+    ascending=$method.ascending,
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+
+#else if str($method.method) == 'pl.contributions':
+fig = li.plotting.contributions(
+    misty=mdata,
+    #if str($method.key) != '':
+    key='$method.key',
+    #end if
+    #if str($method.view_names) != '':
+    view_names=[x.strip() for x in '$method.view_names'.split(',')],
+    #end if
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+
+#else if str($method.method) == 'pl.interactions':
+fig = li.plotting.interactions(
+    misty=mdata,
+    #if str($method.key) != '':
+    key='$method.key',
+    #end if
+    #if str($method.view) != '':
+    view='$method.view',
+    #end if
+    #if str($method.top_n) != '':
+    top_n=$method.top_n,
+    #end if
+    ascending=$method.ascending,
+    figure_size=($method.figure_size_width, $method.figure_size_height),
+    return_fig=True)
+#end if
+
+## Save the figure
+fig.save('plot.$format', dpi=150)
+
+        ]]>
+        </configfile>
+    </configfiles>
+    <inputs>
+        <param name="format" type="select" label="Format for saving figure">
+            <option value="png" selected="true">png</option>
+            <option value="pdf">pdf</option>
+            <option value="svg">svg</option>
+        </param>
+        <conditional name="method">
+            <param argument="method" type="select" label="Plotting method">
+                <option value="pl.dotplot">Dotplot: Interactions by source and target cells (dotplot)</option>
+                <option value="pl.dotplot_by_sample">Dotplot by sample: Interactions grouped by sample (dotplot_by_sample)</option>
+                <option value="pl.tileplot">Tileplot: Interactions as tiles by source and target (tileplot)</option>
+                <option value="pl.connectivity">Connectivity: Spatial connectivity weights (connectivity)</option>
+                <option value="pl.target_metrics">MISTy Target Metrics: Plot target metrics from MISTy results (target_metrics)</option>
+                <option value="pl.contributions">MISTy Contributions: Plot view contributions per target (contributions)</option>
+                <option value="pl.interactions">MISTy Interactions: Plot interaction importances (interactions)</option>
+            </param>
+            <when value="pl.dotplot">
+                <expand macro="inputs_anndata"/>
+                <expand macro="param_uns_key"/>
+                <expand macro="param_plot_colour"/>
+                <expand macro="param_plot_size"/>
+                <expand macro="param_source_labels"/>
+                <expand macro="param_target_labels"/>
+                <expand macro="param_ligand_complex"/>
+                <expand macro="param_receptor_complex"/>
+                <expand macro="param_top_n"/>
+                <expand macro="param_orderby"/>
+                <expand macro="param_orderby_ascending"/>
+                <expand macro="param_orderby_absolute"/>
+                <expand macro="param_inverse_colour"/>
+                <expand macro="param_inverse_size"/>
+                <expand macro="param_cmap"/>
+                <expand macro="param_size_range"/>
+                <expand macro="param_figure_size"/>
+            </when>
+            <when value="pl.dotplot_by_sample">
+                <expand macro="inputs_anndata"/>
+                <expand macro="param_uns_key"/>
+                <expand macro="param_sample_key" VALUE="sample"/>
+                <expand macro="param_plot_colour"/>
+                <expand macro="param_plot_size"/>
+                <expand macro="param_source_labels"/>
+                <expand macro="param_target_labels"/>
+                <expand macro="param_ligand_complex"/>
+                <expand macro="param_receptor_complex"/>
+                <expand macro="param_inverse_colour"/>
+                <expand macro="param_inverse_size"/>
+                <expand macro="param_cmap"/>
+                <expand macro="param_size_range"/>
+                <expand macro="param_figure_size"/>
+            </when>
+            <when value="pl.tileplot">
+                <expand macro="inputs_anndata"/>
+                <expand macro="param_uns_key"/>
+                <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.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <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').">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <expand macro="param_source_labels"/>
+                <expand macro="param_target_labels"/>
+                <expand macro="param_ligand_complex"/>
+                <expand macro="param_receptor_complex"/>
+                <expand macro="param_top_n"/>
+                <expand macro="param_orderby"/>
+                <expand macro="param_orderby_ascending"/>
+                <expand macro="param_orderby_absolute"/>
+                <param argument="source_title" type="text" value="" optional="true" label="Source axis title" help="Custom title for sender/source cell types axis. Default: 'Source'.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <param argument="target_title" type="text" value="" optional="true" label="Target axis title" help="Custom title for receiver/target cell types axis. Default: 'Target'.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <expand macro="param_cmap"/>
+                <param argument="label_size" type="integer" value="12" min="1" label="Label text size" help="Font size for labels in tiles. Default: 12.">
+                </param>
+                <expand macro="param_figure_size" width="5" height="5"/>
+            </when>
+            <when value="pl.connectivity">
+                <expand macro="inputs_anndata"/>
+                <param argument="idx" type="integer" value="0" min="0" label="Cell index" help="Index of the cell to plot connectivity for."/>
+                <param argument="spatial_key" type="text" value="spatial" label="Spatial key" help="Key in adata.obsm that contains the spatial coordinates.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <param argument="connectivity_key" type="text" value="spatial_connectivities" label="Connectivity key" help="Key in adata.obsp that contains the spatial connectivity matrix.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <param argument="size" type="float" value="1" min="0" label="Point size" help="Size of the points."/>
+                <expand macro="param_figure_size" width="5.4" height="5"/>
+            </when>
+            <when value="pl.target_metrics">
+                <param name="mdata" type="data" format="h5mu" optional="true" label="MISTy (MuData .h5mu) file" help="" />
+                <expand macro="param_misty_key"/>
+                <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.">
+                    <option value="">-- Select statistic --</option>
+                    <option value="gain_R2">gain_R2 - R² gain from spatial context</option>
+                    <option value="intra_R2">intra_R2 - Intra-view R²</option>
+                    <option value="multi_R2">multi_R2 - Total multi-view R²</option>
+                    <option value="p_value">p_value - Statistical significance</option>
+                </param>
+                <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.">
+                </param>
+                <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).">
+                </param>
+                <expand macro="param_figure_size" width="5" height="5"/>
+            </when>
+            <when value="pl.contributions">
+                <param name="mdata" type="data" format="h5mu" optional="true" label="MISTy (MuData .h5mu) file" help="" />
+                <expand macro="param_misty_key"/>
+                <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.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <expand macro="param_figure_size" width="5" height="5"/>
+            </when>
+            <when value="pl.interactions">
+                <param name="mdata" type="data" format="h5mu" optional="true" label="MISTy (MuData .h5mu) file" help="" />
+                <expand macro="param_misty_key"/>
+                <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.">
+                    <expand macro="sanitize_query"/>
+                </param>
+                <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.">
+                </param>
+                <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).">
+                </param>
+                <expand macro="param_figure_size" width="5" height="5"/>
+            </when>
+        </conditional>
+        <expand macro="inputs_common_advanced"/>
+    </inputs>
+    <outputs>
+        <data name="out_png" format="png" from_work_dir="plot.png" label="${tool.name} (${method.method}) on ${on_string}: PNG">
+            <filter>format == 'png'</filter>
+        </data>
+        <data name="out_pdf" format="pdf" from_work_dir="plot.pdf" label="${tool.name} (${method.method}) on ${on_string}: PDF">
+            <filter>format == 'pdf'</filter>
+        </data>
+        <data name="out_svg" format="svg" from_work_dir="plot.svg" label="${tool.name} (${method.method}) on ${on_string}: SVG">
+            <filter>format == 'svg'</filter>
+        </data>
+        <data name="hidden_output" format="txt" label="Log file">
+            <filter>advanced_common['show_log']</filter>
+        </data>
+    </outputs>
+    <tests>
+        <!-- 1) dotplot -> PNG -->
+        <test expect_num_outputs="2">
+            <param name="format" value="png"/>
+            <conditional name="method">
+                <param name="method" value="pl.dotplot"/>
+                <param name="adata" location="https://zenodo.org/records/18388645/files/pbmc_liana_results.h5ad"/>
+                <param name="uns_key" value="liana_res"/>
+                <param name="colour" value="magnitude_rank"/>
+                <param name="size" value="specificity_rank"/>
+                <param name="inverse_colour" value="true"/>
+                <param name="inverse_size" value="true"/>
+                <param name="cmap" value="viridis"/>
+                <param name="size_range_min" value="1"/>
+                <param name="size_range_max" value="5"/>
+                <param name="figure_size_width" value="8"/>
+                <param name="figure_size_height" value="6"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_png" ftype="png">
+                <assert_contents>
+                    <has_size size="390000" delta="150000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.dotplot"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- 2) dotplot_by_sample -> PDF -->
+        <test expect_num_outputs="2">
+            <param name="format" value="pdf"/>
+            <conditional name="method">
+                <param name="method" value="pl.dotplot_by_sample"/>
+                <param name="adata" location="https://zenodo.org/records/18388645/files/multi_sample_test.h5ad"/>
+                <param name="uns_key" value="liana_res"/>
+                <param name="sample_key" value="sample"/>
+                <param name="colour" value="magnitude_rank"/>
+                <param name="size" value="specificity_rank"/>
+                <param name="inverse_colour" value="true"/>
+                <param name="inverse_size" value="true"/>
+                <param name="cmap" value="viridis"/>
+                <param name="size_range_min" value="1"/>
+                <param name="size_range_max" value="5"/>
+                <param name="figure_size_width" value="8"/>
+                <param name="figure_size_height" value="6"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_pdf" ftype="pdf">
+                <assert_contents>
+                    <has_size size="280000" delta="100000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.dotplot_by_sample"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- 3) tileplot -> SVG -->
+        <test expect_num_outputs="2">
+            <param name="format" value="svg"/>
+            <conditional name="method">
+                <param name="method" value="pl.tileplot"/>
+                <param name="adata" location="https://zenodo.org/records/18388645/files/pbmc_liana_results.h5ad"/>
+                <param name="uns_key" value="liana_res"/>
+                <param name="fill" value="magnitude_rank"/>
+                <param name="label" value="magnitude_rank"/>
+                <param name="top_n" value="15"/>
+                <param name="orderby" value="magnitude_rank"/>
+                <param name="orderby_ascending" value="true"/>
+                <param name="cmap" value="viridis"/>
+                <param name="label_size" value="10"/>
+                <param name="figure_size_width" value="6"/>
+                <param name="figure_size_height" value="6"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_svg" ftype="svg">
+                <assert_contents>
+                    <has_size size="3300000" delta="1000000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.tileplot"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- 4) connectivity -> PNG -->
+        <test expect_num_outputs="2">
+            <param name="format" value="png"/>
+            <conditional name="method">
+                <param name="method" value="pl.connectivity"/>
+                <param name="adata" location="https://zenodo.org/records/18388645/files/spatial_small.h5ad"/>
+                <param name="idx" value="0"/>
+                <param name="spatial_key" value="spatial"/>
+                <param name="connectivity_key" value="spatial_connectivities"/>
+                <param name="size" value="1.5"/>
+                <param name="figure_size_width" value="6"/>
+                <param name="figure_size_height" value="5"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_png" ftype="png">
+                <assert_contents>
+                    <has_size size="56000" delta="40000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.connectivity"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- 5) MISTy target_metrics -> PDF -->
+        <test expect_num_outputs="2">
+            <param name="format" value="pdf"/>
+            <conditional name="method">
+                <param name="method" value="pl.target_metrics"/>
+                <param name="mdata" location="https://zenodo.org/records/18388645/files/genericMistyData_rf.h5mu"/>
+                <param name="stat" value="gain_R2"/>
+                <param name="ascending" value="false"/>
+                <param name="figure_size_width" value="5"/>
+                <param name="figure_size_height" value="5"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_pdf" ftype="pdf">
+                <assert_contents>
+                    <has_size size="17186" delta="5000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.target_metrics"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- 6) MISTy contributions -> SVG -->
+        <test expect_num_outputs="2">
+            <param name="format" value="svg"/>
+            <conditional name="method">
+                <param name="method" value="pl.contributions"/>
+                <param name="mdata" location="https://zenodo.org/records/18388645/files/genericMistyData_rf.h5mu"/>
+                <param name="view_names" value="intra,juxta,para"/>
+                <param name="figure_size_width" value="5"/>
+                <param name="figure_size_height" value="5"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_svg" ftype="svg">
+                <assert_contents>
+                     <has_size size="58175" delta="10000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.contributions"/>
+                </assert_contents>
+            </output>
+        </test>
+        <!-- 7) MISTy interactions -> PNG -->
+        <test expect_num_outputs="2">
+            <param name="format" value="png"/>
+            <conditional name="method">
+                <param name="method" value="pl.interactions"/>
+                <param name="mdata" location="https://zenodo.org/records/18388645/files/genericMistyData_rf.h5mu"/>
+                <param name="view" value="para"/>
+                <param name="top_n" value="20"/>
+                <param name="ascending" value="false"/>
+                <param name="figure_size_width" value="5"/>
+                <param name="figure_size_height" value="5"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="out_png" ftype="png">
+                <assert_contents>
+                    <has_size size="52184" delta="8000"/>
+                </assert_contents>
+            </output>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="li.plotting.interactions"/>
+                </assert_contents>
+            </output>
+        </test>
+    </tests>
+    <help><![CDATA[
+Liana Plotting Tools
+====================
+
+This tool provides visualization methods for LIANA ligand-receptor analysis results.
+
+Available Methods
+-----------------
+
+**dotplot**
+    Create a dotplot of interactions by source and target cells. The dot size and color
+    can be mapped to different columns in the LIANA results (e.g., expression magnitude,
+    specificity scores).
+
+**dotplot_by_sample**
+    Create a dotplot of interactions grouped by sample. Useful for comparing interactions
+    across different conditions or samples.
+
+**tileplot**
+    Create a tileplot showing interactions as tiles organized by source and target cells.
+    The fill color and labels can be customized.
+
+**connectivity**
+    Plot spatial connectivity weights for a specific cell. Requires spatial data with
+    connectivity information computed.
+
+**target_metrics** (MISTy)
+    Plot target metrics from MISTy spatial modelling results. Shows statistics like
+    R² gain, intra R², multi R², or p-values for each target.
+
+**contributions** (MISTy)
+    Plot view contributions per target from MISTy results. Shows how different spatial
+    views contribute to explaining each target variable.
+
+**interactions** (MISTy)
+    Plot interaction importances from MISTy results. Shows the importance of predictor
+    variables for explaining targets within a specific view.
+
+Common Parameters
+-----------------
+
+**uns_key**
+    Key in adata.uns that contains the LIANA results. Default is 'liana_res'.
+
+**colour / size**
+    Columns in liana_res to define the color and size of dots/tiles.
+    Common options include: 'magnitude_rank', 'specificity_rank', 'lr_means', etc.
+
+**source_labels / target_labels**
+    Filter interactions to only show specific source or target cell types.
+
+**ligand_complex / receptor_complex**
+    Filter interactions to only show specific ligand or receptor complexes.
+
+**top_n / orderby**
+    Show only the top N interactions, ordered by a specific column.
+
+**inverse_colour / inverse_size**
+    Apply -log10 transformation to the colour/size values for better visualization.
+
+**cmap**
+    Colormap to use for plotting (e.g., 'viridis', 'plasma', 'RdBu_r').
+
+**figure_size**
+    Width and height of the figure in inches.
+
+Output
+------
+
+The tool outputs a plot in the selected format (PNG, PDF, or SVG).
+
+    ]]></help>
+    <expand macro="citations"/>
+</tool>