What's the easiest and cleanest way to get galaxy arguments (xml file input) into our R script?

Hello everyone,
I am developing galaxy tools for the first time and I would like my tools to be as simple as possible. I’m developing on R scripts. I’ve finished my xml structure with my command for running my R code :

...
    <command detect_errors="exit_code"><![CDATA[
    Rscript '$__tool_directory__/CAMERA_groupFWHM.R'
    '$image'
    $groupfwhm.sigma
    $groupfwhm.perfwhm
    $groupfwhm.intval
    ]]></command>

    <inputs>
        <param name="image" type="data" label="RData file" format="rdata.xcms.fillpeaks,rdata" help="output file from another function xcms (fillPeaks)" />
        <section name="groupfwhm" title="Group co-eluted peals based on RT" expanded="True">
            <param name="sigma" type="integer" value="6" label="the multiplier of the standard deviation"/>
            <param name="perfwhm" type="float" value="0.6" max="1" min="0" label="percentage of the width of the FWHM"/>
            <param name="intval" type="select" label="intensity values for ordering. Allowed values are into, maxo, intb">
                <option value="into" selected="true">into</option>
                <option value="maxo">maxo</option>
                <option value="intb">intb</option>
            </param>
        </section>
    </inputs>
...

I’d like to retrieve my arguments in my CAMERA_groupFWHM.R file to execute a single function:
xsAnnotateObj <- groupFWHM(xsAnnotateObj, sigma = sigma, perfwhm = perfwhm, intval = intval)

If you have a simple and clean way of transmitting your arguments between your xml file and your R script, I’d love to hear from you!

For the moment, I’m using this method to retrieve my argument :

#!/usr/bin/env Rscript

args <- commandArgs(trailingOnly = TRUE)
image <- args[1]
sigma <- as.numeric(args[2])
perfwhm <- as.numeric(args[3])
intval <- args[4]

Hi @Damien_Rat

The best way to develop tools is to use Planemo.

Full docs → Welcome to Planemo’s documentation! — Planemo 0.75.27.dev0 documentation

Start here → Building Galaxy Tools — Planemo 0.75.27.dev0 documentation

Then, to see how others have handled a particular function, find a tool written by the IUC that does something similar to what you want to do, then model after that. You can search the IUC’s github directly, or (maybe an easier navigation) find a tool hosted at a UseGalaxy server, then follow the Options → See in ToolShed links (top of each tool form in the upper right corner).

I can’t personally help with this, mostly since I’m not writing Galaxy tools everyday!, so others are still welcome to add in more! And if you want to post back what ended up working for you @Damien_Rat that would be great!

Thanks! :slight_smile:

1 Like