This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to perform iteration task inside a docker image (RNA-seq analysis)

Hi, there

I am using docker containers to run a pipeline for RNA-seq analysis. Specifically, I am using cufflinks now, to quantitate and annotate the transcripts. I am dealing with 770 .bam files (aligned by TopHat), and running the following code for each one of them:

cufflinks -b hg19.fa -g hg19.refGene.gtf -u [sample.bam]

I would very much like to let cufflinks run across all those samples without the need of manually putting the command for each one of them. And that would also allow for the machine to run non-stop until it's done. So, my question is:

Is there any way to create an iteration procedure/command for that?

PS: I am running the docker image within an interactive shell (arguments -it)

Any help is very much appreciated!

rna-seq quantification docker

1 answer

I would highly recommend using nextflow or some other workflow manager as they are designed precisely for the task you are describing.

You can write a simple script to read in the bam files, and execute the cufflinks command. Using the -with-docker flag will tell it to run it inside the container where your tools are.

Something like:

#!/usr/bin nextflow

params.bams = "/path/to/bams/*.bam"
Channel 
     .frompath( params.bams )
     .set{ bams }

params.genome = "/path/to/hg19.fa"
genome_file = file(params.genome)

params.gtf = "path/to/hg19.gtf"
gtf_file = file(params.gtf)

process cufflinks{
     publishDir "Results", mode:'copy'

    input:
    file bam from bams
    file genome from genome_file
    file gtf from gtf_file

    output:
    file "*.gtf" into outputs

    script:
    """
    cufflinks -b $genome -g $gtf -u $bam
    """
}

Should be more than enough to get you up and running there. Nextflow is easy to install and you will not run into sudo problems (assuming you are on a HPC with 700+ bams).

Thanks a lot, @Barry Digby! That's the first time I heard about nextflow. I will definitely give it a go and post a follow-up here. Many thanks again!

No problem. Let me know if you run into trouble :)

Log in to answer this question.