Commit 991c07af authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added vcf stats for each region bed file

parent ea781d9b
......@@ -30,19 +30,14 @@ import org.broadinstitute.gatk.queue.QScript
class BamMetrics(val root: Configurable) extends QScript
with SummaryQScript
with SampleLibraryTag
with Reference {
with Reference
with TargetRegions {
def this() = this(null)
@Input(doc = "Bam File", shortName = "BAM", required = true)
var inputBam: File = _
/** Bed files for region of interests */
var roiBedFiles: List[File] = config("regions_of_interest", Nil)
/** Bed of amplicon that is used */
var ampliconBedFile: Option[File] = config("amplicon_bed")
/** Settings for CollectRnaSeqMetrics */
var rnaMetricsSettings: Map[String, String] = Map()
var transcriptRefFlatFile: Option[File] = config("transcript_refflat")
......
package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.File
import nl.lumc.sasc.biopet.utils.config.Configurable
/**
* Created by pjvan_thof on 11/20/15.
*/
trait TargetRegions extends Configurable {
/** Bed files for region of interests */
var roiBedFiles: List[File] = config("regions_of_interest", Nil)
/** Bed of amplicon that is used */
var ampliconBedFile: Option[File] = config("amplicon_bed")
}
......@@ -54,6 +54,7 @@ class VcfStats(val root: Configurable) extends ToolCommandFunction with Summariz
var allInfoTags = false
var allGenotypeTags = false
var reference: File = _
var intervals: Option[File] = None
override def beforeGraph(): Unit = {
reference = referenceFasta()
......@@ -76,7 +77,8 @@ class VcfStats(val root: Configurable) extends ToolCommandFunction with Summariz
repeat("--genotypeTag", genotypeTags) +
conditional(allInfoTags, "--allInfoTags") +
conditional(allGenotypeTags, "--allGenotypeTags") +
required("-R", reference)
required("-R", reference) +
optional("--intervals", intervals)
/** Returns general stats to the summary */
def summaryStats: Map[String, Any] = {
......
......@@ -354,19 +354,12 @@ trait ShivaTrait extends MultiSampleQScript with Reference { qscript: QScript =>
def summaryFile = new File(outputDir, "Shiva.summary.json")
/** Settings of pipeline for summary */
def summarySettings = {
val roiBedFiles: List[File] = config("regions_of_interest", Nil)
val ampliconBedFile: Option[File] = config("amplicon_bed")
Map(
def summarySettings = Map(
"reference" -> referenceSummary,
"regions_of_interest" -> roiBedFiles.map(_.getName.stripSuffix(".bed")),
"amplicon_bed" -> ampliconBedFile.map(_.getName.stripSuffix(".bed")),
"annotation" -> annotation.isDefined,
"multisample_variantcalling" -> multisampleVariantCalling.isDefined,
"sv_calling" -> svCalling.isDefined
)
}
/** Files for the summary */
def summaryFiles = Map("referenceFasta" -> referenceFasta())
......
......@@ -15,23 +15,24 @@
*/
package nl.lumc.sasc.biopet.pipelines.shiva
import java.io.File
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ Reference, SampleLibraryTag }
import nl.lumc.sasc.biopet.extensions.gatk.{ CombineVariants, GenotypeConcordance }
import nl.lumc.sasc.biopet.extensions.tools.VcfStats
import nl.lumc.sasc.biopet.pipelines.bammetrics.TargetRegions
import nl.lumc.sasc.biopet.pipelines.shiva.variantcallers._
import nl.lumc.sasc.biopet.utils.{ BamUtils, Logging }
import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.utils.commandline.Input
/**
* Common trait for ShivaVariantcalling
*
* Created by pjvan_thof on 2/26/15.
*/
trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with Reference {
trait ShivaVariantcallingTrait extends SummaryQScript
with SampleLibraryTag
with Reference
with TargetRegions {
qscript: QScript =>
@Input(doc = "Bam files (should be deduped bams)", shortName = "BAM", required = true)
......@@ -87,42 +88,43 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with
add(caller)
cv.addInput(caller.outputFile, caller.name)
val vcfStats = new VcfStats(qscript)
vcfStats.input = caller.outputFile
vcfStats.setOutputDir(new File(caller.outputDir, "vcfstats"))
add(vcfStats)
addSummarizable(vcfStats, namePrefix + "-vcfstats-" + caller.name)
referenceVcf.foreach(referenceVcfFile => {
val gc = new GenotypeConcordance(this)
gc.evalFile = caller.outputFile
gc.compFile = referenceVcfFile
gc.outputFile = new File(caller.outputDir, s"$namePrefix-genotype_concordance.${caller.name}.txt")
referenceVcfRegions.foreach(gc.intervals ::= _)
add(gc)
addSummarizable(gc, s"$namePrefix-genotype_concordance-${caller.name}")
})
addStats(caller.outputFile, caller.name)
}
add(cv)
addStats(finalFile, "final")
addSummaryJobs()
}
protected def addStats(vcfFile: File, name: String): Unit = {
val vcfStats = new VcfStats(qscript)
vcfStats.input = finalFile
vcfStats.setOutputDir(new File(outputDir, "vcfstats"))
vcfStats.infoTags :+= cv.setKey
vcfStats.input = vcfFile
vcfStats.setOutputDir(new File(vcfFile.getParentFile, "vcfstats"))
vcfStats.infoTags :+= "VariantCaller"
add(vcfStats)
addSummarizable(vcfStats, namePrefix + "-vcfstats-final")
addSummarizable(vcfStats, s"$namePrefix-vcfstats-$name")
referenceVcf.foreach(referenceVcfFile => {
val gc = new GenotypeConcordance(this)
gc.evalFile = finalFile
gc.evalFile = vcfFile
gc.compFile = referenceVcfFile
gc.outputFile = new File(outputDir, s"$namePrefix-genotype_concordance.final.txt")
gc.outputFile = new File(vcfFile.getParentFile, s"$namePrefix-genotype_concordance.$name.txt")
referenceVcfRegions.foreach(gc.intervals ::= _)
add(gc)
addSummarizable(gc, s"$namePrefix-genotype_concordance-final")
addSummarizable(gc, s"$namePrefix-genotype_concordance-$name")
})
addSummaryJobs()
for (bedFile <- ampliconBedFile.toList ::: roiBedFiles) {
val regionName = bedFile.getName.stripSuffix(".bed")
val vcfStats = new VcfStats(qscript)
vcfStats.input = vcfFile
vcfStats.intervals = Some(bedFile)
vcfStats.setOutputDir(new File(vcfFile.getParentFile, s"vcfstats-$regionName"))
vcfStats.infoTags :+= "VariantCaller"
add(vcfStats)
addSummarizable(vcfStats, s"$namePrefix-vcfstats-$name-$regionName")
}
}
/** Will generate all available variantcallers */
......@@ -132,7 +134,11 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with
def summaryFile = new File(outputDir, "ShivaVariantcalling.summary.json")
/** Settings for the summary */
def summarySettings = Map("variantcallers" -> configCallers.toList)
def summarySettings = Map(
"variantcallers" -> configCallers.toList,
"regions_of_interest" -> roiBedFiles.map(_.getName.stripSuffix(".bed")),
"amplicon_bed" -> ampliconBedFile.map(_.getName.stripSuffix(".bed"))
)
/** Files for the summary */
def summaryFiles: Map[String, File] = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment