本文整理汇总了Python中hmmlearn.hmm.GaussianHMM._do_viterbi_pass方法的典型用法代码示例。如果您正苦于以下问题:Python GaussianHMM._do_viterbi_pass方法的具体用法?Python GaussianHMM._do_viterbi_pass怎么用?Python GaussianHMM._do_viterbi_pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hmmlearn.hmm.GaussianHMM
的用法示例。
在下文中一共展示了GaussianHMM._do_viterbi_pass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log
# 需要导入模块: from hmmlearn.hmm import GaussianHMM [as 别名]
# 或者: from hmmlearn.hmm.GaussianHMM import _do_viterbi_pass [as 别名]
warned=False;
if args.verbose>1: sys.stderr.write(" Iteration %i.\n"%(i));
viterbi = {}
noChange=0;
viterbiCat =np.zeros(allDataCat.shape[0]);
curTot=0;
curNumCNVs=0;
for chr in chrOrder:
#3. Calculate Viterbi path given data
if args.verbose>2: sys.stderr.write(" i=%i; Calculating Viterbi path for %s.\n"%(i,chr));
framelogprob = model._compute_log_likelihood(allData[chr])
#sys.stderr.write("framelogprob dim: "+str(framelogprob.shape)+"\n");
framelogprob[:,cnvsToStateIs[args.ploidy]] = np.subtract(framelogprob[:,cnvsToStateIs[args.ploidy]], args.standardPrior); #add log(prior)
if args.scalePDF>0:
framelogprob = np.subtract(framelogprob,statePDFMaxima) #### This requires some explanation. See Note 1 below.
logprob, viterbi[chr] = model._do_viterbi_pass(framelogprob);
curLen = len(viterbi[chr]);
#4. For each non-standard state, calculate the mean in that state and add a state with a mean representing that ploidy
changeStart=-1
viterbi[chr] = np.insert(viterbi[chr],[0,curLen],[normalState,normalState]); # add initial and terminal normalStates so that telomeres in CNV will be detected.
for j in range(1,len(viterbi[chr])):
if viterbi[chr][j]!=viterbi[chr][j-1]:#there was a change
if changeStart==-1:
if viterbi[chr][j]==normalState:
raise Exception("new state is normal ploidy state");
changeStart=j;
else: #from changeStart to j-1
#calculate the means of this region
localMean = np.mean(allData[chr][changeStart:j,:],axis=0);
#figure out the local CN as the local means divided by the global means, rounded to the nearest logical ploidy
meanRatio = np.divide(localMean,meanNormal);