Repository 'preprocess_muon'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/preprocess_muon

Changeset 0:678260997e94 (2025-02-05)
Next changeset 1:117dbdeec9db (2025-02-10)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/muon/ commit bcf2ec32c3d13b29da55e0e638da7ddd7162c436
added:
macros.xml
preprocess_muon.xml
b
diff -r 000000000000 -r 678260997e94 macros.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/macros.xml Wed Feb 05 10:53:25 2025 +0000
[
b'@@ -0,0 +1,264 @@\n+<macros>\n+    <token name="@TOOL_VERSION@">0.1.6</token>\n+    <token name="@VERSION_SUFFIX@">0</token>\n+    <token name="@PROFILE@">23.0</token>\n+    <xml name="requirements">\n+        <requirements>\n+            <requirement type="package" version="@TOOL_VERSION@">muon</requirement>\n+            <requirement type="package" version="0.10.2">leidenalg</requirement>\n+            <requirement type="package" version="0.8.2">louvain</requirement>\n+            <requirement type="package" version="0.7.2">mofapy2</requirement>\n+        </requirements>\n+    </xml>\n+    <xml name="bio_tools">\n+        <xrefs>\n+            <xref type="bio.tools">muon</xref>\n+        </xrefs>\n+    </xml>\n+    <xml name="creators">\n+        <creator>\n+            <organization name="European Galaxy Team" url="https://galaxyproject.org/eu/" />\n+        </creator>\n+    </xml>\n+    <xml name="citations">\n+        <citations>\n+            <citation type="doi">10.1186/s13059-021-02577-8</citation>\n+        </citations>\n+    </xml>\n+    <xml name="sanitize_query">\n+        <sanitizer>\n+            <valid initial="string.printable">\n+                <remove value="&apos;" />\n+            </valid>\n+       </sanitizer>\n+    </xml>\n+    <xml name="sanitize_string">\n+        <sanitizer>\n+            <valid initial="string.letters,string.digits"><add value="_" /></valid>\n+        </sanitizer>\n+    </xml>\n+    <xml name="version_command">\n+        <version_command><![CDATA[python -c "import muon as mu;print(\'Muon version: %s\' % mu.__version__)"]]></version_command>\n+    </xml>\n+\n+    <token name="@CMD_imports@"><![CDATA[\n+import mudata as md\n+import muon as mu\n+import scanpy as sc\n+import os\n+            ]]>\n+    </token>\n+    <xml name="inputs_mudata">\n+        <param name="mdata" type="data" format="h5ad" label="MuData input file"/>\n+    </xml>\n+    <token name="@CMD_read_inputs@"><![CDATA[\n+mdata = md.read(\'mudata.h5mu\')\n+        ]]>\n+    </token>\n+    <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\'\n+    ]]></token>\n+    <token name="@COPY_MUDATA@"><![CDATA[\n+cp \'$mdata\' \'mudata.h5mu\' &&\n+    ]]>\n+    </token>\n+\n+    <token name="@CMD@"><![CDATA[\n+cat \'$script_file\' > \'$hidden_output\' &&\n+python \'$script_file\' >> \'$hidden_output\' &&\n+touch \'mudata_info.txt\' &&\n+cat \'mudata_info.txt\' @CMD_prettify_stdout@\n+    ]]>\n+    </token>\n+\n+    <token name="@CMD_params_clustering@"><![CDATA[\n+    #if $method.res.type == \'same\'\n+        #if str($method.res.resolution)\n+    resolution=$method.res.resolution,\n+        #end if\n+    #else if $method.res.type == \'separate\'\n+    resolution={\n+        #for $modality in $method.res.modalities\n+        \'$modality.mod_name\': $modality.resolution,\n+        #end for\n+    },\n+    #end if\n+    #if $method.weights.type == \'same\'\n+        #if str($method.weights.mod_weights)\n+    mod_weights=$method.weights.mod_weights,\n+        #end if\n+    #else if $method.weights.type == \'separate\'\n+    mod_weights={\n+        #for $modality in $method.weights.modalities\n+        \'$modality.mod_name\': $modality.mod_weights,\n+        #end for\n+    },\n+    #end if\n+    random_state=$method.random_state,\n+    key_added=\'$method.key_added\',\n+    #if $method.neighbors_key\n+    neighbors_key=\'$method.neighbors_key\',\n+    #end if\n+    directed=$method.directed\n+    ]]></token>\n+\n+    <token name="@CMD_neighbor_keys@"><![CDATA[\n+    #if $method.n_keys.type == \'same\'\n+    neighbor_keys=\'$method.n_keys.neighbor_keys\',\n+    #else if $method.n_keys.type == \'separate\'\n+    neighbor_keys={\n+        #for $modality in $method.n_keys.modalities\n+        \'$modality.mod_name\': \'$modality.neighbor_keys\',\n+        #end for\n+    },\n+    #end if\n+    ]]></token>\n+    <token name="@CMD_params_embedding@"><![CDATA[\n+    #if $method.color\n+    #set $color = ([x.strip() for x in str($method.color).split(\',\')])\n+    color=$color'..b'nd macro="sanitize_string" />\n+                    </param>\n+                    <param name="mod_weights" type="float" label="Weight for the above modality" help="Higher values -> more important"/>\n+                </repeat>\n+            </when>\n+        </conditional>\n+    </xml>\n+    <xml name="param_random_state" tokens="seed">\n+        <param argument="random_state" type="integer" value="@SEED@" optional="true" label="Random seed for the optimization"/>\n+    </xml>\n+    <xml name="param_key_added" tokens="key_added">\n+        <param argument="key_added" type="text" value="@KEY_ADDED@" label="mdata.obs key where cluster labels to be added">\n+            <expand macro="sanitize_string" />\n+        </param>\n+    </xml>\n+    <xml name="param_neighbors_key">\n+        <param argument="neighbors_key" type="text" optional="true" label="Use neighbors connectivities as adjacency"\n+        help="If not specified, look for .obsp[\'connectivities\'] in each modality.\n+        If specified, look for .obsp[.uns[neighbors_key][\'connectivities_key\']] in each modality for connectivities.">\n+            <expand macro="sanitize_string" />\n+        </param>\n+    </xml>\n+    <xml name="param_directed">\n+        <param argument="directed" type="boolean" truevalue="True" falsevalue="False" checked="true" label="Treat the graph as directed"/>\n+    </xml>\n+    <xml name="param_key_added_common">\n+        <param argument="key_added" type="text" optional="true" label="Key to be added to store neighbors, distances and connectivities data"\n+            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.\n+            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\'].">\n+            <expand macro="sanitize_string" />\n+        </param>\n+    </xml>\n+    <xml name="param_eps" tokens="eps_value">\n+        <param argument="eps" type="float" value="@EPS_VALUE@" label="Small number to avoid numerical errors"/>\n+    </xml>\n+    <xml name="param_use_raw" tokens="label,checked">\n+        <param argument="use_raw" type="boolean" truevalue="True" falsevalue="False" checked="@CHECKED@" label="@LABEL@" />\n+    </xml>\n+    <xml name="param_keys">\n+        <conditional name="key_variables">\n+            <param name="type" type="select" label="Keys to plot">\n+                <option value="var_names">All variables in \'.var_names\'</option>\n+                <option value="obs">All fields in \'.obs\'</option>\n+                <option value="custom">Subset of variables in \'adata.var_names\' or fields of \'.obs\'</option>\n+            </param>\n+            <when value="var_names"/>\n+            <when value="obs"/>\n+            <when value="custom">\n+                <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\'">\n+                    <expand macro="sanitize_query" />\n+                </param>\n+            </when>\n+        </conditional>\n+    </xml>\n+    <xml name="param_color">\n+        <param argument="color" type="text" optional="true" label="Keys for variables or annotations of observations (.obs columns)" help="Can be from any modality.">\n+            <expand macro="sanitize_query" />\n+        </param>\n+    </xml>\n+    <xml name="params_embedding">\n+        <expand macro="param_color"/>\n+        <expand macro="param_use_raw" label="Use raw slot of AnnData as input values" checked="true"/>\n+        <param argument="layer" type="text" optional="true" label="Name of the layer in the modality where a feature (from color) is derived from"\n+            help="If a valid layer is provided, this takes precedence over use_raw=True">\n+            <expand macro="sanitize_query" />\n+        </param>\n+    </xml>\n+</macros>\n'
b
diff -r 000000000000 -r 678260997e94 preprocess_muon.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/preprocess_muon.xml Wed Feb 05 10:53:25 2025 +0000
[
b'@@ -0,0 +1,322 @@\n+<tool id="preprocess_muon" name="muon filter and  normalize" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">\n+    <macros>\n+        <import>macros.xml</import>\n+    </macros>\n+    <expand macro="requirements"/>\n+    <expand macro="version_command"/>\n+    <command detect_errors="exit_code"><![CDATA[\n+@COPY_MUDATA@\n+@CMD@\n+    ]]></command>\n+    <configfiles>\n+        <configfile name="script_file"><![CDATA[\n+@CMD_imports@\n+@CMD_read_inputs@\n+\n+#if $method.method == \'pp.intersect_obs\'\n+mu.pp.intersect_obs(\n+    mdata\n+)\n+## Update the features. Only union features of the modalities are considered\n+mdata.update_var()\n+\n+\n+#else if $method.method == \'pp.l2norm\'\n+mu.pp.l2norm(\n+    mdata,\n+    #if $method.mod\n+    mod=\'$method.mod\',\n+    #end if\n+    #if $method.rep\n+    rep=\'$method.rep\',\n+    #end if\n+    n_pcs=$method.n_pcs,\n+    copy=False\n+)\n+\n+#else if $method.method == \'pp.neighbors\'\n+mu.pp.neighbors(\n+    mdata,\n+    #if str($method.n_neighbors)\n+    n_neighbors=$method.n_neighbors,\n+    #end if\n+    n_bandwidth_neighbors=$method.n_bandwidth_neighbors,\n+    n_multineighbors=$method.n_multineighbors,\n+    @CMD_neighbor_keys@\n+    metric=\'$method.metric\',\n+    #if $method.key_added\n+    key_added=\'$method.key_added\',\n+    #end if\n+    weight_key=\'$method.weight_key\',\n+    add_weights_to_modalities=$method.add_weights_to_modalities,\n+    eps=$method.eps,\n+    random_state=$method.random_state,\n+    copy=False\n+)\n+\n+#else if $method.method == \'pp.sample_obs\'\n+mu.pp.sample_obs(\n+    mdata,\n+    frac=$method.frac,\n+    #if $method.groupby\n+    groupby=\'$method.groupby\',\n+    #end if\n+    #if str($method.min_n)\n+    min_n=$method.min_n\n+    #end if\n+)\n+#end if\n+\n+@CMD_mudata_write_outputs@\n+]]></configfile>\n+    </configfiles>\n+    <inputs>\n+        <expand macro="inputs_mudata"/>\n+        <conditional name="method">\n+            <param name="method" type="select" label="Method used for plotting">\n+                    <option value="pp.intersect_obs">Subset: Subset observations present only in all modalities, using \'muon.pp.intersect_obs\'</option>\n+                    <option value="pp.l2norm">Normalize: Normalize observations to unit L2 norm, using \'muon.pp.l2norm\'</option>\n+                    <option value="pp.neighbors">Search: Multimodal nearest neighbor search, using \'muon.pp.neighbors\'</option>\n+                    <option value="pp.sample_obs">Return an object with some of the observations (subsampling). \'muon.pp.sample_obs\'</option>\n+            </param>\n+            <when value="pp.intersect_obs"/>\n+            <when value="pp.l2norm">\n+                <param argument="mod" type="text" optional="true" label="Names of the modalities to normalize" help="Leave empty to use all modalities">\n+                    <expand macro="sanitize_string" />\n+                </param>\n+                <param argument="rep" type="text" optional="true" label="The representation to normalize." help="X or any key for .obsm is valid, for all modalities">\n+                    <expand macro="sanitize_query" />\n+                </param>\n+                <param argument="n_pcs" type="integer" min="0" value="0" label="The number of principal components to use." help="This affects the result only if a PCA representation is being normalized"/>\n+            </when>\n+            <when value="pp.neighbors">\n+                <param argument="n_neighbors" type="integer" optional="true" label="Number of nearest neighbors to find"\n+                    help="If not set, arithmetic mean of per-modality neighbors will be used"/>\n+                <param argument="n_bandwidth_neighbors" type="integer" value="20" label="Number of nearest neighbors to use for bandwidth selection"/>\n+                <param argument="n_multineighbors" type="integer" value="200" label="Number of nearest neighbors in each modality to consider as candidates for multimodal nearest neighbors"\n+                    help="Only points in the union of '..b'test expect_num_outputs="2">\n+            <!-- test4: sample_obs -->\n+            <param name="mdata" ftype="h5ad" location="https://zenodo.org/records/12570984/files/pbmc3k_chr21.h5mu"/>\n+            <param name="method" value="pp.sample_obs"/>\n+            <param name="frac" value="0.5"/>\n+            <param name="min_n" value="10"/>\n+            <section name="advanced_common">\n+                <param name="show_log" value="true" />\n+            </section>\n+            <output name="hidden_output">\n+                <assert_contents>\n+                    <has_text_matching expression="mu.pp.sample_obs"/>\n+                    <has_text_matching expression="frac=0.5"/>\n+                    <has_text_matching expression="min_n=10"/>\n+                </assert_contents>\n+            </output>\n+            <assert_stdout>\n+                <has_text_matching expression="179 \xc3\x97 490"/>\n+                <has_text_matching expression="179 x 178"/>\n+                <has_text_matching expression="179 x 312"/>\n+            </assert_stdout>\n+            <output name="mudata_out" ftype="h5ad">\n+                <assert_contents>\n+                    <has_h5_keys keys="mod/rna"/>\n+                    <has_h5_keys keys="mod/atac"/>\n+                </assert_contents>\n+            </output>\n+        </test>\n+    </tests>\n+    <help><![CDATA[\n+Filter: Filter observations (samples or cells) in-place using any column in .obs or in .X (\'muon.pp.filter_obs\')\n+================================================================================================================\n+\n+        Filter observations (samples or cells) in-place using any column in .obs or in .X.\n+\n+        More details on the `muon documentation\n+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.filter_obs.html#muon.pp.filter_obs>`__\n+\n+Filter: Filter variables (features) (\'muon.pp.filter_var\')\n+==========================================================\n+\n+        Filter variables (features, e.g. genes) in-place using any column in .var or row in .X.\n+\n+        More details on the `muon documentation\n+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.filter_var.html#muon.pp.filter_var>`__\n+\n+Subset: Subset observations (samples or cells) in-place taking observations present only in all modalities (\'muon.pp.intersect_obs\')\n+====================================================================================================================================\n+\n+        Subset observations (samples or cells) in-place taking observations present only in all modalities.\n+\n+        More details on the `muon documentation\n+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.intersect_obs.html#muon.pp.intersect_obs>`__\n+\n+Normalize: Normalize observations to unit L2 norm (\'muon.pp.l2norm\')\n+====================================================================\n+\n+        Normalize observations to unit L2 norm.\n+\n+        More details on the `muon documentation\n+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.l2norm.html#muon.pp.l2norm>`__\n+\n+Search: Multimodal nearest neighbor search (\'muon.pp.neighbors\')\n+================================================================\n+\n+        Multimodal nearest neighbor search by implementing the multimodal nearest neighbor method of Hao et al. and Swanson et al.\n+        The neighbor search efficiency on this heavily relies on UMAP. In particular, you may want to decrease\n+        n_multineighbors for large data set to avoid excessive peak memory use. To achieve results as close as possible\n+        to the Seurat implementation, observations must be normalized to unit L2 norm prior to running per-modality\n+        nearest-neighbor search.\n+\n+        More details on the `muon documentation\n+        <https://muon.readthedocs.io/en/latest/api/generated/muon.pp.neighbors.html#muon.pp.neighbors>`__\n+\n+    ]]></help>\n+    <expand macro="citations"/>\n+</tool>\n\\ No newline at end of file\n'