diff plot_muon.xml @ 0:36f2cd69d20e draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/muon/ commit bcf2ec32c3d13b29da55e0e638da7ddd7162c436
author iuc
date Wed, 05 Feb 2025 10:53:37 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot_muon.xml	Wed Feb 05 10:53:37 2025 +0000
@@ -0,0 +1,271 @@
+<tool id="plot_muon" name="muon plot" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <expand macro="bio_tools"/>
+    <expand macro="requirements"/>
+    <expand macro="version_command"/>
+    <command detect_errors="exit_code"><![CDATA[
+@COPY_MUDATA@
+@CMD@
+        ]]></command>
+    <configfiles>
+        <configfile name="script_file"><![CDATA[
+@CMD_imports@
+@CMD_read_inputs@
+
+#if $method.method == "pl.embedding"
+plot = mu.pl.embedding(
+    mdata,
+    basis='$method.basis',
+    @CMD_params_embedding@
+    return_fig=True
+)
+plot.savefig("plot.$plot_ext")
+
+#else if $method.method == "pl.histogram"
+plot = mu.pl.histogram(
+    mdata,
+    #if $method.key_variables.type == "var_names"
+        #set $key_list = mdata.var_names
+    #else if $method.key_variables.type == "obs"
+        #set $key_list = mdata.obs.select_dtypes(exclude=['category']).columns
+    #else if $method.key_variables.type == "custom"
+        #set $key_list=([x.strip() for x in str($method.key_variables.keys).split(',')])
+    #end if
+    keys=$key_list,
+    #if $method.groupby
+    groupby='$method.groupby',
+    #end if
+    save='plot.$plot_ext'
+)
+os.rename(os.path.join('figures', 'histogram_plot.$plot_ext'), 'plot.$plot_ext')
+
+#else if $method.method == "pl.mofa"
+plot = mu.pl.mofa(
+    mdata,
+    @CMD_params_embedding@
+    return_fig=True
+)
+plot.savefig("plot.$plot_ext")
+
+#else if $method.method == "pl.mofa_loadings"
+plot = mu.pl.mofa_loadings(
+    mdata,
+    #if $method.factors
+    factors='$method.factors',
+    #end if
+    include_lowest=$method.include_lowest,
+    #if str($method.n_points)
+    n_points=$method.n_points,
+    #end if
+    save='plot.$plot_ext'
+)
+os.rename(os.path.join('figures', 'mofa_loadings_plot.$plot_ext'), 'plot.$plot_ext')
+
+#else if $method.method == "pl.umap"
+plot = mu.pl.umap(
+    mdata,
+    @CMD_params_embedding@
+    return_fig=True
+)
+plot.savefig("plot.$plot_ext")
+
+#end if
+
+]]></configfile>
+    </configfiles>
+    <inputs>
+        <expand macro="inputs_mudata"/>
+        <conditional name="method">
+            <param name="method" type="select" label="Method used for plotting">
+                    <option value="pl.embedding">Scatter: Scatter plot along observations (.obs column), using 'muon.pl.embedding'</option>
+                    <option value="pl.histogram">Histogram: Plot Histogram of Fragment lengths within specified region, using 'muon.pl.histogram'</option>
+                    <option value="pl.mofa">Scatter: Scatter plot in MOFA factor coordinates, using 'muon.pl.mofa'</option>
+                    <option value="pl.mofa_loadings">Ranking: Rank genes according to contributions to MOFA factors, using 'muon.pl.mofa_loadings'</option>
+                    <option value="pl.umap">Scatter: UMAP scatter plot, using 'muon.pl.umap'</option>
+            </param>
+            <when value="pl.embedding">
+                <param argument="basis" type="text" value="X_mofa" label="Name of the obsm basis to use" help="can also be a basis inside any modality, e.g. 'rna:X_pca'">
+                    <expand macro="sanitize_query" />
+                </param>
+                <expand macro="params_embedding"/>
+            </when>
+            <when value="pl.histogram">
+                <expand macro="param_keys"/>
+                <param argument="groupby" type="text" optional="true" label="Column name(s) of .obs slot of the AnnData object according to which the plot is split">
+                    <expand macro="sanitize_query" />
+                </param>
+            </when>
+            <when value="pl.mofa">
+                <expand macro="params_embedding"/>
+            </when>
+            <when value="pl.mofa_loadings">
+                <param argument="factors" type="text" optional="true" label="Comma separated list of factors" help="For example, '1,2,3' means [1, 2, 3], first, second, third factors">
+                    <expand macro="sanitize_query" />
+                </param>
+                <param argument="include_lowest" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Whether to show the variables with both highest and lowest loadings"/>
+                <param argument="n_points" type="integer" optional="true" label="Number of variables to plot for each factor"/>
+            </when>
+            <when value="pl.umap">
+                <expand macro="params_embedding"/>
+            </when>
+        </conditional>
+        <param name="plot_ext" type="select" label="Type of output plot">
+            <option value="png" selected="true">PNG</option>
+            <option value="svg">SVG</option>
+            <option value="pdf">PDF</option>
+        </param>
+        <expand macro="inputs_common_advanced" />
+    </inputs>
+    <outputs>
+        <data name="out_png" format="png" from_work_dir="plot.png" label="PNG plot from ${tool.name} (${method.method}) on ${on_string}">
+            <filter>plot_ext == 'png'</filter>
+        </data>
+        <data name="out_pdf" format="pdf" from_work_dir="plot.pdf" label="PDF plot from ${tool.name} (${method.method}) on ${on_string}">
+            <filter>plot_ext == 'pdf'</filter>
+        </data>
+        <data name="out_svg" format="svg" from_work_dir="plot.svg" label="SVG plot from ${tool.name} (${method.method}) on ${on_string}">
+            <filter>plot_ext == 'svg'</filter>
+        </data>
+        <data name="hidden_output" format="txt" label="Log file" hidden="true" >
+            <filter>advanced_common['show_log']</filter>
+        </data>
+    </outputs>
+    <tests>
+        <test expect_num_outputs="2">
+            <!-- test1: pl.embedding -->
+            <param name="mdata" location="https://zenodo.org/records/12570984/files/tl.mofa.h5mu"/>
+            <param name="method" value="pl.embedding"/>
+            <param name="basis" value="X_mofa"/>
+            <param name="color" value="rna:leiden,atac:leiden"/>
+            <param name="use_raw" value="False"/>
+            <param name="plot_ext" value="pdf"/>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="mu.pl.embedding"/>
+                    <has_text_matching expression="basis='X_mofa'"/>
+                    <has_text_matching expression="color=\['rna:leiden', 'atac:leiden'\]"/>
+                    <has_text_matching expression="use_raw=False"/>
+                </assert_contents>
+            </output>
+            <output name="out_pdf" ftype="pdf" location="https://zenodo.org/records/12570984/files/pl.embedding.pdf" compare="sim_size" delta_frac="0.1"/>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test2 pl.histogram -->
+            <param name="mdata" location="https://zenodo.org/records/12570984/files/tl.mofa.h5mu"/>
+            <param name="method" value="pl.histogram"/>
+            <conditional name="key_variables">
+                <param name="type" value="custom"/>
+                <param name="keys" value="rna:n_genes_by_counts,rna:total_counts"/>
+            </conditional>
+            <param name="plot_ext" value="png"/>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="mu.pl.histogram"/>
+                    <has_text_matching expression="keys=\['rna:n_genes_by_counts', 'rna:total_counts'\]"/>
+                </assert_contents>
+            </output>
+            <output name="out_png" ftype="png" location="https://zenodo.org/records/12570984/files/pl.histogram.png" compare="image_diff"/>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test3: pl.mofa -->
+            <param name="mdata" location="https://zenodo.org/records/12570984/files/tl.mofa.h5mu"/>
+            <param name="method" value="pl.mofa"/>
+            <param name="use_raw" value="False"/>
+            <param name="plot_ext" value="svg"/>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="mu.pl.mofa"/>
+                    <has_text_matching expression="use_raw=False"/>
+                </assert_contents>
+            </output>
+            <output name="out_svg" ftype="svg" location="https://zenodo.org/records/12570984/files/pl.mofa.svg" compare="sim_size" delta_frac="0.1"/>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test4: pl.mofa_loadings -->
+            <param name="mdata" location="https://zenodo.org/records/12570984/files/tl.mofa.h5mu"/>
+            <param name="method" value="pl.mofa_loadings"/>
+            <param name="factors" value="1,2,3"/>
+            <param name="include_lowest" value="True"/>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="mu.pl.mofa_loadings"/>
+                    <has_text_matching expression="factors='1,2,3'"/>
+                    <has_text_matching expression="include_lowest=True"/>
+                </assert_contents>
+            </output>
+            <output name="out_png" ftype="png" location="https://zenodo.org/records/12570984/files/pl.mofa_loadings.png" compare="image_diff"/>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test5: pl.umap -->
+            <param name="mdata" location="https://zenodo.org/records/12570984/files/tl.umap.h5mu"/>
+            <param name="method" value="pl.umap"/>
+            <param name="use_raw" value="False"/>
+            <section name="advanced_common">
+                <param name="show_log" value="true" />
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="mu.pl.umap"/>
+                    <has_text_matching expression="use_raw=False"/>
+                </assert_contents>
+            </output>
+            <output name="out_png" ftype="png" location="https://zenodo.org/records/12570984/files/pl.umap.png" compare="image_diff"/>
+        </test>
+    </tests>
+    <help><![CDATA[
+Scatter: Scatter plot along observations (.obs column) ('muon.pl.embedding')
+============================================================================
+
+        Produce a scatter plot in the define basis (.obs), which can also be a basis inside any modality.
+
+        More details on the `muon documentation
+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pl.embedding.html#muon.pl.embedding>`__
+
+Scatter: Scatter plot in MOFA factor coordinates ('muon.pl.mofa')
+=================================================================
+
+        Scatter plot in MOFA factors coordinates.
+
+        More details on the `muon documentation
+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pl.mofa.html#muon.pl.mofa>`__
+
+Scatter: UMAP scatter plot ('muon.pl.umap')
+===========================================
+
+        UMAP Scatter plot.
+
+        More details on the `muon documentation
+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pl.umap.html#muon.pl.umap>`__
+
+Histogram: Plot Histogram of Fragment lengths within specified region ('muon.pl.histogram')
+===========================================================================================
+
+        Plot Histogram of Fragment lengths within specified region.
+
+        More details on the `muon documentation
+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pl.histogram.html#muon.pl.histogram>`__
+
+Ranking: Rank genes according to contributions to MOFA factors ('muon.pl.mofa_loadings')
+========================================================================================
+
+        Rank genes according to contributions to MOFA factors.
+
+        More details on the `muon documentation
+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pl.mofa_loadings.html#muon.pl.mofa_loadings>`__
+    ]]></help>
+    <expand macro="citations"/>
+</tool>
\ No newline at end of file