view sceasy_convert.xml @ 1:f62bc418173f draft default tip

planemo upload for repository https://github.com/ebi-gene-expression-group/container-galaxy-sc-tertiary/ commit d125854376bf1b5c768b8513bc26f197c3373fea
author ebi-gxa
date Mon, 21 Oct 2019 12:37:29 -0400
parents ef1449a3f358
children
line wrap: on
line source

<?xml version="1.0" encoding="utf-8"?>
<tool id="sceasy_convert" name="SCEasy convert" version="@TOOL_VERSION@+galaxy1">
  <description>a data object between formats</description>
  <macros>
    <import>sceasy_macros.xml</import>
  </macros>
  <expand macro="requirements"/>
  <command detect_errors="exit_code"><![CDATA[
#if str($conversion['direction']).startswith("loom")
    ln -s ${conversion.input_object_file} input.loom &&
#else if str($conversion['direction']).startswith("anndata")
    ln -s ${conversion.input_object_file} input.h5ad &&
#else
    ln -s ${conversion.input_object_file} input.rds &&
#end if

    Rscript -e 'library(sceasy)'
#if $conversion.direction == "loom2sce"
            -e 'sce <- sceasy::convertFormat("input.loom", from="loom", to="sce", main_layer_name="${conversion.assay_name}")'
            -e 'saveRDS(sce, "output.rds")'
            -e 'print(sce)'
#else if $conversion.direction == "sce2loom"
            -e 'sce <- readRDS("input.rds")'
            -e 'sceasy::convertFormat(sce, outFile="output.loom", from="sce", to="loom", main_layer="${conversion.assay}")'
#else if $conversion.direction == "sce2anndata"
            -e 'sce <- readRDS("input.rds")'
            -e 'sceasy::convertFormat(sce, outFile="output.h5ad", from="sce", to="anndata", main_layer="${conversion.assay}")'
            -e 'print(sce)'
#else if $conversion.direction == "seurat2anndata"
            -e 'srt <- readRDS("input.rds")'
            -e 'sceasy::convertFormat(srt, outFile="output.h5ad", from="seurat", to="anndata", assay="${conversion.assay}", main_layer="${conversion.dtype}")'
            -e 'print(srt)'
#end if
]]></command>

  <inputs>
    <conditional name="conversion">
      <param name="direction" type="select" label="Direction of conversion">
        <option value="loom2sce" selected="true">Loom to SingleCellExperiment</option>
        <option value="sce2loom">SingleCellExperiment to Loom</option>
        <option value="seurat2anndata">Seurat to AnnData</option>
        <option value="sce2anndata">SingleCellExperiment to AnnData</option>
      </param>
      <when value="loom2sce">
        <param name="input_object_file" type="data" format="h5" label="Input object in Loom format"/>
        <param name="assay_name" type="text" label="Name of the expression matrix to be transferred as">
          <option value="counts" selected="true">counts</option>
          <option value="logcounts">logcounts</option>
          <option value="cpm">cpm</option>
        </param>
      </when>
      <when value="sce2loom">
        <param name="input_object_file" type="data" format="rdata" label="Input object in SingleCellExperiment RDS format"/>
        <param name="assay" type="text" label="Name of the assay to be transferred as main layer" help="Please make sure the assay exists">
          <option value="counts" selected="true">counts</option>
          <option value="logcounts">logcounts</option>
          <option value="cpm">cpm</option>
        </param>
      </when>
      <when value="sce2anndata">
        <param name="input_object_file" type="data" format="rdata" label="Input object in SingleCellExperiment RDS format"/>
        <param name="assay" type="text" label="Name of the assay to be transferred as main layer" help="Please make sure the assay exists">
          <option value="counts" selected="true">counts</option>
          <option value="logcounts">logcounts</option>
          <option value="cpm">cpm</option>
        </param>
      </when>
      <when value="seurat2anndata">
        <param name="input_object_file" type="data" format="rdata" label="Input object in Seurat RDS format"/>
        <param name="assay" type="text" value="RNA" label="Name of the assay to be transferred" help="Please make sure the assay exists"/>
        <param name="dtype" type="select" value="RNA" label="Data type of the assay to be transferred" help="Please make sure the data type exists">
          <option value="data" selected="true">data</option>
          <option value="counts">counts</option>
          <option value="scale.data">scale.data</option>
        </param>
      </when>
    </conditional>
  </inputs>

  <outputs>
    <data name="output_sce" format="rdata" from_work_dir="output.rds" label="${tool.name} on ${on_string}: SingleCellExperiment">
      <filter>conversion['direction'].endswith('sce')</filter>
    </data>
    <data name="output_loom" format="h5" from_work_dir="output.loom" label="${tool.name} on ${on_string}: Loom">
      <filter>conversion['direction'].endswith('loom')</filter>
    </data>
    <data name="output_anndata" format="h5" from_work_dir="output.h5ad" label="${tool.name} on ${on_string}: AnnData">
      <filter>conversion['direction'].endswith('anndata')</filter>
    </data>
  </outputs>

  <tests>
    <test>
      <param name="direction" value="loom2sce"/>
      <param name="input_object_file" value="input.loom"/>
      <output name="output_sce" file="output.rds" ftype="rdata" compare="sim_size"/>
    </test>
  </tests>

  <help><![CDATA[
===================================================================
Convert scRNA data object between formats `sceasy::convertFormat()`
===================================================================

Support the following conversion:
 * Loom <-> SingleCellExperiment (full)
 * SingleCellExperiment -> AnnData (matrix, metadata, reducedDim)
 * Seurat -> AnnData (matrix, metadata, reducedDim)

@HELP@

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