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

[AVOCADO-274] Add flag to emit all genotyped variants, regardless of quality. #275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ class BiallelicGenotyperArgs extends Args4jBase with ADAMSaveAnyArgs with Parque
name = "-score_all_sites",
usage = "If provided, scores all sites, even non-variant sites. Emits a gVCF styled output.")
var scoreAllSites = false
@Args4jOption(required = false,
name = "-emit_all_genotypes",
usage = "Emits genotypes for all sites that were discovered.")
var emitAllGenotypes = false

// required by HardFilterGenotypesArgs
var maxSnpPhredStrandBias: Float = -1.0f
Expand Down Expand Up @@ -254,7 +258,8 @@ class BiallelicGenotyper(

// hard filter the genotypes
val filteredGenotypes = HardFilterGenotypes(genotypes, args,
filterRefGenotypes = !args.scoreAllSites)
filterRefGenotypes = !args.scoreAllSites,
emitAllGenotypes = (args.scoreAllSites || args.emitAllGenotypes))

// save the variant calls
filteredGenotypes.saveAsParquet(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ private[avocado] object HardFilterGenotypes extends Serializable {
* @param grdd GenotypeRDD to filter.
* @param args The hard filter configuration to apply.
* @param filterRefGenotypes If true, discards homozygous ref calls.
* @param emitAllGenotypes If true, emits all genotypes.
* @return A new GenotypeRDD of hard filtered genotypes.
*/
def apply(grdd: GenotypeRDD,
args: HardFilterGenotypesArgs,
filterRefGenotypes: Boolean = true): GenotypeRDD = {
filterRefGenotypes: Boolean = true,
emitAllGenotypes: Boolean = true): GenotypeRDD = {

// make snp and indel filters
val snpFilters = buildSnpHardFilters(args)
Expand Down Expand Up @@ -246,7 +248,8 @@ private[avocado] object HardFilterGenotypes extends Serializable {
minQuality,
snpFilters,
indelFilters,
filterRefGenotypes))
filterRefGenotypes,
emitAllGenotypes = emitAllGenotypes))
}).addHeaderLines(filterHeaders)
}

Expand Down Expand Up @@ -624,6 +627,7 @@ private[avocado] object HardFilterGenotypes extends Serializable {
* @param snpFilters Collection of filters to apply to emitted SNPs.
* @param indelFilters Collection of filters to apply to emitted INDELs.
* @param filterRefGenotypes If true, discards hom-ref calls.
* @param emitAllGenotypes If true, emits all genotypes.
* @return If genotype is high enough quality to emit, a hard filtered
* genotype.
*/
Expand All @@ -632,11 +636,16 @@ private[avocado] object HardFilterGenotypes extends Serializable {
minQuality: Int,
snpFilters: Iterable[Genotype => Option[String]],
indelFilters: Iterable[Genotype => Option[String]],
filterRefGenotypes: Boolean): Option[Genotype] = {
filterRefGenotypes: Boolean,
emitAllGenotypes: Boolean = false): Option[Genotype] = {

// first, apply emission filters
val optGenotype = Some(genotype)
.filter(emitGenotypeFilter(_, minQuality, filterRefGenotypes))
val optGenotype = if (emitAllGenotypes) {
Some(genotype)
} else {
Some(genotype)
.filter(emitGenotypeFilter(_, minQuality, filterRefGenotypes))
}

// then, check whether we are a snp or indel and apply hard filters
if (genotype.getVariant.getAlternateAllele != null) {
Expand Down