Mercurial > repos > iuc > clustering_from_distmat
diff clustering_from_distmat.xml @ 0:8192b416f945 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/clustering_from_distmat/ commit a34052b87a2d05cabed5001c50f1bb10e74f97ee
author | iuc |
---|---|
date | Thu, 08 Aug 2024 19:34:36 +0000 |
parents | |
children | c0b01c55a0e0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clustering_from_distmat.xml Thu Aug 08 19:34:36 2024 +0000 @@ -0,0 +1,111 @@ +<tool id="clustering_from_distmat" name="Distance matrix-based hierarchical clustering" version="1.0" profile="23.0"> + <description>using Scipy</description> + <edam_topics> + <edam_topic>topic_2269</edam_topic> + <edam_topic>topic_0084</edam_topic> + </edam_topics> + <edam_operations> + <edam_operation>operation_3432</edam_operation> + </edam_operations> + <requirements> + <requirement type="package" version="3.12">python</requirement> + <requirement type="package" version="1.14.0">scipy</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ +python '$__tool_directory__/clustering_from_distmat.py' + '$distmat' + result + --method $method + #if str($cluster_assignment.select) == 'n-cluster': + --n-clusters $cluster_assignment.n_cluster + #elif str($cluster_assignment.select) == 'height': + --height $cluster_assignment.height + #end if + ]]></command> + <inputs> + <param name="distmat" type="data" format="tabular" label="Distance matrix" /> + <param name="method" type="select" label="Clustering method"> + <option value="single">Nearest Point (scipy 'single' method)</option> + <option value="complete">Farthest Point (scipy 'complete' method)</option> + <option value="average" selected="true">UPGMA (scipy 'average' method)</option> + <option value="weighted">WPGMA (scipy 'weighted' method)</option> + <option value="centroid">UPGMC (scipy 'centroid' method)</option> + <option value="median">WPGMC (scipy 'median' method)</option> + <option value="ward">Ward/Incremental (scipy 'ward' method)</option> + </param> + <conditional name="cluster_assignment"> + <param name="select" type="select" label="Generate cluster assignments?"> + <option value="dendrogram-only">No, just generate the dendrogram of clustering results</option> + <option value="n-cluster">Yes, and divide into specified number of clusters </option> + <option value="height">Yes, and use distance threshold to divide into clusters</option> + </param> + <when value="dendrogram-only" /> + <when value="n-cluster"> + <param name="n_cluster" type="integer" value="5" min="1" label="How many clusters to divide into?" /> + <param name="generate_dendrogram" type="boolean" label="Produce also the dendrogram of clustering results" /> + </when> + <when value="height"> + <param name="height" type="float" value="5.0" label="Distance threshold for clusters to be reported" /> + <param name="generate_dendrogram" type="boolean" label="Produce also the dendrogram of clustering results" /> + </when> + </conditional> + </inputs> + <outputs> + <data name="clustering_dendrogram" format="newick" from_work_dir="result.tree.newick" label="${tool.name} on ${on_string}: Dendrogram"> + <filter>cluster_assignment["select"] == "dendrogram-only" or cluster_assignment["generate_dendrogram"]</filter> + </data> + <data name="clustering_assignment" format="tabular" from_work_dir="result.cluster_assignments.tsv" label="${tool.name} on ${on_string}: Cluster assignment"> + <filter>cluster_assignment["select"] in ["n-cluster", "height"]</filter> + </data> + </outputs> + <tests> + <!-- Test data and expected results taken from https://en.wikipedia.org/wiki/UPGMA#Working_example --> + <test expect_num_outputs="1"> + <param name="distmat" value="test_matrix.tsv"/> + <output name="clustering_dendrogram" ftype="newick" file="test_tree_average.newick" /> + </test> + <test expect_num_outputs="1"> + <param name="distmat" value="test_matrix.tsv" /> + <param name="method" value="complete" /> + <output name="clustering_dendrogram" ftype="newick" file="test_tree_complete.newick" /> + </test> + <test expect_num_outputs="1"> + <param name="distmat" value="test_matrix.tsv"/> + <conditional name="cluster_assignment"> + <param name="select" value="height" /> + <param name="height" value="18" /> + </conditional> + <output name="clustering_assignment" ftype="tabular" file="test_assignment_average_h18.tsv" /> + </test> + <test expect_num_outputs="2"> + <param name="distmat" value="test_matrix.tsv"/> + <conditional name="cluster_assignment"> + <param name="select" value="n-cluster" /> + <param name="n_cluster" value="4" /> + <param name="generate_dendrogram" value="true" /> + </conditional> + <output name="clustering_assignment" ftype="tabular" file="test_assignment_average_n4.tsv" /> + </test> + </tests> + <help><![CDATA[ + +.. class:: infomark + +**What it does** + +This tool lets you perform hierarchical clustering of samples using the `scipy.cluster.hierarchy.linkage`_ function and any of the clustering methods supported by it. + +As input it expects a symmetrical distance matrix with sample names on the first row and in the first column. + +The clustering result can be reported in the form of a dendrogram in newick format. + +Additionally, the tool can report the assignment of the samples to clusters "cut" from the clustering tree using the `scipy.cluster.hierarchy.cut_tree`_ function. +Reflecting the parameters of that function, you can specify *how* to cut the tree by specifying either the number of clusters to cut into or a distance threshold, i.e., the height at which to cut the tree as SciPy calls it. + +.. _`scipy.cluster.hierarchy.linkage`: https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html +.. _`scipy.cluster.hierarchy.cut_tree`: https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.cut_tree.html + ]]></help> + <citations> + <citation type="doi">10.1038/s41592-019-0686-2</citation> + </citations> +</tool>