Ejemplo n.º 1
0
        private void AssignMcc(CanvasSegment canvasSegment, ICopyNumberModel copyNumberModel,
                               PhasedGenotype gtStates, int copyNumber)
        {
            const int diploidCopyNumber = 2;

            if (copyNumber > diploidCopyNumber)
            {
                canvasSegment.MajorChromosomeCount =
                    Math.Max(gtStates.CopyNumberA, gtStates.CopyNumberB);
                int?selectedGtState = _genotypes[copyNumber].IndexOf(gtStates);
                canvasSegment.MajorChromosomeCountScore = GetGtLogLikelihoodScore(canvasSegment.Balleles, _genotypes[copyNumber], ref selectedGtState, copyNumberModel);
            }
            else
            {
                // variant caller does not attempt to call LOH, for DELs CN=MCC
                if (copyNumber == diploidCopyNumber)
                {
                    canvasSegment.MajorChromosomeCount = null;
                }
                else
                {
                    canvasSegment.MajorChromosomeCount = copyNumber;
                }
                canvasSegment.MajorChromosomeCountScore = null;
            }
        }
Ejemplo n.º 2
0
 private double GetProbandLogLikelihood(ICopyNumberModel copyNumberModel, int childCopyNumber, PhasedGenotype parent1GtStates, PhasedGenotype parent2GtStates, bool isInheritedCnv, CanvasSegment canvasSegment,
                                        double bestLogLikelihood, ref PhasedGenotype bestGtState)
 {
     foreach (var childGtState in _genotypes[childCopyNumber])
     {
         double currentChildLogLikelihood;
         if (IsGtPedigreeConsistent(parent1GtStates, childGtState) &&
             IsGtPedigreeConsistent(parent2GtStates, childGtState) &&
             isInheritedCnv)
         {
             currentChildLogLikelihood = copyNumberModel.GetGenotypeLogLikelihood(canvasSegment.Balleles, childGtState);
         }
         else
         {
             continue;
         }
         if (currentChildLogLikelihood > bestLogLikelihood)
         {
             bestLogLikelihood = currentChildLogLikelihood;
             bestGtState       = childGtState;
         }
     }
     return(bestLogLikelihood);
 }
Ejemplo n.º 3
0
 private static double GetCurrentGtLogLikelihood(ICopyNumberModel copyNumberModel, CanvasSegment canvasSegment, PhasedGenotype gtStates)
 {
     return(copyNumberModel.GetGenotypeLogLikelihood(canvasSegment.Balleles, gtStates));
 }
Ejemplo n.º 4
0
        internal static double GetGtLogLikelihoodScore(Balleles gtObservedCounts, List <PhasedGenotype> gtModelCounts, ref int?selectedGtState, ICopyNumberModel copyNumberModel)
        {
            const int maxGQscore       = 60;
            var       gtLogLikelihoods = Enumerable.Repeat(Double.NegativeInfinity, gtModelCounts.Count).ToList();
            var       gtModelCounter   = -1;

            foreach (var gtModelCount in gtModelCounts)
            {
                gtModelCounter++;
                // As we don't estimate allele CN but only MCC, focus on upper-triangle
                if (gtModelCount.CopyNumberA < gtModelCount.CopyNumberB)
                {
                    continue;
                }
                gtLogLikelihoods[gtModelCounter] = copyNumberModel.GetGenotypeLogLikelihood(gtObservedCounts, gtModelCount);
            }
            var maxLogLikelihood = gtLogLikelihoods.Max();

            if (!selectedGtState.HasValue)
            {
                selectedGtState = gtLogLikelihoods.IndexOf(maxLogLikelihood);
            }
            double normalizationConstant = gtLogLikelihoods.Sum(ll => Math.Exp(ll - maxLogLikelihood));
            double gqscore = -10.0 * Math.Log10((normalizationConstant - 1) / normalizationConstant);

            if (Double.IsInfinity(gqscore) | gqscore > maxGQscore)
            {
                gqscore = maxGQscore;
            }
            return(Double.IsNaN(gqscore) || Double.IsInfinity(gqscore) ? 0 : gqscore);
        }