view cell-browser.xml @ 6:97483e5ec21e draft default tip

planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/tree/develop/tools/tertiary-analysis/ucsc-cell-browser/.shed.yml commit 30c232088d42557d13359dfa26f9c7ce5edfc444
author ebi-gxa
date Sat, 15 Jul 2023 09:25:00 +0000
parents 544d44faa8bf
children
line wrap: on
line source

<tool id="ucsc_cell_browser" name="UCSC Cell Browser" version="1.0.0+galaxy1" profile="18.01">
  <description>displays single-cell clusterized data in an interactive web application.</description>
  <requirements>
    <requirement type="package" version="1.0.0">ucsc-cell-browser</requirement>
  </requirements>
<stdio>
<exit_code range="1:" />
<regex source="both" match="Killed" level="fatal_oom" description="Killed, most likely due to OOM" />
</stdio>
<command><![CDATA[
#if $input_type.expression_source == "native-cell-browser":

   echo "coords = [ {'file':'$tsneCoordinates', 'shortLabel':'t-SNE'} ]" > ./cellbrowser.conf;
   echo "meta = '$cellMetadata'" >> ./cellbrowser.conf;
   echo "name = 'sample'" >> ./cellbrowser.conf;
   echo "exprMatrix = '$expressionMatrix'" >> ./cellbrowser.conf;
   echo "geneIdType = 'symbol'" >> ./cellbrowser.conf;

   cbBuild -i cellbrowser.conf -o "$html_file.extra_files_path";

   ## "sample" is used as name, so no change needed.
   # cp '$__tool_directory__/redirect.html' '$html_file';
   mv '$redirect_html' '$html_file';

#else if $input_type.expression_source == "cell-browser-tar":

   tar -xf '$tarred_sources';
   cbBuild -i cellbrowser.conf -o "$html_file.extra_files_path";

   ## we need to adapt redirect to use the study name used in cellbrowser.conf
   study=\$(grep '^name=' cellbrowser.conf | awk -F'=' '{ print $2 }' | sed s/\"//g ) &&
   echo "Study to replace: "\$study &&
   ## sed "s/ds=sample/ds=\$study/" '$__tool_directory__/redirect.html' > '$html_file';
   sed "s/ds=sample/ds=\$study/" '$redirect_html' > '$html_file';

#else if $input_type.expression_source == "scanpy":

   ## We could add a condition here were, if cluster_field is provided
   ## then we rename it inside with an AnnData relying script to read 'louvain' to please UCSC CellBrowser

   ln -s '$input_anndata_file' scanpy_ann_data.h5ad;
   cbImportScanpy -i scanpy_ann_data.h5ad

   #if $input_type.marker_field:
     --markerField '${input_type.marker_field}'
   #end if

   #if $input_type.cluster_field:
     --clusterField '${input_type.cluster_field}'
   #end if


     -o outdir -n sample --htmlDir '$html_file.extra_files_path';
   ## cp '$__tool_directory__/redirect.html' '$html_file';
   mv '$redirect_html' '$html_file';

#end if
]]></command>
<configfiles>
    <configfile name="redirect_html"><![CDATA[
      <!DOCTYPE HTML>
      <html lang="en-US">
          <head>
              <meta charset="UTF-8">
              <meta http-equiv="refresh" content="0; url=index.html?ds=sample">
              <script type="text/javascript">
                  window.location.href = "index.html?ds=sample"
              </script>
              <title>Page Redirection</title>
          </head>
          <body>
              <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
              If you are not redirected automatically, follow this <a href='index.html?ds=sample'>link to example</a>.
          </body>
      </html>
    ]]></configfile>
</configfiles>
<inputs>
  <conditional name="input_type">
    <param type="select" name="expression_source" label="Choose the format of the expression data" help="Use compressed txt, Scanpy or Seurat objects">
      <option value="native-cell-browser" selected="true">CellBrowser tar.gz expression matrix</option>
      <option value="scanpy">Scanpy AnnData HDF5 serialized object</option>
      <option value="cell-browser-tar">Tar file with CellBrowser files to execute cbBuild</option>
    </param>
    <when value="native-cell-browser">
      <param type="data" name="expressionMatrix" label="Expression matrix" help="Tabular expression matrix (see https://github.com/maximilianh/cellBrowser/tree/master/sampleData)" format="tabular"/>
      <param type="data" name="cellMetadata" label="Cell metadata" help="Tabular file with metadata fields (columns) for each cell (rows)." format="tabular"/>
      <param type="data" name="tsneCoordinates" label="tSNE coordinates" help="Tabular file with tSNE coordinates for each cell." format="tabular"/>
    </when>
    <when value="cell-browser-tar">
      <param name="tarred_sources" type="data" format="tar" label="CellBrowser source files tarred" help="Tar containing CellBrowser config, tsne, umap and other source files for running cbBuild"/>
    </when>
    <when value="scanpy">
      <param name="input_anndata_file" type="data" format="h5,h5ad" label="Input object in AnnData hdf5 format" help="Scanpy serialized output is by default produced as an AnnData hdf5 file."/>
      <param name="marker_field" argument="--markerField" type="text" value="rank_genes_groups" label="Marker genes field" help="Scanpy marker genes field to use (part of uns), optional, if not set 'rank_genes_groups' will be used."/>
      <param name="cluster_field" argument="--clusterField" type="text" label="Cluster field" help="Scanpy cluster field to use in obs. Optional, if not set 'louvain' will be used. If the AnnData object doesn't not have 'louvain' among its clustering fields in obs, then this NEEDS to be set or UCSC CellBrowser will fail."/>
    </when>
  </conditional>
</inputs>
<outputs>
    <data format="html" name="html_file" label="${tool.name} on ${on_string}: Interactive Viewer"/>
</outputs>

<!-- Test data not included due to size, to obtain it execute get_test_data.sh -->
<tests>
  <test>
    <conditional name="input_type">
      <param name="expression_source" value="scanpy"/>
      <param name="input_anndata_file" ftype="h5ad" value="E-MTAB-6077.project.h5ad"/>
      <param name="marker_field" value="markers_louvain_resolution_0.7"/>
      <param name="cluster_field" value="louvain_resolution_0.7"/>
    </conditional>
    <output name="html_file">
      <!-- mostly checking that execution doesn't fail, we cannot access the files
      with relevant content to check it -->
      <assert_contents>
          <has_text text="If you are not redirected automatically" />
      </assert_contents>
    </output>
  </test>
</tests>

<help><![CDATA[
UCSC Single Cell Browser
========================

Funded by the California Institute of Regenerative Medicine and the Chan-Zuckerberg
Initiative https://www.chanzuckerberg.com/.

The UCSC Cell Browser is a viewer for single cell data. You can click on and hover
over cells to get meta information, search for genes to color on and click clusters
to show cluster-specific marker genes, which in turn are clickable again.

For a demo of the browser, see http://cells.ucsc.edu

Usage
-----

After choosing the inputs and executing the tool, once the history item becomes
green, press the View data (eye icon) button, which will open the generated UCSC Cell Browser
interactive site.

For EBI Single Cell Expression Atlas AnnData files (available from http://ftp.ebi.ac.uk/pub/databases/microarray/data/atlas/sc_experiments/
<accession> / <accession>.project.h5ad ), use `markers_louvain_resolution_<value>`
for Marker genes fields and `louvain_resolution_<value>` for Cluster field. There will be different
resolution values available, you can see them by executing `Inspect AnnData` tool, select
and set "What to inspect" to "General information about the object". Then look in the results under
obs and uns.

Troubleshooting
---------------

Depending on the window size when pressing the "View data" button, you might see a black canvas and a diminished panel to the upper left
with the text "Choose cell...". If that is the case, close that panel (click on the cross)
and then choose File -> Open Dataset... and then press the Open Dataset white button.

Version history
---------------

0.4.3+galaxy0: Initial contribution. Pablo Moreno, Expression Atlas team https://www.ebi.ac.uk/gxa/home  at
EMBL-EBI https://www.ebi.ac.uk/.

0.4.38+galaxy0: Supports Seurat (through a converter) and Scanpy input. Pablo Moreno, Expression Atlas team https://www.ebi.ac.uk/gxa/home  at
EMBL-EBI https://www.ebi.ac.uk/.

0.5.21+galaxy0: Update UCSC CellBrowser version to 0.5.21. Pablo Moreno, Expression Atlas team https://www.ebi.ac.uk/gxa/home  at
EMBL-EBI https://www.ebi.ac.uk/.

0.5.38+galaxy0: Update UCSC CellBrowser version to 0.5.43. Fixes bugs and improves usage of gene symbols in AnnData objects. Pablo Moreno, Expression Atlas team https://www.ebi.ac.uk/gxa/home  at
EMBL-EBI https://www.ebi.ac.uk/.

1.0.0+galaxy0: Update UCSC CellBrowser version to 1.0.0. Fixes bugs and improves support for AnnData objects. Pablo Moreno, Expression Atlas team https://www.ebi.ac.uk/gxa/home  at
EMBL-EBI https://www.ebi.ac.uk/.
]]></help>
<citations>
 <citation type="bibtex">
  @misc{ucsc-cell-browser-gitrepo,
  author = {Maximilian Haeussler and collaborators},
  year = {2018},
  title = {UCSC Single Cell Browser: Python pipeline and Javascript scatter plot library for single-cell datasets},
  publisher = {GitHub},
  journal = {GitHub repository},
  url = {https://github.com/maximilianh/cellBrowser},
 }
 </citation>
 <citation type="doi">10.1038/s41592-021-01102-w</citation>
 <citation type="doi">10.1101/2020.10.30.361162</citation>
</citations>
</tool>