private Genotype CalculateHaploidGenotype(IEnumerable <CalledAllele> alleles, int minDepthToGenotype, out List <CalledAllele> allelesToPrune) { allelesToPrune = new List <CalledAllele>(); var singleGTForLoci = Genotype.HemizygousNoCall; var orderedVariants = GenotypeCalculatorUtilities.FilterAndOrderAllelesByFrequency(alleles, allelesToPrune, _minorVF); var referenceFrequency = GenotypeCalculatorUtilities.GetReferenceFrequency(alleles, _minorVF); var refExists = (referenceFrequency >= _minorVF); var depthIssue = GenotypeCalculatorUtilities.CheckForDepthIssue(alleles, minDepthToGenotype); bool refCall = ((orderedVariants.Count == 0) || (orderedVariants[0].Frequency < _minorVF)); if (!depthIssue && refCall && refExists && referenceFrequency > _majorVF) { singleGTForLoci = Genotype.HemizygousRef; } if (!depthIssue && !refCall && !refExists && orderedVariants[0].Frequency > _majorVF) { singleGTForLoci = Genotype.HemizygousAlt; } //if (!diploidModelFail) allelesToPrune = GenotypeCalculatorUtilities.GetAllelesToPruneBasedOnGTCall(singleGTForLoci, orderedVariants, allelesToPrune); return(singleGTForLoci); }
private static Genotype CalculateDiploidGenotype(IEnumerable <CalledAllele> alleles, int minDepthToGenotype, DiploidThresholdingParameters snvThresholdingParameters, DiploidThresholdingParameters indelThresholdingParameters, out List <CalledAllele> allelesToPrune) { allelesToPrune = new List <CalledAllele>(); var singleGTForLoci = Genotype.RefLikeNoCall; var orderedVariants = GenotypeCalculatorUtilities.FilterAndOrderAllelesByFrequency(alleles, allelesToPrune, snvThresholdingParameters.MinorVF); var referenceFrequency = GenotypeCalculatorUtilities.GetReferenceFrequency(alleles, snvThresholdingParameters.MinorVF); var refExists = (referenceFrequency >= snvThresholdingParameters.MinorVF); var depthIssue = GenotypeCalculatorUtilities.CheckForDepthIssue(alleles, minDepthToGenotype); var diploidModelFail = false; // as in {30%,30%,30%} not {49%,49%,2%},ie, diploid model FAIL. bool refCall = ((orderedVariants.Count == 0) || (orderedVariants[0].Frequency < snvThresholdingParameters.MinorVF)); var parameters = snvThresholdingParameters; //do we apply SNP threshholds or indel thresholds? if (!refCall) { var dominantVariant = orderedVariants.Last(); if (dominantVariant.Type != AlleleCategory.Snv) { parameters = indelThresholdingParameters; } } if (depthIssue) { if (refCall) { singleGTForLoci = Genotype.RefLikeNoCall; } else { singleGTForLoci = Genotype.AltLikeNoCall; } } else { //obvious reference call if (refCall) { if (!refExists) { singleGTForLoci = Genotype.RefLikeNoCall; //there might have been an upstream deletion } else { var firstAllele = alleles.First(); //we see too much of something else (unknown) for a clean ref call. if ((firstAllele.Type == AlleleCategory.Reference) && ((1 - firstAllele.Frequency) > parameters.MinorVF)) { singleGTForLoci = Genotype.RefAndNoCall; } else { singleGTForLoci = Genotype.HomozygousRef; // being explicit for readability } } }//else, types of alt calls... else if ((orderedVariants[0].Frequency >= parameters.MinorVF) && (orderedVariants[0].Frequency <= parameters.MajorVF)) { if (orderedVariants.Count == 1) { if (refExists) { singleGTForLoci = Genotype.HeterozygousAltRef; } else { singleGTForLoci = Genotype.AltAndNoCall; } } else { //is this 0/1, 1/2, or 0/1/2 or 1/2/3/... diploidModelFail = CheckForTriAllelicIssue(refExists, referenceFrequency, orderedVariants, parameters.SumVFforMultiAllelicSite); if (diploidModelFail) { SetMultiAllelicFilter(alleles); if (refExists) { singleGTForLoci = Genotype.AltLikeNoCall; } else { singleGTForLoci = Genotype.Alt12LikeNoCall; } } else if (refExists) { singleGTForLoci = Genotype.HeterozygousAltRef; } else { singleGTForLoci = Genotype.HeterozygousAlt1Alt2; } } } else if (orderedVariants[0].Frequency > parameters.MajorVF) { singleGTForLoci = Genotype.HomozygousAlt; } } //if (!diploidModelFail) allelesToPrune = GenotypeCalculatorUtilities.GetAllelesToPruneBasedOnGTCall(singleGTForLoci, orderedVariants, allelesToPrune); //tjd + //incase of DiploidModelFail, we *used* to show all alleles we detected, but then we were worried about down stream processors. //So now we will will prune in this case, too. // we still will flag this DiploidModelFail site as a no call. But no longer report everything we found //tjd - return(singleGTForLoci); }