Beispiel #1
0
 /// <summary>
 /// Apply quality scores.
 /// </summary>
 public static void AssignQualityScores(List <CanvasSegment> segments, QScoreMethod qscoreMethod, QualityScoreParameters qscoreParameters)
 {
     foreach (CanvasSegment segment in segments)
     {
         segment.QScore = segment.ComputeQScore(qscoreMethod, qscoreParameters);
     }
 }
Beispiel #2
0
        public int ComputeQScore(QScoreMethod qscoreMethod, QualityScoreParameters qscoreParameters)
        {
            double score;
            int    qscore;

            switch (qscoreMethod)
            {
            case QScoreMethod.LogisticGermline:
                // Logistic model using a new selection of features.  Gives ROC curve area 0.921
                score  = qscoreParameters.LogisticGermlineIntercept;
                score += GetQScorePredictor(QScorePredictor.LogBinCount) *
                         qscoreParameters.LogisticGermlineLogBinCount;
                score += GetQScorePredictor(QScorePredictor.ModelDistance) *
                         qscoreParameters.LogisticGermlineModelDistance;
                score += GetQScorePredictor(QScorePredictor.DistanceRatio) *
                         qscoreParameters.LogisticGermlineDistanceRatio;
                score = Math.Exp(score);
                score = score / (score + 1);
                // Transform probability into a q-score:
                qscore = (int)(Math.Round(-10 * Math.Log10(1 - score)));
                qscore = Math.Min(40, qscore);
                qscore = Math.Max(2, qscore);
                return(qscore);

            case QScoreMethod.Logistic:
                // Logistic model using a new selection of features.  Gives ROC curve area 0.8289
                score  = qscoreParameters.LogisticIntercept;
                score += GetQScorePredictor(QScorePredictor.LogBinCount) * qscoreParameters.LogisticLogBinCount;
                score += GetQScorePredictor(QScorePredictor.ModelDistance) * qscoreParameters.LogisticModelDistance;
                score += GetQScorePredictor(QScorePredictor.DistanceRatio) * qscoreParameters.LogisticDistanceRatio;
                score += GetQScorePredictor(QScorePredictor.BinCountAmpDistance);
                double coreScore = score;
                score = Math.Exp(score);
                score = score / (score + 1);
                // Transform probability into a q-score:
                qscore = (int)Math.Round(-10 * Math.Log10(1 - score));
                qscore = Math.Min(60, qscore);
                qscore = Math.Max(2, qscore);
                //if (CopyNumber>20)
                //{
                //    Console.WriteLine($"HiCN: {CopyNumber} from {this.MedianCount} distance {ModelDistance} next {RunnerUpModelDistance} bins {BinCount}");
                //    Console.WriteLine($"      Prelogit {coreScore} = intercept {qscoreParameters.LogisticIntercept} + bins { GetQScorePredictor(QScorePredictor.LogBinCount) * qscoreParameters.LogisticLogBinCount} + dist {GetQScorePredictor(QScorePredictor.ModelDistance) * qscoreParameters.LogisticModelDistance} + ratio { GetQScorePredictor(QScorePredictor.DistanceRatio) * qscoreParameters.LogisticDistanceRatio} + amp {GetQScorePredictor(QScorePredictor.BinCountAmpDistance)}");
                //    Console.WriteLine($"      Logit {score} --> init qscore {(int)Math.Round(-10 * Math.Log10(1 - score))} --> qscore");
                //}
                return(qscore);

            case QScoreMethod.BinCountLinearFit:
                if (this.BinCount >= 100)
                {
                    return(61);
                }
                else
                {
                    return
                        ((int)
                         Math.Round(-10 * Math.Log10(1 - 1 / (1 + Math.Exp(0.5532 - this.BinCount * 0.147))), 0,
                                    MidpointRounding.AwayFromZero));
                }

            case QScoreMethod.GeneralizedLinearFit:     // Generalized linear fit with linear transformation to QScore
                double linearFit = qscoreParameters.GeneralizedLinearFitIntercept;
                linearFit += qscoreParameters.GeneralizedLinearFitLogBinCount *
                             GetQScorePredictor(QScorePredictor.LogBinCount);
                linearFit += qscoreParameters.GeneralizedLinearFitModelDistance *
                             GetQScorePredictor(QScorePredictor.ModelDistance);
                linearFit += qscoreParameters.GeneralizedLinearFitMajorChromosomeCount *
                             GetQScorePredictor(QScorePredictor.MajorChromosomeCount);
                linearFit += qscoreParameters.GeneralizedLinearFitMafMean *
                             GetQScorePredictor(QScorePredictor.MafMean);
                linearFit += qscoreParameters.GeneralizedLinearFitLogMafCv *
                             GetQScorePredictor(QScorePredictor.LogMafCv);
                linearFit += GetQScorePredictor(QScorePredictor.BinCountAmpDistance);
                score      = -11.9 - 11.4 * linearFit; // Scaling to achieve 2 <= qscore <= 61
                score      = Math.Max(2, score);
                score      = Math.Min(61, score);
                return((int)Math.Round(score, 0, MidpointRounding.AwayFromZero));

            default:
                throw new Exception("Unhandled qscore method");
            }
        }
