3
$\begingroup$

Not going to lie, my head hurts when I read the NextFlow documentation (No dig on the documentation, I think my head is losing its processing capacity lol).

I had written a pipeline in Bash, essentially iterates over a text file containing full paths of R1 and R2 reads, followed by a series of commands and liberal use of gnu parallel to improve efficiency.

Is there any template I can follow, where I can slot in my commands and get things running quickly?

EDIT - The skeleton of pipeline goes as follows (As I'm not sure if I can put our inhouse pipeline in its entirety here) -

Bash code which loops through R1 and R2, aligns with BWA-mem2 and sorts the bam, then using gnu parallel, I essentially follow the steps as outlined in GATK Best Practices (looking to drop BQSR, but the steps remain) to obtain a gvcf file. The steps in Best Practices have been turned to functions, rather than each step being called sequentially.

$\endgroup$
3
  • 2
    $\begingroup$ Please edit your question and show us your code. Nobody can help if they don't know what your code actually does. But, that said, every pipeline is different so I really doubt there will ever be a "template". $\endgroup$
    – terdon
    Commented May 3, 2023 at 14:36
  • 2
    $\begingroup$ Hi KarthikNair could you kindly supply the code or else a reproducible example? Otherwise there are a lot of NextFlow questions and answers on Bioinformatics SE, particularly answered by user @Steve, and those would likely provide pointers. To be honest it's not possible to answer the question as it stands in my personal opinion. I've a reasonable understanding of NextFlow, but I'm not an expert. $\endgroup$
    – M__
    Commented May 3, 2023 at 14:37
  • $\begingroup$ I have mentioned the brief gist about the pipeline, essentially we are following GATK best practices for variant calling (humans). $\endgroup$ Commented May 3, 2023 at 15:10

3 Answers 3

5
$\begingroup$

If your objective is to convert Bash scripts into Nextflow code, you might find Viash (https://viash.io) a particularly useful open source tool. It automatically generates independent Nextflow modules from each of your scripts, along with the corresponding Docker containers for each module. Docker containers are generated on the fly based on your config description in Viash. These modules can be coupled together to build a (modular) Nextflow pipeline.

$\endgroup$
2
  • $\begingroup$ Thanks for answering the question as written! Super helpful! $\endgroup$ Commented May 31, 2023 at 6:58
  • $\begingroup$ Generating Docker containers on the fly is part of the behaviour of NextFlow per se, which is why it's so cool. However, I know zero about Viash. It would be useful if someone could give feedback on Viash.io because it may not possibly work as advertised here .... The question was flagged for hidden issues, i.e. it may not work as advertised, so I would recommend proceeding with care. $\endgroup$
    – M__
    Commented Jun 1, 2023 at 13:23
2
$\begingroup$

The gist would be something like:

fastqs = Channel.of(...some annoying groovy code to make this a list of tuples...)
workflow{
  align(fastqs)
  makeGVCF(align.out.bams)
  ... collect() the output from above joint call them all...
}

process align {
  input:
    tuple val(sampleName), path(reads)
  output:
    tuple val(sampleName), path("${sampleName}.bam"), emit: bams
  """
  bwa ... | samtools sort ...
  """
}

process makeGVCF{
  input:
    tuple val(sampleName), path(bam)
  output:
    path "${sampleName}.gvcf", emit: gvcfs
  """
  ...haplotype caller code...
  """
}
$\endgroup$
2
  • 1
    $\begingroup$ The usual way would be to use either the fromFilePairs factory method, or to read from a samplesheet using the fromPath factory and the splitCsv operator, e.g. Channel.fromPath( params.samplesheet ).splitCsv( header:true ).map { row -> tuple( row.sample, [ row.fastq1, row.fastq2 ] ) }.set { readgroups }. Then align( readgroups ). $\endgroup$
    – Steve
    Commented May 4, 2023 at 1:11
  • $\begingroup$ I really thank you both for your inputs. But my head started hurting when I reached the end of the comments. I guess I just have to grit my teeth and push through it. $\endgroup$ Commented May 4, 2023 at 5:41
2
$\begingroup$

Since you asked about templates, if your task is something rather generic, there is a good chance that a module, or several, that you can use to build your workflow exists in https://nf-co.re/modules Generally I would recommend taking a look at the source of nf-core pipelines (e.g. https://nf-co.re/sarek for variant calling) to get an idea how to get your samplesheets in.

$\endgroup$
2
  • $\begingroup$ Nextflow (nextflow.io) is a workflow manager / language used to implement analysis pipelines, nf-core is an open source collection of modules and pipelines written for / in nextflow $\endgroup$
    – Niklas
    Commented May 5, 2023 at 20:24
  • $\begingroup$ Hi @Niklas thank you - I see your point. Its leveraging NextFlow and providing a link to a NextFlow template on GitHub. Got it. FYI I can use NextFlow. Its Docker container on the fly, is neat, but I agree with DevonRyan its Groovy (an obsolete language) I personally think is a bit weird. $\endgroup$
    – M__
    Commented May 5, 2023 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.