Beispiel #1
0
	def __log_complete_likelihood1__(self, phi, mu_r, mu_v, new_state=0):	
		llh = []
		if self.cnv: 
			self.compute_n_genomes(0,new_state) # maternal
			mu = (self.nr * mu_r + self.nv*(1-mu_r) ) / (self.nr+ self.nv)
			llh.append(u.log_binomial_likelihood(self.a, self.d, mu) + log(0.5) +  self._log_bin_norm_const)
			self.compute_n_genomes(1,new_state) # paternal
			mu = (self.nr * mu_r + self.nv*(1-mu_r) ) / (self.nr+ self.nv)
			llh.append(u.log_binomial_likelihood(self.a, self.d, mu) + log(0.5) +  self._log_bin_norm_const)
			llh = u.logsumexp(ll)
		else: ## CNV datum or SSM with no CNV
			mu = (1 - phi) * mu_r + phi*mu_v # (mu_r=0.999, mu_v=0.5)
			llh = u.log_binomial_likelihood(self.a, self.d, mu) +  self._log_bin_norm_const
		return 	llh
Beispiel #2
0
	def __log_complete_likelihood1__(self, phi, mu_r, mu_v, new_state=0):	
		llh = []
		if self.cnv: 
			self.compute_n_genomes(0,new_state) # maternal
			mu = (self.nr * mu_r + self.nv*(1-mu_r) ) / (self.nr+ self.nv)
			llh.append(u.log_binomial_likelihood(self.a, self.d, mu) + log(0.5) +  self._log_bin_norm_const)
			self.compute_n_genomes(1,new_state) # paternal
			mu = (self.nr * mu_r + self.nv*(1-mu_r) ) / (self.nr+ self.nv)
			llh.append(u.log_binomial_likelihood(self.a, self.d, mu) + log(0.5) +  self._log_bin_norm_const)
			llh = u.logsumexp(ll)
		else: ## CNV datum or SSM with no CNV
			mu = (1 - phi) * mu_r + phi*mu_v # (mu_r=0.999, mu_v=0.5)
			llh = u.log_binomial_likelihood(self.a, self.d, mu) +  self._log_bin_norm_const
		return 	llh
Beispiel #3
0
	def __log_complete_likelihood__(self, phi, mu_r, mu_v, tp, new_state=0):	
		
		if self.cnv:
			ll = []
			poss_n_genomes = self.compute_n_genomes(tp,new_state)
			poss_n_genomes = [x for x in poss_n_genomes if x[1] > 0]
			for (nr,nv) in poss_n_genomes:
				mu = (nr * mu_r + nv*(1-mu_r) ) / (nr+ nv)
				ll.append(u.log_binomial_likelihood(self.a[tp], self.d[tp], mu) + log(1.0/len(poss_n_genomes)) +  self._log_bin_norm_const[tp])
			if len(poss_n_genomes) == 0:
				ll.append(log(1e-99)) # to handle cases with zero likelihood
			llh = u.logsumexp(ll)
		else: ## CNV datum
			mu = (1 - phi) * mu_r + 0.5*phi
			llh = u.log_binomial_likelihood(self.a[tp], self.d[tp], mu) +  self._log_bin_norm_const[tp]
		return 	llh
Beispiel #4
0
	def __log_complete_likelihood__(self, phi, mu_r, mu_v, tp, new_state=0):	
		
		if self.cnv:
			ll = []
			poss_n_genomes = self.compute_n_genomes(tp,new_state)
			poss_n_genomes = [x for x in poss_n_genomes if x[1] > 0]
			for (nr,nv) in poss_n_genomes:
				mu = (nr * mu_r + nv*(1-mu_r) ) / (nr+ nv)
				ll.append(u.log_binomial_likelihood(self.a[tp], self.d[tp], mu) + log(1.0/len(poss_n_genomes)) +  self._log_bin_norm_const[tp])
			if len(poss_n_genomes) == 0:
				ll.append(log(1e-99)) # to handle cases with zero likelihood
			llh = u.logsumexp(ll)
		else: ## CNV datum
			mu = (1 - phi) * mu_r + phi*mu_v # (mu_r=0.999, mu_v=0.5)
			llh = u.log_binomial_likelihood(self.a[tp], self.d[tp], mu) +  self._log_bin_norm_const[tp]
		return 	llh
Beispiel #5
0
 def __log_complete_likelihood__(self, phi, mu_r, mu_v, tp):
     mu = (1 - phi) * mu_r + phi * mu_v
     return u.log_binomial_likelihood(self.a[tp], self.d[tp],
                                      mu) + self._log_bin_norm_const[tp]
Beispiel #6
0
	def calcLogLikelihoodBinom(self, mu, tp, sd_d=0):
		return u.log_binomial_likelihood(self.a[tp], self.d[tp], mu) +  self._log_bin_norm_const[tp]
Beispiel #7
0
 def __log_complete_likelihood__(self, phi, mu_r, mu_v, tp):
     mu = (1 - phi) * mu_r + phi * mu_v
     return u.log_binomial_likelihood(self.a[tp], self.d[tp], mu) + self._log_bin_norm_const[tp]