diff reduce_dimensions.xml @ 0:e49429e8d6dd draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/seurat_v5 commit a9214c07b0cc929a51fd92a369bb89c675b6c88d
author iuc
date Wed, 11 Sep 2024 10:21:02 +0000
parents
children 46ed93e8da30
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reduce_dimensions.xml	Wed Sep 11 10:21:02 2024 +0000
@@ -0,0 +1,425 @@
+<tool id="seurat_reduce_dimension" name="Seurat Run Dimensional Reduction" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
+    <description>- PCA, tSNE or UMAP</description>
+    <macros>
+        <import>macros.xml</import>
+    </macros>
+    <expand macro="requirements"/>
+    <expand macro="version_command"/>
+    <command detect_errors="exit_code"><![CDATA[
+@CMD@
+    ]]></command>
+    <configfiles>
+        <configfile name="script_file"><![CDATA[
+@CMD_imports@
+@CMD_read_inputs@
+
+#if $method.method == 'RunPCA'
+
+    #if $method.features
+    features_list<-paste(readLines('$method.features'), collapse=",")
+    #end if
+
+seurat_obj<-RunPCA(
+    seurat_obj,
+    #if $method.assay != ''
+    assay = '$method.assay',
+    #end if
+    #if $method.features
+    features = c(unlist(strsplit(features_list, ","))),
+    #end if
+    npcs = $method.npcs,
+    rev.pca = $method.rev_pca,
+    weight.by.var = $method.weight_by_var,
+    reduction.key = '$method.reduction_key',
+    seed.use = $method.seed_use,
+    approx = $method.approx,
+    reduction.name = '$method.reduction_name'
+)
+
+    #if $method.print_pcs.print_pcs == 'true'
+    sink('print_pcs.txt')
+    print(
+        seurat_obj[['pca']],
+        dims = 1:$method.print_pcs.dims,
+        nfeatures = $method.print_pcs.nfeatures
+    )
+    sink()
+    #end if
+
+#else if $method.method == 'RunTSNE'
+seurat_obj<-RunTSNE(
+    seurat_obj,
+    #if $method.reduction != ''
+    reduction = '$method.reduction',
+    #end if
+    #if $method.dims
+    dims = 1:$method.dims,
+    #end if
+    #if $method.assay != ''
+    assay = '$method.assay',
+    #end if
+    seed.use = $method.seed_use,
+    tsne.method = '$method.tsne_method',
+    dim.embed = $method.dim_embed,
+    reduction.key = '$method.reduction_key',
+    reduction.name = '$method.reduction_name'
+)
+
+#else if $method.method == 'RunUMAP'
+@reticulate_hack@
+
+    #if $method.run_umap_on.run_umap_on == 'features'
+    features_list<-paste(readLines('$method.run_umap_on.features'), collapse=",")
+    #end if
+
+seurat_obj<-RunUMAP(
+    seurat_obj,
+    #if $method.reduction != ''
+    reduction = '$method.reduction',
+    #end if
+    #if $method.assay != ''
+    assay = '$method.assay',
+    #end if
+    reduction.key = '$method.adv.reduction_key',
+    reduction.name = '$method.adv.reduction_name',
+    #if $method.adv.reduction_model != ''
+    reduction.model = '$method.adv.reduction_model',
+    #end if
+    umap.method ='$method.umap_method.umap_method',
+    #if $method.umap_method.umap_method == 'umap-learn'
+    densmap = $method.umap_method.densmap.densmap,
+        #if $method.umap_method.densmap.densmap == 'TRUE'
+        dens.lambda = $method.umap_method.densmap.dens_lambda,
+        dens.frac = $method.umap_method.densmap.dens_frac,
+        dens.var.shift = $method.umap_method.densmap.dens_var_shift,
+        #end if
+    #end if
+    n.neighbors = $method.n_neighbors,
+    n.components = $method.n_components,
+    metric = '$method.metric',
+    #if $method.adv.n_epochs
+    n.epochs = $method.adv.n_epochs,
+    #end if
+    learning.rate = $method.adv.learning_rate,
+    min.dist = $method.adv.min_dist,
+    spread = $method.adv.spread,
+    set.op.mix.ratio = $method.adv.set_op_mix_ratio,
+    local.connectivity = $method.adv.local_connectivity,
+    repulsion.strength = $method.adv.repulsion_strength,
+    negative.sample.rate = $method.adv.negative_sample_rate,
+    #if $method.adv.a != ''
+    a = '$method.adv.a',
+    #end if
+    #if $method.adv.b != ''
+    b = '$method.adv.b',
+    #end if
+    uwot.sgd = $method.adv.uwot_sgd,
+    seed.use = $method.adv.seed_use,
+    angular.rp.forest = $method.adv.angular_rp_forest,
+    #if $method.run_umap_on.run_umap_on == 'dims'
+    dims = 1:$method.run_umap_on.dims,
+    #else if $method.run_umap_on.run_umap_on == 'features'
+    features = c(unlist(strsplit(features_list, ","))),
+    slot = '$method.run_umap_on.slot',
+    #else if $method.run_umap_on.run_umap_on == 'graph'
+    graph = '$method.run_umap_on.graph',
+    #else if $method.run_umap_on.run_umap_on == 'nn_name'
+    nn.names = '$method.run_umap_on.nn_name',
+    #end if
+)
+
+#end if
+
+@CMD_rds_write_outputs@
+
+]]></configfile>
+    </configfiles>
+    <inputs>
+        <expand macro="input_rds"/>
+        <conditional name="method">
+            <param name="method" type="select" label="Method used">
+                <option value="RunPCA">Run a PCA dimensionality reduction using 'RunPCA'</option>
+                <option value="RunTSNE">Run a t-SNE dimensionality reduction using 'RunTSNE'</option>
+                <option value="RunUMAP">Run a UMAP dimensional reduction using 'RunUMAP'</option>
+            </param>
+            <when value="RunPCA">
+                <expand macro="select_assay"/>
+                <param argument="npcs" type="integer" value="50" label="Number of PCs to compute"/>
+                <param name="rev_pca" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Compute the PCA on the 'gene x cell' matrix instead of 'cell x gene' matrix" help="(rev.pca)"/>
+                <param name="weight_by_var" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="true" label="Weight the cell embeddings by the variance of each PC" help="(weight.by.var)"/>
+                <param name="seed_use" type="integer" value="42" label="Set a random seed" help="(seed.use)"/>
+                <param argument="approx" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="true" label="Use truncated singular value decomposition to approximate PCA"/>
+                <param argument="features" type="data" format="txt,tabular" optional="true" label="List of features to compute PCA on" help="text file with one feature on each line, default is variable features"/>
+                <param name="reduction_name" type="text" value="pca" label="Name for dimensional reduction" help="(reduction.name)">
+                    <expand macro="valid_name"/>
+                </param>
+                <param name="reduction_key" type="text" value="PC_" label="Dimensional reduction key" help="specifies the string before the number for the dimension names (reduction.key)">
+                        <expand macro="valid_reduction_key"/>
+                </param>
+                <conditional name="print_pcs">
+                    <param name="print_pcs" type="select" label="Output list of top genes">
+                        <option value="false" selected="true">No</option>
+                        <option value="true">Yes</option>
+                    </param>
+                    <when value="false">
+                    </when>
+                    <when value="true">
+                        <param argument="dims" type="integer" value="5" label="Number of PCs to print genes for"/>
+                        <param argument="nfeatures" type="integer" value="5" label="Number of top genes to print for each PC"/>
+                    </when>
+                </conditional>
+            </when>
+            <when value="RunTSNE">
+                <expand macro="select_reduction_pca"/>
+                <expand macro="set_dims"/>
+                <expand macro="select_assay"/>
+                <param name="tsne_method" type="select" label="Select the method to use to compute the tSNE" help="(tsne.method)">
+                    <option value="Rtsne" selected="true">Rtsne</option>
+                    <option value="FIt-SNE">FIt-SNE</option>
+                </param>
+                <param name="seed_use" type="integer" value="1" label="Set a random seed" help="(seed.use)"/>
+                <param name="dim_embed" type="integer" value="2" label="Set the dimensional space of the tSNE embedding" help="(dim.embed)"/>
+                <param name="reduction_name" type="text" value="tsne" label="Name for dimensional reduction" help="(reduction.name)">
+                    <expand macro="valid_name"/>
+                </param>
+                <param name="reduction_key" type="text" value="tSNE_" label="Dimensional reduction key" help="specifies the string before the number for the dimension names (reduction.key)">
+                    <expand macro="valid_reduction_key"/>
+                </param>
+            </when>
+            <when value="RunUMAP">
+                <expand macro="select_reduction_pca"/>
+                <expand macro="select_assay"/>
+                <conditional name="umap_method">
+                    <param name="umap_method" type="select" label="UMAP implementation to run" help="(umap.method)">
+                        <option value="uwot" selected="true">uwot</option>
+                        <option value="uwot-learn">uwot-learn</option>
+                        <option value="umap-learn">umap-learn</option>
+                    </param>
+                    <when value="uwot">
+                    </when>
+                    <when value="uwot-learn">
+                    </when>
+                    <when value="umap-learn">
+                        <conditional name="densmap">
+                            <param argument="densmap" type="select" label="Use the density-augmented objective of densMAP">
+                                <option value="TRUE">Yes</option>
+                                <option value="FALSE" selected="true">No</option>
+                            </param>
+                            <when value="TRUE">
+                                <param name="dens_lambda" type="integer" optional="true" value="2" label="Control the regularization weight of densMAP density correlation term" help="(dens.lambda)"/>
+                                <param name="dens_frac" type="float" optional="true" min="0" max="1" value="0.3" label="Control the fraction of epochs where density-augmented objective is used in densMAP" help="(dens.frac)"/>
+                                <param name="dens_var_shift" type="float" optional="true" value="0.1" label="Constant to add to variance of local radii when calculating density correlation objective" help="(dens.var.shift)"/>
+                            </when>
+                            <when value="FALSE">
+                            </when>
+                        </conditional>
+                    </when>
+                </conditional>
+                <param name="n_neighbors" type="integer" value="30" label="Number of neighbors to use" help="Usually in range 5-50 (n.neighbors)"/>
+                <param name="n_components" type="integer" value="2" label="Dimension of the space to embed into" help="(n.components)"/>
+                <param argument="metric" type="select" label="Choose metric to use to measure distances in the input space">
+                    <option value="cosine" selected="true">cosine</option>
+                    <option value="correlation">correlation</option>
+                    <option value="euclidean">euclidean</option>
+                    <option value="manhattan">manhattan</option>
+                    <option value="hamming">hamming</option>
+                </param>
+                <conditional name="run_umap_on">
+                    <param name="run_umap_on" type="select" label="Run UMAP on dimensions, features, graph or KNN output">
+                        <option value="dims" selected="true">dims</option>
+                        <option value="features">features</option>
+                        <option value="graph">graph</option>
+                        <option value="nn_name">nn.name</option>
+                    </param>
+                    <when value="dims">
+                        <expand macro="set_dims"/>
+                    </when>
+                    <when value="features">
+                        <param argument="features" type="data" format="txt,tabular" optional="true" label="Run UMAP on this subset of features" help="text file with one feature on each line"/>
+                        <expand macro="select_slot_data"/>
+                    </when>
+                    <when value="graph">
+                        <param argument="graph" type="text" optional="true" value="" label="Name of graph on which to run UMAP">
+                            <expand macro="valid_name"/>
+                        </param>
+                    </when>
+                    <when value="nn_name">
+                        <param name="nn_name" type="text" optional="true" value="" label="Name of KNN output on which to run UMAP" help="(nn.name)">
+                            <expand macro="valid_name"/>
+                        </param>
+                    </when>
+                </conditional>
+                <section name="adv" title="Advanced Options">
+                    <param name="reduction_model" type="text" optional="true" value="" label="DimReduct object that contains the umap model" help="(reduction.model)"/>
+                    <param name="n_epochs" type="integer" optional="true" value="" label="Set the number of training epochs to use to optimise the embedding" help="if left empty, will be set as 500 for small datasets, 200 for large datasets (n.epochs)"/>
+                    <param name="learning_rate" type="integer" value="1" label="Initial learning rate for the embedding optimization" help="(learning.rate)"/>
+                    <param name="min_dist" type="float" value="0.3" label="Control how tightly points are compressed in the embedding" help="sensible values are in the range 0.001 to 0.5 (min.dist)"/>
+                    <param argument="spread" type="integer" value="1" label="Effective spread of embedded points"/>
+                    <param name="set_op_mix_ratio" type="float" value="1.0" label="Interpolate between fuzzy union and intersection" help="(set.op.mix.ratio)"/>
+                    <param name="local_connectivity" type="integer" value="1" label="Set local connectivity" help="the number of nearest neighbors assummed to connect at local level (local.connectivity)"/>
+                    <param name="repulsion_strength" type="integer" value="1" label="Apply weighting to negative values" help="(repulsion.strength)"/>
+                    <param name="negative_sample_rate" type="integer" value="5" label="Number of negative samples to select per positive sample during optimization" help="(negative.sample.rate)"/>
+                    <param argument="a" type="text" optional="true" value="" label="Parameter 'a' of differentiable approximation of right adjoint functor" help="automatically set if left empty"/>
+                    <param argument="b" type="text" optional="true" value="" label="Parameter 'b' of differentiable approximation of right adjoint functor" help="automatically set if left empty"/>
+                    <param name="uwot_sgd" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked ="false" label="Set uwot::umap(fast_sgd = TRUE)" help="(uwot.sgd)"/>
+                    <param name="seed_use" type="integer" value="42" label="Set a random seed" help="(seed.use)"/>
+                    <param name="angular_rp_forest" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="false" label="Use an angular random projection forest to initialise nearest neighbors" help="(angular.rp.forest)"/>
+                    <param name="reduction_name" type="text" value="umap" label="Name for dimensional reduction" help="(reduction.name)">
+                        <expand macro="valid_name"/>
+                    </param>
+                    <param name="reduction_key" type="text" value="UMAP_" label="Dimensional reduction key" help="specifies the string before the number for the dimension names (reduction.key)">
+                        <expand macro="valid_reduction_key"/>
+                    </param>
+                </section>
+            </when>
+        </conditional>
+        <expand macro="inputs_common_advanced"/>
+    </inputs>
+    <outputs>
+        <expand macro="seurat_outputs"/>
+        <expand macro="print_top_pcs"/>
+    </outputs>
+    <tests>
+        <test expect_num_outputs="3">
+            <!-- test1: RunPCA -->
+            <param name="seurat_rds" location="https://zenodo.org/records/13732784/files/scaled.rds"/>
+            <conditional name="method">
+                <param name="method" value="RunPCA"/>
+                <conditional name="print_pcs">
+                    <param name="print_pcs" value="true"/>
+                </conditional>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="RunPCA"/>
+                </assert_contents>
+            </output>
+            <output name="rds_out" location="https://zenodo.org/records/13732784/files/pca.rds" ftype="rds" compare="sim_size"/>
+            <output name="top_pcs" location="https://zenodo.org/records/13732784/files/top_pcs.txt" ftype="txt">
+                <assert_contents>
+                    <has_text_matching expression="PC_" n="5"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test2: RuntSNE -->
+            <param name="seurat_rds" location="https://zenodo.org/records/13732784/files/clusters.rds"/>
+            <conditional name="method">
+                <param name="method" value="RunTSNE"/>
+                <param name="seed.use" value="1"/>
+                <param name="tsne_method" value="Rtsne"/>
+                <param name="dim_embed" value="2"/>
+                <param name="reduction_key" value="tSNE_"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="RunTSNE"/>
+                </assert_contents>
+            </output>
+            <output name="rds_out" location="https://zenodo.org/records/13732784/files/tSNE.rds" ftype="rds" compare="sim_size"/>
+        </test>
+                <test expect_num_outputs="2">
+            <!-- test3: RuntSNE with FIt-SNE -->
+            <param name="seurat_rds" location="https://zenodo.org/records/13732784/files/clusters.rds"/>
+            <conditional name="method">
+                <param name="method" value="RunTSNE"/>
+                <param name="seed.use" value="1"/>
+                <param name="tsne_method" value="FIt-SNE"/>
+                <param name="dim_embed" value="2"/>
+                <param name="reduction_key" value="tSNE_"/>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="RunTSNE"/>
+                </assert_contents>
+            </output>
+            <output name="rds_out" location="https://zenodo.org/records/13732784/files/FIt-SNE.rds" ftype="rds" compare="sim_size"/>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test4: RunUMAP -->
+            <param name="seurat_rds" location="https://zenodo.org/records/13732784/files/clusters.rds"/>
+            <conditional name="method">
+                <param name="method" value="RunUMAP"/>
+                <param name="reduction_key" value="UMAP_"/>
+                <conditional name="umap_method">
+                    <param name="umap_method" value="uwot"/>
+                </conditional>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="RunUMAP"/>
+                </assert_contents>
+            </output>
+            <output name="rds_out" location="https://zenodo.org/records/13732784/files/umap.rds" ftype="rds" compare="sim_size"/>
+        </test>
+        <test expect_num_outputs="2">
+            <!-- test5: RunUMAP - umap-learn -->
+            <param name="seurat_rds" location="https://zenodo.org/records/13732784/files/clusters.rds"/>
+            <conditional name="method">
+                <param name="method" value="RunUMAP"/>
+                <param name="reduction_key" value="UMAP_"/>
+                <conditional name="umap_method">
+                    <param name="umap_method" value="umap-learn"/>
+                    <conditional name="densmap">
+                        <param name="densmap" value="FALSE"/>
+                    </conditional>
+                </conditional>
+            </conditional>
+            <section name="advanced_common">
+                <param name="show_log" value="true"/>
+            </section>
+            <output name="hidden_output">
+                <assert_contents>
+                    <has_text_matching expression="RunUMAP"/>
+                </assert_contents>
+            </output>
+            <output name="rds_out" location="https://zenodo.org/records/13732784/files/umap-learn.rds" ftype="rds" compare="sim_size"/>
+        </test>
+    </tests>
+    <help><![CDATA[
+Seurat
+======
+
+Seurat is an R package designed for QC, analysis, and exploration of single-cell RNA-seq data.
+
+Seurat aims to enable users to identify and interpret sources of heterogeneity from single-cell transcriptomic measurements, and to integrate diverse types of single-cell data.
+
+RunPCA
+======
+
+Run a PCA dimensionality reduction.
+
+More details on the `seurat documentation
+<https://satijalab.org/seurat/reference/runpca>`__
+
+RuntSNE
+=======
+
+Run t-SNE dimensionality reduction on selected features.
+
+More details on the `seurat documentation
+<https://satijalab.org/seurat/reference/runtsne>`__
+
+RunUMAP
+=======
+
+Runs the Uniform Manifold Approximation and Projection (UMAP) dimensional reduction technique.
+
+More details on the `seurat documentation
+<https://satijalab.org/seurat/reference/runumap>`__
+
+    ]]></help>
+    <expand macro="citations"/>
+</tool>