These are chat archives for nextflow-io/nextflow

3rd
Nov 2017
Bo
@wenbostar
Nov 03 2017 05:51
We can send parameter to shell code use variable like "$sample". But does anyone know how to send parameter to R code in script?
Evan Floden
@evanfloden
Nov 03 2017 05:56
@wenbostar For an example see the Nextflow parameter ${exp_file} here which is passed to an R script as an argument.
If your R code is inline (i.e. is written the .nf file) it should be the same.
Bo
@wenbostar
Nov 03 2017 15:08
@skptic , thanks. Do you have an example to show how to do this in R?
Bo
@wenbostar
Nov 03 2017 15:14
I want to use R functions in "script:" part.
Evan Floden
@evanfloden
Nov 03 2017 16:05
It should be the same no?
Bo
@wenbostar
Nov 03 2017 16:06
I just got an example:

params.range = 100

process test{
echo true
script:
"""

    #!/usr/bin/Rscript --vanilla

    plot(1)
    cat("in=",${params.range},"\n")

    """

}

It works now.
Evan Floden
@evanfloden
Nov 03 2017 16:07
Great!
Bo
@wenbostar
Nov 03 2017 16:07
Thanks.
Bo
@wenbostar
Nov 03 2017 18:33
Is there any example to show how to read file names from a file and put these file names into a channel to be used by a process?
Venkat Malladi
@vsmalladi
Nov 03 2017 18:37
@bo rawReads = designFilePaths
.splitCsv(sep: '\t', header: true)
.map { row -> [ row.sample_id, [row.fastq_read1, row.fastq_read2], row.experiment_id, row.biosample, row.factor, row.treatment, row.replicate, row.control_id ] }
}
i read for a csv file and map each row and save as rawReads
Bo
@wenbostar
Nov 03 2017 18:39
@vsmalladi , thanks. This is what I want. But I just want to pick some columns in the file
Do you know how to do that and can I pick the column by column name?
In my pipeline, the columns I want are always in the input file, but their positions may be changed.
Jemma Nelson
@fwip
Nov 03 2017 20:06
https://www.nextflow.io/docs/latest/operator.html#splitcsv - the "sample_id", "fastq_read1", etc in Venkat's example are the header names in the input file.
Venkat Malladi
@vsmalladi
Nov 03 2017 20:19
@fwip thanks for responding
so you shouldn’t have issues if your headers are re-arranged
Bo
@wenbostar
Nov 03 2017 20:20
I see. Thank you all @vsmalladi @fwip ~
It's really helpful.