Skip to content

Commit

Permalink
Added code and README.
Browse files Browse the repository at this point in the history
  • Loading branch information
esrice committed Jan 12, 2021
1 parent 0de50ee commit c39e375
Show file tree
Hide file tree
Showing 10 changed files with 858 additions and 1 deletion.
78 changes: 78 additions & 0 deletions 1-generate-sv-calls/manta.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env nextflow

params.reference = 'ref.fa'

reference_file = file(params.reference)

Channel
.fromSRA(file('../library_list.txt').readLines())
.set{reads}

process bwa_index {
publishDir 'bwa_index'
module 'bwa/bwa-0.7.17'

input:
file reference from reference_file

output:
file "${reference}.*" into reference_index

""" bwa index ${reference} """
}

process samtools_faidx {
module 'samtools/samtools-1.9'

input:
file reference from reference_file

output:
file "${reference}.fai" into faidx

""" samtools faidx ${reference} """
}

process align {
cpus 16
module 'bwa/bwa-0.7.17:samtools/samtools-1.9'
publishDir 'alignments'

input:
file ref from reference_file
file index from reference_index
set accession, file(both_ends) from reads

output:
file "${accession}.bam" into aligned
file "${accession}.bam.bai" into aligned_index

"""
bwa mem -t ${task.cpus} ${ref} ${both_ends} | samtools view -bh - | \
samtools fixmate -m - - | samtools sort - | \
samtools markdup -r - ${accession}.bam
samtools index ${accession}.bam
"""
}

process manta {
cpus 16
module 'biocompute/biocompute-modules'
module 'manta/manta-1.6.0'
publishDir 'results'

input:
file 'ref.fa' from reference_file
file 'ref.fa.fai' from faidx
file bams from aligned.collect()
file bais from aligned_index.collect()

output:
file "manta*" into results

"""
bams=""; for bam in ${bams}; do bams+="--bam \$bam "; done
configManta.py \$bams --referenceFasta ref.fa --runDir manta
manta/runWorkflow.py -j ${task.cpus}
"""
}
137 changes: 137 additions & 0 deletions 1-generate-sv-calls/smoove.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/env nextflow

params.reference = 'ref.fa'
params.scratch = '/local/scratch/esrbhb'

Channel
.fromSRA(file('../library_list.txt').readLines())
.set{reads}

reference_file = file(params.reference)

process bwa_index {
publishDir 'bwa_index'
module 'bwa/bwa-0.7.17'

input:
file reference from reference_file

output:
file "${reference}.*" into reference_index

""" bwa index ${reference} """
}

process samtools_faidx {
module 'samtools/samtools-1.9'

input:
file reference from reference_file

output:
file "${reference}.fai" into faidx

""" samtools faidx ${reference} """
}

process align {
cpus 16
module 'bwa/bwa-0.7.17:samtools/samtools-1.9'
publishDir 'alignments'

input:
file ref from reference_file
file index from reference_index
set accession, file(both_ends) from reads

output:
set accession, "${accession}.bam*" into aligned

"""
bwa mem -R "@RG\\tID:${accession}\\tSM:${accession}\\tPL:ILLUMINA" \
-t ${task.cpus} ${ref} ${both_ends} | samtools view -bh - | \
samtools fixmate -m - - | samtools sort - | \
samtools markdup -r - ${accession}.bam
samtools index ${accession}.bam
"""
}

aligned.into { aligned_for_smoove_call; aligned_for_smoove_genotype }
faidx.into { faidx_for_smoove_call; faidx_for_smoove_merge;
faidx_for_smoove_genotype }

process smoove_call {
container 'brentp/smoove:v0.2.3'
publishDir 'unmerged'
cpus 8

input:
file 'ref.fa' from reference_file
file 'ref.fa.fai' from faidx_for_smoove_call
set accession, file(bam) from aligned_for_smoove_call

output:
file "${accession}-smoove.genotyped.vcf.gz" into unmerged

"""
smoove call --name ${accession} --fasta ref.fa -p ${task.cpus} \
--genotype ${accession}.bam
"""
}

process smoove_merge {
container 'brentp/smoove:v0.2.3'

input:
file 'ref.fa' from reference_file
file 'ref.fa.fai' from faidx_for_smoove_merge
file all_unmerged from unmerged.collect()

output:
file "merged.sites.vcf.gz" into merged

"""
smoove merge --name merged -f ref.fa ${all_unmerged}
"""
}

merged_vcf_faidx_and_bams = merged.combine(faidx_for_smoove_genotype)
.combine(aligned_for_smoove_genotype)

process smoove_genotype {
container 'brentp/smoove:v0.2.3'

input:
file 'ref.fa' from reference_file
set 'merged.sites.vcf.gz', 'ref.fa.fai', accession,
file(bam) from merged_vcf_faidx_and_bams

output:
file "${accession}-joint-smoove.genotyped.vcf.gz" into joint_genotyped
file "${accession}-joint-smoove.genotyped.vcf.gz.csi" into j_g_index

"""
export TMPDIR=\$PWD
smoove genotype -d -x --name ${accession}-joint --fasta ref.fa \
--vcf merged.sites.vcf.gz ${accession}.bam
echo "done!"
"""
}

process smoove_paste {
container 'brentp/smoove:v0.2.3'
publishDir 'output'

input:
file all_vcfs from joint_genotyped.collect()
file all_indexes from j_g_index.collect()

output:
file "pasted.smoove.square.vcf.gz" into pasted

"""
smoove paste --name pasted ${all_vcfs}
"""
}


17 changes: 17 additions & 0 deletions 2-filter-sv-calls/filter_vcfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# filter manta calls
cut -f2,4 ../sample_keys.tsv > sample2id.tsv
bcftools filter -Oz \
-i 'INFO/SVTYPE="DEL" && INFO/SVLEN < -500 && INFO/SVLEN > -100000' \
../1-generate-sv-calls/manta/results/manta/results/variants/diploidSV.vcf.gz \
| bcftools reheader -s sample2id.tsv - > manta_deletions_only.vcf.gz
rm sample2id.tsv

# filter lumpy calls
cut -f1,4 ../sample_keys.tsv > srr2id.tsv
bcftools filter -Oz \
-i 'INFO/SVTYPE="DEL" && INFO/SVLEN < -500 && INFO/SVLEN > -100000' \
../1-generate-sv-calls/lumpy/output/pasted.smoove.square.vcf.gz | \
bcftools reheader -s srr2id.tsv - > lumpy_deletions_only.vcf.gz
rm srr2id.tsv
Loading

0 comments on commit c39e375

Please sign in to comment.