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

Prioritize het calls when merging clustered SVs #9058

Merged
merged 3 commits into from
Dec 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,35 @@ public enum FlagFieldLogic {
/**
* Comparators used for picking the representative genotype for a given sample
*/
// Priotize non-ref over ref
final Comparator<Genotype> genotypeIsNonRefComparator = (o1, o2) -> {
final long count1 = Math.min(1, o1.getAlleles().stream().filter(Allele::isNonReference).filter(Allele::isCalled).count());
final long count2 = Math.min(1, o2.getAlleles().stream().filter(Allele::isNonReference).filter(Allele::isCalled).count());
return Long.compare(count1, count2);
};

// Priotize fewer ALT alleles over more. When applied after non-ref comparator, hom-ref genotypes will not be encountered.
final Comparator<Genotype> genotypeNonRefCountComparator = (o1, o2) -> {
final long count1 = o1.getAlleles().stream().filter(Allele::isNonReference).filter(Allele::isCalled).count();
final long count2 = o2.getAlleles().stream().filter(Allele::isNonReference).filter(Allele::isCalled).count();
return Long.compare(count1, count2);
return Long.compare(count2, count1);
};

// Priotize called genotypes
final Comparator<Genotype> genotypeCalledComparator = (o1, o2) -> {
final long count1 = o1.getAlleles().stream().filter(Allele::isCalled).count();
final long count2 = o2.getAlleles().stream().filter(Allele::isCalled).count();
return Long.compare(count1, count2);
};

// Priotize higher quality
final Comparator<Genotype> genotypeQualityComparator = (o1, o2) -> {
final int quality1 = VariantContextGetters.getAttributeAsInt(o1, VCFConstants.GENOTYPE_QUALITY_KEY, 0);
final int quality2 = VariantContextGetters.getAttributeAsInt(o2, VCFConstants.GENOTYPE_QUALITY_KEY, 0);
return Integer.compare(quality1, quality2);
};

// Priotize higher depth genotyping quality
final Comparator<Genotype> genotypeCopyNumberQualityComparator = new Comparator<Genotype>() {
@Override
public int compare(Genotype o1, Genotype o2) {
Expand All @@ -155,14 +160,33 @@ public int compare(Genotype o1, Genotype o2) {
}
};

// Priotize depth genotypes closer to reference
final Comparator<Genotype> genotypeCopyNumberComparator = new Comparator<Genotype>() {
@Override
public int compare(Genotype o1, Genotype o2) {
final int expectedQualityNumber1 = VariantContextGetters.getAttributeAsInt(o1, GATKSVVCFConstants.EXPECTED_COPY_NUMBER_FORMAT, 0);
final int copyNumber1 = VariantContextGetters.getAttributeAsInt(o1, GATKSVVCFConstants.COPY_NUMBER_FORMAT, 0);
final int expectedQualityNumber2 = VariantContextGetters.getAttributeAsInt(o2, GATKSVVCFConstants.EXPECTED_COPY_NUMBER_FORMAT, 0);
final int copyNumber2 = VariantContextGetters.getAttributeAsInt(o2, GATKSVVCFConstants.COPY_NUMBER_FORMAT, 0);
return Double.compare(Math.abs(expectedQualityNumber1 - copyNumber1), Math.abs(expectedQualityNumber2 - copyNumber2));
return Double.compare(Math.abs(expectedQualityNumber2 - copyNumber2), Math.abs(expectedQualityNumber1 - copyNumber1));
}
};

// Priotize DEL over DUP as final tiebreaker
final Comparator<Genotype> genotypeDelOverDupComparator = new Comparator<Genotype>() {
@Override
public int compare(Genotype o1, Genotype o2) {
final int expectedCN1 = VariantContextGetters.getAttributeAsInt(o1, GATKSVVCFConstants.EXPECTED_COPY_NUMBER_FORMAT, 0);
final boolean isDel1 = VariantContextGetters.getAttributeAsInt(o1, GATKSVVCFConstants.COPY_NUMBER_FORMAT, expectedCN1) < expectedCN1;
final int expectedCN2 = VariantContextGetters.getAttributeAsInt(o2, GATKSVVCFConstants.EXPECTED_COPY_NUMBER_FORMAT, 0);
final boolean isDel2 = VariantContextGetters.getAttributeAsInt(o2, GATKSVVCFConstants.COPY_NUMBER_FORMAT, expectedCN2) < expectedCN2;
if (isDel1 && !isDel2) {
return 1;
} else if (isDel2 && !isDel1) {
return -1;
} else {
return 0;
}
}
};

Expand Down Expand Up @@ -461,7 +485,8 @@ protected Genotype getRepresentativeGenotype(final Collection<Genotype> genotype
.thenComparing(genotypeQualityComparator)
.thenComparing(genotypeNonRefCountComparator)
.thenComparing(genotypeCopyNumberQualityComparator)
.thenComparing(genotypeCopyNumberComparator)).get();
.thenComparing(genotypeCopyNumberComparator)
.thenComparing(genotypeDelOverDupComparator)).get();
}


Expand Down
Loading
Loading