view scanpy-neighbours.xml @ 28:6417cccad133 draft

planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/tree/develop/tools/tertiary-analysis/scanpy commit 6c9d530aa653101e9e21804393ec11f38cddf027-dirty
author ebi-gxa
date Thu, 16 Feb 2023 13:29:23 +0000
parents fcaa9048cdaf
children f776e3ed3c03
line wrap: on
line source

<?xml version="1.0" encoding="utf-8"?>
<tool id="scanpy_compute_graph" name="Scanpy ComputeGraph" version="@TOOL_VERSION@+galaxy9" profile="@PROFILE@">
  <description>to derive kNN graph</description>
  <macros>
    <import>scanpy_macros2.xml</import>
  </macros>
  <expand macro="requirements"/>
  <command detect_errors="exit_code"><![CDATA[
ln -s '${input_obj_file}' input.h5 &&
PYTHONIOENCODING=utf-8 scanpy-neighbors
#if $settings.default == "false"
    #if $settings.n_neighbors_file
        #set f = open($settings.n_neighbors_file.__str__)
        #set n_neighbors = f.read().strip()
        #silent f.close
    #elif $settings.n_neighbors
        #set n_neighbors = $settings.n_neighbors.__str__.strip()
    #end if

    #if $n_neighbors
        --n-neighbors $n_neighbors
    #end if
    #if $settings.key_added
        #set key_added = $settings.key_added
        #if $n_neighbors
            #set key_added = $key_added.replace('N_NEIGHBORS', $n_neighbors.__str__)
        #end if
        --key-added '${key_added}'
    #end if

    --method '${settings.method}'
    --metric '${settings.metric}'
    --random-state '${settings.random_seed}'
    #if $settings.use_rep
        --use-rep '${settings.use_rep}'
    #end if
    #if $settings.n_pcs
        --n-pcs '${settings.n_pcs}'
    #end if
    ${settings.knn}
#end if
    @INPUT_OPTS@
    @OUTPUT_OPTS@
]]></command>

  <inputs>
    <expand macro="input_object_params"/>
    <expand macro="output_object_params"/>
    <conditional name="settings">
      <param name="default" type="boolean" checked="true" label="Use programme defaults"/>
      <when value="true"/>
      <when value="false">
        <param name="key_added" argument="--key-added" type="text" optional="true" label="Key added"
            help="If not specified, the 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’]." value='' />
        <param name="n_neighbors" argument="--n-neighbors" type="integer" value="15" label="Maximum number of neighbors used"/>
        <param name="n_neighbors_file" argument="--n-neighbors" type="data" format="txt,tsv" optional="true"
               label="File with n_neighbours, use with parameter iterator. Overrides the n_neighbors setting"/>
        <param name="use_rep" argument="--use-rep" type="text" optional="true" label="Use the indicated representation" help="'X' (for the content of .X, usually normalised expression values) or any key for .obsm (e.g. X_pca for PCA) is valid. If not set, the representation is chosen automatically: For .n_vars less than 50, .X is used, otherwise ‘X_pca’ is used. If ‘X_pca’ is not present, it’s computed with default parameters."/>
        <param name="n_pcs" argument="--n-pcs" type="integer" value="50" optional="true" label="Number of PCs to use"/>
        <param name="knn" argument="--knn" type="boolean" truevalue="" falsevalue="--no-knn" checked="true"
               label="Use hard threshold to restrict neighbourhood size (otherwise use a Gaussian kernel to down weight distant neighbors)"/>
        <param name="method" argument="--method" type="select" label="Method for calculating connectivity">
          <option value="umap" selected="true">UMAP</option>
          <option value="gauss">Gaussian</option>
          <option value="rapids">RAPIDS</option>
        </param>
        <param name="metric" argument="--metric" type="select" label="A known metric’s name">
          <option value="euclidean" selected="true">Euclidean</option>
          <option value="cityblock">cityblock</option>
          <option value="cosine">cosine</option>
          <option value="l1">l1</option>
          <option value="l2">l2</option>
          <option value="manhattan">manhattan</option>
          <option value="braycurtis">braycurtis</option>
          <option value="canberra">canberra</option>
          <option value="chebyshev">chebyshev</option>
          <option value="correlation">correlation</option>
          <option value="dice">dice</option>
          <option value="hamming">hamming</option>
          <option value="jaccard">jaccard</option>
          <option value="kulsinski">kulsinski</option>
          <option value="mahalanobis">mahalanobis</option>
          <option value="minkowski">minkowski</option>
          <option value="rogerstanimoto">rogerstanimoto</option>
          <option value="russelrao">russelrao</option>
          <option value="seuclidan">seuclidian</option>
          <option value="sokalmichener">sokalmichener</option>
          <option value="sokalsneath">sokalsneath</option>
          <option value="sqeuclidean">sqeuclidean</option>
          <option value="yule">yule</option>
        </param>
        <param name="random_seed" argument="--random-seed" type="integer" value="0" label="Seed for random number generator"/>
      </when>
    </conditional>
  </inputs>

  <outputs>
    <expand macro="output_data_obj" description="Graph object"/>
  </outputs>

  <tests>
    <test>
      <param name="input_obj_file" value="run_pca.h5"/>
      <param name="input_format" value="anndata"/>
      <param name="output_format" value="anndata"/>
      <param name="default" value="false"/>
      <param name="n_neighbors_file" value="n_neighbors.txt"/>
      <param name="n_pcs" value="50"/>
      <param name="knn" value="true"/>
      <param name="random_seed" value="0"/>
      <param name="method" value="umap"/>
      <output name="output_h5" file="compute_graph.h5" ftype="h5" compare="sim_size"/>
    </test>
    <test>
      <param name="input_obj_file" value="run_pca.h5"/>
      <param name="input_format" value="anndata"/>
      <param name="output_format" value="anndata"/>
      <param name="default" value="false"/>
      <param name="n_neighbors" value="15"/>
      <param name="n_pcs" value="50"/>
      <param name="knn" value="true"/>
      <param name="random_seed" value="0"/>
      <param name="method" value="umap"/>
      <output name="output_h5" file="compute_graph.h5" ftype="h5" compare="sim_size"/>
    </test>
  </tests>

  <help><![CDATA[
=============================================================
Compute a neighborhood graph of observations (`pp.neighbors`)
=============================================================

The neighbor search efficiency of this heavily relies on UMAP (McInnes et al, 2018),
which also provides a method for estimating connectivities of data points -
the connectivity of the manifold (`method=='umap'`). If `method=='Gaussian'`,
connectivities are computed according to Coifman et al (2005), in the adaption of
Haghverdi et al (2016).

@HELP@

@VERSION_HISTORY@
]]></help>
  <expand macro="citations"/>
</tool>