Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/lpa indepedent mode #1

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 0 additions & 1 deletion conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ params {
project = "exome-validation"
input = "test-data/*.bam"
gold = "reference-data/gold/gold.txt"
region = "reference-data/peterReadExtract.hg38.camo.LPA.realign.sorted.bed"
reference = "reference-data/kiv2.fasta"
contig = "KIV2_6"
build = "hg38"
Expand Down
18 changes: 18 additions & 0 deletions conf/test_other_regions.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
========================================================================================
Nextflow config file for running minimal tests
========================================================================================
Defines input files and everything required to run a fast and simple pipeline test.
Use as follows:
nextflow run genepi/exome-cnv-nf -r <tag> -profile test,<docker/singularity>
----------------------------------------------------------------------------------------
*/

params {
project = "vntr-other-region"
input = "test-data/*.bam"
region = "bin/kiv2_hg38.bed"
reference = "reference-data/kiv2.fasta"
contig = "KIV2_6"
build = "hg38"
}
2 changes: 1 addition & 1 deletion modules/local/call_variants_mutserve.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process CALL_VARIANTS_MUTSERVE {
input:
path bamFiles
path ref_fasta
path contig
val(contig)

output:
path "${params.project}.txt", emit: variants_ch
Expand Down
4 changes: 2 additions & 2 deletions modules/local/extract_reads.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ process EXTRACT_READS {

output:
path "*.extracted.bam", emit: extracted_bams_ch

"""
samtools view -h -L ${regionFile} ${bamFile} | awk '\$5 < ${params.reads_quality_limit} || \$1 ~ "^@"' | samtools view -hb - | samtools sort -n -o ${bamFile.baseName}.extracted.bam -
samtools view -hb -L ${regionFile} ${bamFile} | samtools sort -n -o ${bamFile.baseName}.extracted.bam -
"""
}
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ params {
gold = null
region = null
build = null
region = null
reference = null
signature_split_value = 50
mutserve_detection_limit = 0.01
Expand Down
64 changes: 33 additions & 31 deletions workflows/exome-cnv.nf
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
nextflow.enable.dsl = 2

params.project="exome-validation"
params.input="$baseDir/test-data/*.bam"
params.gold="$baseDir/reference-data/gold/gold.txt"
params.region="$baseDir/reference-data/peterReadExtract.hg38.camo.LPA.realign.sorted.bed"
params.reference="$baseDir/reference-data/kiv2.fasta"
params.reference_fai="$baseDir/reference-data/kiv2.fasta.fai"
params.contig="KIV2_6"
params.threads = (Runtime.runtime.availableProcessors() - 1)
params.output="output"

bam_files_ch = Channel.fromPath(params.input)
//region_file_ch = file(params.region)
ref_fasta = file(params.reference)
ref_fasta_fai = file(params.reference_fai)
gold_standard = file(params.gold)
contig = file(params.contig)

if(params.build == "hg19") {
lpa_region = file("$baseDir/bin/lpa_hg19.bed", checkIfExists: true)
} else if (params.build == "hg38") {
lpa_region = file("$baseDir/bin/lpa_hg38.bed", checkIfExists: true)
}

requiredParams = [
'project', 'input',
'gold', 'reference', 'contig', 'build'
'project', 'input','reference', 'contig'
]

for (param in requiredParams) {
Expand All @@ -34,12 +10,17 @@ for (param in requiredParams) {
}
}

if(params.outdir == null) {
outdir = "output/${params.project}"
} else {
outdir = params.outdir
if (params.region == null && params.build == null) {
exit 1, "Please specify build of your input data."
}

bam_files_ch = Channel.fromPath(params.input)
ref_fasta = file(params.reference, checkIfExists: true)
ref_fasta_fai = file(params.reference+".fai", checkIfExists: true)
contig = params.contig

outdir = "output/${params.project}"

include { BUILD_BWA_INDEX } from '../modules/local/build_bwa_index'
include { DETECT_TYPE } from '../modules/local/detect_type' addParams(outdir: "$outdir")
include { EXTRACT_READS } from '../modules/local/extract_reads' addParams(outdir: "$outdir")
Expand All @@ -52,10 +33,31 @@ include { CALCULATE_PERFORMANCE } from '../modules/local/calculate_performance'
workflow EXOME_CNV {

BUILD_BWA_INDEX ( ref_fasta )

// if no region is set, we apply our LPA-specific signature approach
if (params.region == null){
// load lpa region, concrecte bed file is then defined in DETECT_TYPE
if(params.build == "hg19") {
lpa_region = file("$baseDir/bin/lpa_hg19.bed", checkIfExists: true)
} else if (params.build == "hg38") {
lpa_region = file("$baseDir/bin/lpa_hg38.bed", checkIfExists: true)
}
DETECT_TYPE ( bam_files_ch, lpa_region )
EXTRACT_READS ( DETECT_TYPE.out.bam_bed_ch )
bam_bed_tuple = DETECT_TYPE.out.bam_bed_ch
// for all other regions use the defined region file
} else {
region = file(params.region, checkIfExists: true)
bam_files_ch.map { it -> [it, region] }
.set { bam_bed_tuple }
}

EXTRACT_READS ( bam_bed_tuple )
BAM_TO_FASTQ ( EXTRACT_READS.out.extracted_bams_ch )
REALIGN_FASTQ ( BAM_TO_FASTQ.out.fastq_ch,ref_fasta,BUILD_BWA_INDEX.out.bwa_index_ch )
CALL_VARIANTS_MUTSERVE ( REALIGN_FASTQ.out.realigned_ch.collect(),ref_fasta, contig )
CALCULATE_PERFORMANCE ( CALL_VARIANTS_MUTSERVE.out.variants_ch,gold_standard )

if(params.gold != null) {
gold_standard = file(params.gold, checkIfExists: true)
CALCULATE_PERFORMANCE ( CALL_VARIANTS_MUTSERVE.out.variants_ch,gold_standard )
}
}