Beispiel #3
0
        public int ComputeQScore(QScoreMethod qscoreMethod, QualityScoreParameters qscoreParameters)
        {
            double score;
            int    qscore;

            switch (qscoreMethod)
            {
            case QScoreMethod.LogisticGermline:
                // Logistic model using a new selection of features.  Gives ROC curve area 0.921
                score  = qscoreParameters.LogisticGermlineIntercept;
                score += GetQScorePredictor(QScorePredictor.LogBinCount) * qscoreParameters.LogisticGermlineLogBinCount;
                score += GetQScorePredictor(QScorePredictor.ModelDistance) * qscoreParameters.LogisticGermlineModelDistance;
                score += GetQScorePredictor(QScorePredictor.DistanceRatio) * qscoreParameters.LogisticGermlineDistanceRatio;
                score  = Math.Exp(score);
                score  = score / (score + 1);
                // Transform probability into a q-score:
                qscore = (int)(Math.Round(-10 * Math.Log10(1 - score)));
                qscore = Math.Min(40, qscore);
                qscore = Math.Max(2, qscore);
                return(qscore);

            case QScoreMethod.Logistic:
                // Logistic model using a new selection of features.  Gives ROC curve area 0.8289
                score  = qscoreParameters.LogisticIntercept;
                score += GetQScorePredictor(QScorePredictor.LogBinCount) * qscoreParameters.LogisticLogBinCount;
                score += GetQScorePredictor(QScorePredictor.ModelDistance) * qscoreParameters.LogisticModelDistance;
                score += GetQScorePredictor(QScorePredictor.DistanceRatio) * qscoreParameters.LogisticDistanceRatio;
                score += GetQScorePredictor(QScorePredictor.BinCountAmpDistance);
                score  = Math.Exp(score);
                score  = score / (score + 1);
                // Transform probability into a q-score:
                qscore = (int)Math.Round(-10 * Math.Log10(1 - score));
                qscore = Math.Min(60, qscore);
                qscore = Math.Max(2, qscore);
                return(qscore);

            case QScoreMethod.BinCountLinearFit:
                if (this.BinCount >= 100)
                {
                    return(61);
                }
                else
                {
                    return((int)Math.Round(-10 * Math.Log10(1 - 1 / (1 + Math.Exp(0.5532 - this.BinCount * 0.147))), 0, MidpointRounding.AwayFromZero));
                }

            case QScoreMethod.GeneralizedLinearFit:     // Generalized linear fit with linear transformation to QScore
                double linearFit = qscoreParameters.GeneralizedLinearFitIntercept;
                linearFit += qscoreParameters.GeneralizedLinearFitLogBinCount *
                             GetQScorePredictor(QScorePredictor.LogBinCount);
                linearFit += qscoreParameters.GeneralizedLinearFitModelDistance *
                             GetQScorePredictor(QScorePredictor.ModelDistance);
                linearFit += qscoreParameters.GeneralizedLinearFitMajorChromosomeCount *
                             GetQScorePredictor(QScorePredictor.MajorChromosomeCount);
                linearFit += qscoreParameters.GeneralizedLinearFitMafMean *
                             GetQScorePredictor(QScorePredictor.MafMean);
                linearFit += qscoreParameters.GeneralizedLinearFitLogMafCv * GetQScorePredictor(QScorePredictor.LogMafCv);
                linearFit += GetQScorePredictor(QScorePredictor.BinCountAmpDistance);
                score      = -11.9 - 11.4 * linearFit; // Scaling to achieve 2 <= qscore <= 61
                score      = Math.Max(2, score);
                score      = Math.Min(61, score);
                return((int)Math.Round(score, 0, MidpointRounding.AwayFromZero));

            default:
                throw new Exception("Unhandled qscore method");
            }
        }
