// -*- mode: c++; indent-tabs-mode: nil; -*- // // Copyright 2009 Illumina, Inc. // // This software is covered by the "Illumina Genome Analyzer Software // License Agreement" and the "Illumina Source Code License Agreement", // and certain third party copyright/licenses, and any user of this // source file is bound by the terms therein (see accompanying files // Illumina_Genome_Analyzer_Software_License_Agreement.pdf and // Illumina_Source_Code_License_Agreement.pdf and third party // copyright/license notices). // // /// \file /// \author Chris Saunders /// #include "position_loghood_minfunc.hh" #include "blt_common/position_snp_call_lrt.hh" #define CODEMIN_USE_BOOST #include "minimize_1d.h" #include "minimize_conj_direction.h" #include "boost/math/distributions/chi_squared.hpp" #include #include void position_snp_call_lrt(const double alpha, const snp_pos_info& pi, lrt_snp_call& sc){ if(pi.ref_base=='N') return; unsigned ecount(0); const unsigned n_calls(pi.calls.size()); for(unsigned i(0);i delta_loghood) return; double x_nonref_freq; double x_loghood; position_nonref_freq_loghood_minfunc mf(pi); static const double x1(0.5); static const double x2(0.4); codemin::minimize_1d(x1,x2,mf.val(x1),mf,x_nonref_freq,x_loghood); x_nonref_freq = mf.arg_to_prob(x_nonref_freq); const double log_lrt(-2.*(x_loghood+null_loghood)); // becuase null has the parameter fixed to a boundary value, the // asymmtotic distribution is a 50:50 mixture of csq(0) and chq(1) // -- the same effect as multiplying alpha of csq(1) by 2, dividing // the null prob by 2. (as we do below): boost::math::chi_squared dist(1); const double null_prob((1.-boost::math::cdf(dist,log_lrt))/2.); sc.is_snp=(null_prob