How to edit the xml file for parameters with different options?

I am trying to develop a tool based on R script. The tool should provided several methods for correlation calculation. Then there should be a parameter with options for different methods. I have set the parameter, but “there is no options available” on my local galaxy.

Here is my code:

    <param name="method" type="select" label="methods for correlation calculation"/>

            <option value="pearson">Pearson </option>
            <option value="spearman">Spearman  </option>
            <option value="kendall">kendall </option>
    </param>

In the corresponding R script:

spec_list$expr <- c(‘expr’, ‘f’, ‘1’, ‘character’)
spec_list$method <- c(‘method’, ‘m’, 1, ‘character’)
spec_list$correlationMatrix <- c(‘correlationMatrix’, ‘c’, 1, ‘character’)

spec <- t(as.data.frame(spec_list))
opt <- getopt(spec)

if(!is.null(opt$method)){
corMatrix <- cor(expr, method=opt$method)
}

1 Like

I am unclear here, does the select element render fine for you in the toolform? (it should)

How do you pass it to the R script? Can you show us the command from the tool?

1 Like

Hi,

I have copied the R code, I think the problem is in the tool definition xml file.

1 Like

Here are the R code:

spec_list<-list()
spec_list$help <- c(‘help’, ‘h’, ‘0’, ‘logical’)
spec_list$expressionData <- c(‘expressionData’, ‘f’, ‘1’, ‘character’)
spec_list$method <- c(‘method’, ‘m’, 1, ‘character’)
spec_list$correlationMatrix <- c(‘correlationMatrix’, ‘c’, 1, ‘character’)

spec <- t(as.data.frame(spec_list))
opt <- getopt(spec)

expressionData <- read.table(opt$expressionData)

if(!is.null(opt$method)){
corMatrix <- cor(expressionData, method=opt$method)
}

write.table(corMatrix)

1 Like

Could you please show us your <command> from the xml tool file?

1 Like

Here are my commands:

<command>
    <![CDATA[
        Rscript '${__tool_directory__}/correlationMatrix.R'
            -f $expressionData
            -m $method
            -c $correlationMatrix                  
            
            
            
    ]]>
</command>
<param name="method" type="select" label="methods for correlation calculation"/>

there is a typo "/ "
you close the parameter block before the options

2 Likes