Beispiel #4
0
 public int ComputeQScore(QScoreMethod qscoreMethod)
 {
     double score;
     int qscore;
     switch (qscoreMethod)
     {
         case QScoreMethod.LogisticGermline:
             // Logistic model using a new selection of features.  Gives ROC curve area 0.921
             score = -5.0123;
             score += GetQScorePredictor(QScorePredictor.LogBinCount) * 4.9801;
             score += GetQScorePredictor(QScorePredictor.ModelDistance) * -5.5472;
             score += GetQScorePredictor(QScorePredictor.DistanceRatio) * -1.7914;
             score = Math.Exp(score);
             score = score / (score + 1);
             // Transform probability into a q-score:
             qscore = (int)(Math.Round(-10 * Math.Log10(1 - score)));
             qscore = Math.Min(40, qscore);
             qscore = Math.Max(2, qscore);
             return qscore;
         case QScoreMethod.Logistic:
             // Logistic model using a new selection of features.  Gives ROC curve area 0.8289
             score = -0.5143;
             score += GetQScorePredictor(QScorePredictor.LogBinCount) * 0.8596;
             score += GetQScorePredictor(QScorePredictor.ModelDistance) * -50.4366;
             score += GetQScorePredictor(QScorePredictor.DistanceRatio) * -0.6511;
             score = Math.Exp(score);
             score = score / (score + 1);
             // Transform probability into a q-score:
             qscore = (int)(Math.Round(-10 * Math.Log10(1 - score)));
             qscore = Math.Min(60, qscore);
             qscore = Math.Max(2, qscore);
             return qscore;
         case QScoreMethod.BinCountLinearFit:
             if (this.BinCount >= 100)
                 return 61;
             else
                 return (int)Math.Round(-10 * Math.Log10(1 - 1 / (1 + Math.Exp(0.5532 - this.BinCount * 0.147))), 0, MidpointRounding.AwayFromZero);
         case QScoreMethod.GeneralizedLinearFit: // Generalized linear fit with linear transformation to QScore
             double linearFit = -3.65
                                - 1.12 * GetQScorePredictor(QScorePredictor.LogBinCount)
                                + 3.89 * GetQScorePredictor(QScorePredictor.ModelDistance)
                                + 0.47 * GetQScorePredictor(QScorePredictor.MajorChromosomeCount)
                                - 0.68 * GetQScorePredictor(QScorePredictor.MafMean)
                                - 0.25 * GetQScorePredictor(QScorePredictor.LogMafCv);
             score = -11.9 - 11.4 * linearFit; // Scaling to achieve 2 <= qscore <= 61
             score = Math.Max(2, score);
             score = Math.Min(61, score);
             return (int)Math.Round(score, 0, MidpointRounding.AwayFromZero);
         default:
             throw new Exception("Unhandled qscore method");
     }
 }
Beispiel #5
0
 /// <summary>
 /// Apply quality scores.
 /// </summary>
 public static void AssignQualityScores(List<CanvasSegment> segments, QScoreMethod qscoreMethod)
 {
     foreach (CanvasSegment segment in segments)
     {
         segment.QScore = segment.ComputeQScore(qscoreMethod);
     }
 }
Beispiel #6
0
        public int ComputeQScore(QScoreMethod qscoreMethod)
        {
            double score;
            int    qscore;

            switch (qscoreMethod)
            {
            case QScoreMethod.LogisticGermline:
                // Logistic model using a new selection of features.  Gives ROC curve area 0.921
                score  = -5.0123;
                score += GetQScorePredictor(QScorePredictor.LogBinCount) * 4.9801;
                score += GetQScorePredictor(QScorePredictor.ModelDistance) * -5.5472;
                score += GetQScorePredictor(QScorePredictor.DistanceRatio) * -1.7914;
                score  = Math.Exp(score);
                score  = score / (score + 1);
                // Transform probability into a q-score:
                qscore = (int)(Math.Round(-10 * Math.Log10(1 - score)));
                qscore = Math.Min(40, qscore);
                qscore = Math.Max(2, qscore);
                return(qscore);

            case QScoreMethod.Logistic:
                // Logistic model using a new selection of features.  Gives ROC curve area 0.8289
                score  = -0.5143;
                score += GetQScorePredictor(QScorePredictor.LogBinCount) * 0.8596;
                score += GetQScorePredictor(QScorePredictor.ModelDistance) * -50.4366;
                score += GetQScorePredictor(QScorePredictor.DistanceRatio) * -0.6511;
                score  = Math.Exp(score);
                score  = score / (score + 1);
                // Transform probability into a q-score:
                qscore = (int)(Math.Round(-10 * Math.Log10(1 - score)));
                qscore = Math.Min(60, qscore);
                qscore = Math.Max(2, qscore);
                return(qscore);

            case QScoreMethod.BinCountLinearFit:
                if (this.BinCount >= 100)
                {
                    return(61);
                }
                else
                {
                    return((int)Math.Round(-10 * Math.Log10(1 - 1 / (1 + Math.Exp(0.5532 - this.BinCount * 0.147))), 0, MidpointRounding.AwayFromZero));
                }

            case QScoreMethod.GeneralizedLinearFit:     // Generalized linear fit with linear transformation to QScore
                double linearFit = -3.65
                                   - 1.12 * GetQScorePredictor(QScorePredictor.LogBinCount)
                                   + 3.89 * GetQScorePredictor(QScorePredictor.ModelDistance)
                                   + 0.47 * GetQScorePredictor(QScorePredictor.MajorChromosomeCount)
                                   - 0.68 * GetQScorePredictor(QScorePredictor.MafMean)
                                   - 0.25 * GetQScorePredictor(QScorePredictor.LogMafCv);
                score = -11.9 - 11.4 * linearFit;     // Scaling to achieve 2 <= qscore <= 61
                score = Math.Max(2, score);
                score = Math.Min(61, score);
                return((int)Math.Round(score, 0, MidpointRounding.AwayFromZero));

            default:
                throw new Exception("Unhandled qscore method");
            }
        }