public static MixtureModel FitMixtureModel(IList <int> ad, IList <int> dp, double[] startingMeans)
        {
            var mm = new MixtureModel(ad, dp, startingMeans);

            mm.FitBinomialModel();
            return(mm);
        }
        public static MixtureModel UsePrefitModel(IList <int> ad, IList <int> dp, double[] means, double[] priors)
        {
            var mm = new MixtureModel(ad, dp, means, priors);

            mm.UpdateClusteringAndQScore();
            return(mm);
        }
Exemple #3
0
        /// <summary>
        /// Calculates the Q score and genotype posteriors of a 1/2 locus using a multinomial distribution.
        /// This method is called from Pisces variant caller.
        /// </summary>
        /// <param name="allele1"></param>
        /// <param name="allele2"></param>
        /// <param name="models">IList of models for allele1 and allele 2.  Each model is a 3 element double array.</param>
        /// <returns>RecalibratedVariant that contains the Q score and genotype posteriors.</returns>
        public static MixtureModelResult GetMultiAllelicQScores(CalledAllele allele1, CalledAllele allele2,
                                                                IList <double[]> models)
        {
            int totalCoverage = allele1.TotalCoverage;

            int[] alleleDepths = new int[3];
            alleleDepths[2] = allele2.AlleleSupport;
            alleleDepths[1] = allele1.AlleleSupport;

            // "Reference" here is not really reference--it is just everything else that was not the top two alleles
            alleleDepths[0] = Math.Max(totalCoverage - alleleDepths[1] - alleleDepths[2], 0);

            return(MixtureModel.GetMultinomialQScores(alleleDepths, totalCoverage, models));
        }
Exemple #4
0
 /// <summary>
 /// Calculates Q score of a called allele.
 /// </summary>
 /// <param name="allele"> Called allele from Pisces variant caller. </param>
 /// <param name="model"> Means of binomial model to be used to estimate Q score.  If this has more than three elements,
 /// the elements closest to 0, 0.5 and 1 are used as the alleles true category.  </param>
 /// <param name="priors"> Prior probability for that category.  The length must match the length of model.  </param>
 /// <returns> RecalibratedVariant that holds the Q scores and posteriors of the allele.  </returns>
 public static MixtureModelResult GetGenotypeAndQScore(CalledAllele allele, double[] model, double[] priors)
 {
     var(alleleSupport, totalDepth) = PreprocessCalledAllele(allele);
     return(MixtureModel.CalculateQScoreAndGenotypePosteriors(alleleSupport, totalDepth, model, priors));
 }
Exemple #5
0
 public static SimplifiedDiploidGenotype GetSimplifiedGenotype(CalledAllele allele, double[] model, double[] priors)
 {
     var(alleleSupport, totalDepth) = PreprocessCalledAllele(allele);
     return(MixtureModel.GetSimplifiedGenotype(alleleSupport, totalDepth, model, priors));
 }