view macros.xml @ 1:47645ab08727 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/muon/ commit b4044d2239aeffeb63d36572da09a0abdd0ba190
author iuc
date Mon, 10 Feb 2025 20:39:22 +0000
parents 089a6101d5d9
children cf936f2abb96
line wrap: on
line source

<macros>
    <token name="@TOOL_VERSION@">0.1.6</token>
    <token name="@VERSION_SUFFIX@">1</token>
    <token name="@PROFILE@">23.0</token>
    <xml name="requirements">
        <requirements>
            <requirement type="package" version="@TOOL_VERSION@">muon</requirement>
            <requirement type="package" version="0.10.2">leidenalg</requirement>
            <requirement type="package" version="0.8.2">louvain</requirement>
            <requirement type="package" version="0.7.2">mofapy2</requirement>
        </requirements>
    </xml>
    <xml name="bio_tools">
        <xrefs>
            <xref type="bio.tools">muon</xref>
        </xrefs>
    </xml>
    <xml name="creators">
        <creator>
            <organization name="European Galaxy Team" url="https://galaxyproject.org/eu/" />
        </creator>
    </xml>
    <xml name="citations">
        <citations>
            <citation type="doi">10.1186/s13059-021-02577-8</citation>
        </citations>
    </xml>
    <xml name="sanitize_query">
        <sanitizer>
            <valid initial="string.printable">
                <remove value="&apos;" />
            </valid>
       </sanitizer>
    </xml>
    <xml name="sanitize_string">
        <sanitizer>
            <valid initial="string.letters,string.digits"><add value="_" /></valid>
        </sanitizer>
    </xml>
    <xml name="version_command">
        <version_command><![CDATA[python -c "import muon as mu;print('Muon version: %s' % mu.__version__)"]]></version_command>
    </xml>

    <token name="@CMD_imports@"><![CDATA[
import mudata as md
import muon as mu
import scanpy as sc
import os
            ]]>
    </token>
    <xml name="inputs_mudata">
        <param name="mdata" type="data" format="h5ad" label="MuData input file"/>
    </xml>
    <token name="@CMD_read_inputs@"><![CDATA[
mdata = md.read('mudata.h5mu')
        ]]>
    </token>
    <token name="@CMD_prettify_stdout@"><![CDATA[ | sed -r '1 s|MuData object with (.+) = (.*)\s*|\1: \2|g' | sed "s|'||g"  | sed -r 's|^\s*(.*):\s(.*)|[\1]\n-    \2|g' | sed 's|, |\n-    |g'
    ]]></token>
    <token name="@COPY_MUDATA@"><![CDATA[
cp '$mdata' 'mudata.h5mu' &&
    ]]>
    </token>

    <token name="@CMD@"><![CDATA[
cat '$script_file' > '$hidden_output' &&
python '$script_file' >> '$hidden_output' &&
touch 'mudata_info.txt' &&
cat 'mudata_info.txt' @CMD_prettify_stdout@
    ]]>
    </token>

    <token name="@CMD_params_clustering@"><![CDATA[
    #if $method.res.type == 'same'
        #if str($method.res.resolution)
    resolution=$method.res.resolution,
        #end if
    #else if $method.res.type == 'separate'
    resolution={
        #for $modality in $method.res.modalities
        '$modality.mod_name': $modality.resolution,
        #end for
    },
    #end if
    #if $method.weights.type == 'same'
        #if str($method.weights.mod_weights)
    mod_weights=$method.weights.mod_weights,
        #end if
    #else if $method.weights.type == 'separate'
    mod_weights={
        #for $modality in $method.weights.modalities
        '$modality.mod_name': $modality.mod_weights,
        #end for
    },
    #end if
    random_state=$method.random_state,
    key_added='$method.key_added',
    #if $method.neighbors_key
    neighbors_key='$method.neighbors_key',
    #end if
    directed=$method.directed
    ]]></token>

    <token name="@CMD_neighbor_keys@"><![CDATA[
    #if $method.n_keys.type == 'same'
    neighbor_keys='$method.n_keys.neighbor_keys',
    #else if $method.n_keys.type == 'separate'
    neighbor_keys={
        #for $modality in $method.n_keys.modalities
        '$modality.mod_name': '$modality.neighbor_keys',
        #end for
    },
    #end if
    ]]></token>
    <token name="@CMD_params_embedding@"><![CDATA[
    #if $method.color
    #set $color = ([x.strip() for x in str($method.color).split(',')])
    color=$color,
    #end if
    use_raw=$method.use_raw,
    #if $method.layer
    layer='$method.layer',
    #end if
    ]]></token>

    <xml name="inputs_common_advanced">
        <section name="advanced_common" title="Advanced Options" expanded="false">
            <param name="show_log" type="boolean" checked="false" label="Output Log?" />
        </section>
    </xml>
    <xml name="outputs_common_advanced">
        <data name="hidden_output" format="txt" label="Log file" >
            <filter>advanced_common['show_log']</filter>
        </data>
    </xml>
    <xml name="muon_outputs">
        <data name="mudata_out" format="h5ad" from_work_dir="mudata.h5mu" label="${tool.name} (${method.method}) on ${on_string}: MuData"/>
        <expand macro="outputs_common_advanced"/>
    </xml>
    <token name="@CMD_mudata_write_outputs@"><![CDATA[
mdata.write('mudata.h5mu')
with open('mudata_info.txt','w', encoding='utf-8') as ainfo:
    print(mdata, file=ainfo)
        ]]>
    </token>

    <xml name="param_neighbor_keys">
        <conditional name="n_keys">
            <param name="type" type="select" label="Same or separate neighborhood information for each modality?">
                <option value="same">Same neighborhood key for all modalities</option>
                <option value="separate">Separate neighborhood keys per modality</option>
            </param>
            <when value="same">
                <param argument="neighbor_keys" type="text" value="neighbors" label="Keys in .uns where per-modality neighborhood information is stored"/>
            </when>
            <when value="separate">
                <repeat name="modalities" title="Modalities" min="2" default="2">
                    <param name="mod_name" type="text" label="Modality name" optional="true">
                        <expand macro="sanitize_string" />
                    </param>
                    <param argument="neighbor_keys" type="text" value="neighbors" label="Keys in .uns where neighborhood information is stored"/>
                </repeat>
            </when>
        </conditional>
    </xml>
    <xml name="param_resolution">
        <conditional name="res">
            <param name="type" type="select" label="Same or separate resolutions for each modality?">
                <option value="same">Same resolution for all modalities</option>
                <option value="separate">Separate resolutions per modality</option>
            </param>
            <when value="same">
                <param argument="resolution" type="float" optional="true" label="Coarseness of the clustering" help="Higher values -> more clusters"/>
            </when>
            <when value="separate">
                <repeat name="modalities" title="Modalities" min="2" default="2">
                    <param name="mod_name" type="text" label="Modality name" optional="true">
                        <expand macro="sanitize_string" />
                    </param>
                    <param name="resolution" type="float" optional="true" label="Resolution for the above modality" help="Higher values -> more clusters"/>
                </repeat>
            </when>
        </conditional>
    </xml>
    <xml name="param_weight">
        <conditional name="weights">
            <param name="type" type="select" label="Same or separate weights for each modality?">
                <option value="same">Same weight for all modalities</option>
                <option value="separate">Separate weight per modality</option>
            </param>
            <when value="same">
                <param argument="mod_weights" type="float" optional="true" label="Weight each modality controlling its contribution" help="Higher values -> more important"/>
            </when>
            <when value="separate">
                <repeat name="modalities" title="Modalities" min="2" default="2">
                    <param name="mod_name" type="text" label="Modality name" optional="true">
                        <expand macro="sanitize_string" />
                    </param>
                    <param name="mod_weights" type="float" optional="true" label="Weight for the above modality" help="Higher values -> more important"/>
                </repeat>
            </when>
        </conditional>
    </xml>
    <xml name="param_random_state" tokens="seed">
        <param argument="random_state" type="integer" value="@SEED@" optional="true" label="Random seed for the optimization"/>
    </xml>
    <xml name="param_key_added" tokens="key_added">
        <param argument="key_added" type="text" value="@KEY_ADDED@" label="mdata.obs key where cluster labels to be added">
            <expand macro="sanitize_string" />
        </param>
    </xml>
    <xml name="param_neighbors_key">
        <param argument="neighbors_key" type="text" optional="true" label="Use neighbors connectivities as adjacency"
        help="If not specified, look for .obsp['connectivities'] in each modality.
        If specified, look for .obsp[.uns[neighbors_key]['connectivities_key']] in each modality for connectivities.">
            <expand macro="sanitize_string" />
        </param>
    </xml>
    <xml name="param_directed">
        <param argument="directed" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Treat the graph as directed"/>
    </xml>
    <xml name="param_key_added_common">
        <param argument="key_added" type="text" optional="true" label="Key to be added to store neighbors, distances and connectivities data"
            help="If not specified, the multimodal neighbors data is stored in .uns['neighbors'], distances and connectivities are stored in .obsp['distances'] and .obsp['connectivities'], respectively.
            If specified, the neighbors data is added to .uns[key_added], distances are stored in .obsp[key_added + '_distances'] and connectivities in .obsp[key_added + '_connectivities'].">
            <expand macro="sanitize_string" />
        </param>
    </xml>
    <xml name="param_eps" tokens="eps_value">
        <param argument="eps" type="float" value="@EPS_VALUE@" label="Small number to avoid numerical errors"/>
    </xml>
    <xml name="param_use_raw" tokens="label,checked">
        <param argument="use_raw" type="boolean" truevalue="True" falsevalue="False" checked="@CHECKED@" label="@LABEL@" />
    </xml>
    <xml name="param_keys">
        <conditional name="key_variables">
            <param name="type" type="select" label="Keys to plot">
                <option value="var_names">All variables in '.var_names'</option>
                <option value="obs">All fields in '.obs'</option>
                <option value="custom">Subset of variables in 'adata.var_names' or fields of '.obs'</option>
            </param>
            <when value="var_names"/>
            <when value="obs"/>
            <when value="custom">
                <param argument="keys" type="text" value="" label="Keys to plot" help="One or a list of comma-separated index or key from '.var_names' or fields of '.obs'">
                    <expand macro="sanitize_query" />
                </param>
            </when>
        </conditional>
    </xml>
    <xml name="param_color">
        <param argument="color" type="text" optional="true" label="Keys for variables or annotations of observations (.obs columns)" help="Can be from any modality.">
            <expand macro="sanitize_query" />
        </param>
    </xml>
    <xml name="params_embedding">
        <expand macro="param_color"/>
        <expand macro="param_use_raw" label="Use raw slot of AnnData as input values" checked="true"/>
        <param argument="layer" type="text" optional="true" label="Name of the layer in the modality where a feature (from color) is derived from"
            help="If a valid layer is provided, this takes precedence over use_raw=True">
            <expand macro="sanitize_query" />
        </param>
    </xml>
</macros>