This repository was archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
[feature] WIP: automate with nextflow #8
Draft
nh13
wants to merge
4
commits into
Magdoll:master
Choose a base branch
from
nh13:feature/nextflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| process bamtools_merge { | ||
| publishDir "${params.outdir}", mode: 'copy' | ||
|
|
||
| conda 'bioconda::lima=2.5.1' | ||
|
|
||
| input: | ||
| tuple val(sample), val(bam) | ||
|
|
||
| output: | ||
| path "${sample}.bam", emit: bam | ||
|
|
||
| shell: | ||
| """ | ||
| bamtools merge -out ${sample}.bam -in ${bam} | ||
| """ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| process ccs { | ||
| publishDir "${params.outdir}", mode: 'copy' | ||
|
|
||
| conda 'bioconda::pbccs=6.0.0' | ||
|
|
||
| input: | ||
| path bam | ||
|
|
||
| output: | ||
| path 'ccs.bam', emit: bam | ||
|
|
||
| shell: | ||
| """ | ||
| ccs ${bam} ccs.bam | ||
| """ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| process ccs { | ||
| publishDir "${params.outdir}", mode: 'copy' | ||
|
|
||
| conda 'bioconda::lima=2.0.0' | ||
|
|
||
| input: | ||
| path ccs_bam | ||
| path barcodes_fasta | ||
|
|
||
| output: | ||
| path 'demux.*', emit: bams | ||
|
|
||
| shell: | ||
| def cores = 16 | ||
| if (task.cpus) { | ||
| cores = (task.cpus as int) | ||
| } | ||
| """ | ||
| lima --num-threads ${cores} \ | ||
| --split-bam-named \ | ||
| --different \ | ||
| --ccs \ | ||
| --min-score-lead 10 \ | ||
| --min-score 80 \ | ||
| ${ccs_bam} \ | ||
| ${barcodes_fasta} \ | ||
| demux.bam | ||
| """ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/usr/bin/env nextflow | ||
|
|
||
| // DSL2 is used | ||
| nextflow.enable.dsl=2 | ||
|
|
||
| /*----------------------------------------------------------------------------- | ||
| Pipeline Processes (includes) | ||
| -----------------------------------------------------------------------------*/ | ||
|
|
||
| include { ccs } from '../modules/ccs/main' | ||
| include { lima } from '../modules/lima/main' | ||
| include { combine_demux_by_patient } from '../modules/combine_demux_by_patient/main' | ||
| include { bamtools_merge } from '../modules/bamtools/merge/main' | ||
|
|
||
| /*----------------------------------------------------------------------------- | ||
| Pipeline Parameters | ||
| -----------------------------------------------------------------------------*/ | ||
|
|
||
| if (!params.subreads_bam) { | ||
| exit 1, "[Pipeline Error] Missing parameter 'subreads_bam'\n" | ||
| } | ||
|
|
||
| if (!params.outdir) { | ||
| exit 1, "[Pipeline Error] Missing parameter 'outdir'\n" | ||
| } | ||
|
|
||
| /*----------------------------------------------------------------------------- | ||
| Main Workflow | ||
| -----------------------------------------------------------------------------*/ | ||
|
|
||
| workflow { | ||
|
|
||
| // [Channel] the input subreads BAM (eg. <movie>.subreads.bam or movie>..hifi_reads.bam) | ||
| ch_in_subreads_bam = Channel.fromPath(params.subreads_bam) | ||
|
|
||
| // [Channel] the sample metadata. Should contain: | ||
| // "Sample", "BarcodeF", "BarcodeFName", "BarcodeR", "BarcodeRName" | ||
| ch_in_metadata = Channel | ||
| .fromPath(params.sample_metadata) | ||
| .splitCsv(header: true) | ||
|
|
||
| // [Channel] the barcode FASTA file, one entry per input barcode | ||
| ch_in_barcodes_fasta = ch_in_metadata | ||
| .collectFile(name: 'barcodes.fasta', newLine: true) | ||
|
|
||
| // [Process] call the consensus reads from the subreads | ||
| ccs(ch_in_subreads_bam) | ||
|
|
||
| // [Process] demultiplex the CCS reads | ||
| lima(ccs.out.subreads_bam, ch_in_barcodes_fasta) | ||
|
|
||
| // [Channel] build tuples of barcode key and BAM file | ||
| ch_lima_bams = lima.out.bams.map { bam -> | ||
| (bam.baseName.substring("demux.".length()), bam) | ||
| } | ||
|
|
||
| // [[Channel] transform the metadata to tuples of barcode key and sample | ||
| ch_in_lima_outputs = ch_in_metadata | ||
| .map { (sample, barcodeF, barcodeFName, barcodeR, barcodeRName) -> | ||
| ("${barcodeFName}--${barcodeRName}", sample) | ||
| } | ||
|
|
||
| // [[Channel] gather all BAMs for the same sample | ||
| ch_bams_by_sample = ch_in_lima_outputs | ||
| .join(ch_lima_bams) // join by barcode name key | ||
| .map { (key, sample, bam) -> (sample, bam) } // discard the key | ||
| .groupTuple() // collect all BAMs by sample name | ||
|
|
||
| // [Process] combine into per-patient data | ||
| bamtools_merge(ch_bams_by_sample) | ||
|
|
||
| // [Process] trim amplicon primers | ||
| // TODO: support --neigbhors or --different | ||
|
|
||
| // [Process] variant calling | ||
| // TODO: support parameterizign variant callers | ||
| // TODO: support bcftools | ||
| // TODO: support DeepVariant | ||
| // TODO: support pbaa | ||
|
|
||
| // [Process] generate consensus sequence using VCFCons | ||
| // TODO: samtools depth | ||
| // TODO: run VCFCons | ||
|
|
||
| // [Process] Assign lineages using Pangolin or Nextclade | ||
| // TODO | ||
|
|
||
| // TODO: other miscellaneous items | ||
| // - downsample reads by amplicon | ||
| // - generate per amplicon coverage BED file | ||
| // | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pditommaso I am requiring a CSV that gives the sample (patient) along with the forward and reverse barcodes used. Since the sample can have multiple F/R barcode pairs, I need to merge the BAMs after demultiplexing. I am trying to figure out a concise way of joining the output of
lima(demultiplexing) with the metadata from the CSV, so I can group the BAMs to merge. Is this type of channel joining the idiomatic way, or would you recommend something different?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks you have already improved it bd3d982. Can't think of anything better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pdtommaso!