def eval_proposal(self, proposal): """Compute probability of proposal""" #util.tic("eval") # compute recon probability info = {} # DEBUG counts = coal.count_lineages_per_branch(self.coal_tree, proposal.coal_recon, proposal.locus_tree) maxcount = max(x[0] for x in counts.values()) #util.logger("max lineage count %d" % maxcount) if maxcount > 10: return -util.INF p = dlcoal.prob_dlcoal_recon_topology(self.coal_tree, proposal.coal_recon, proposal.locus_tree, proposal.locus_recon, proposal.locus_events, proposal.daughters, self.stree, self.n, self.duprate, self.lossrate, self.pretime, self.premean, nsamples=self.nsamples, add_spec=False, info=info) proposal.data = info #util.toc() return p
for node in fly_stree: node.dist *= gen_per_myr # (convert to generations) n = int(100e6) * 2 duprate = .0012 / gen_per_myr lossrate = .0011 / gen_per_myr coal_tree, ex = dlcoal.sample_dlcoal(fly_stree, n, duprate, lossrate) #draw_tree_names(coal_tree, scale=1e-7) if 0: draw_tree_names(coal_tree, scale=.5e-7) print exp(dlcoal.prob_dlcoal_recon_topology( coal_tree, ex["coal_recon"], ex["locus_tree"], ex["locus_recon"], ex["locus_events"], ex["daughters"], fly_stree, n, duprate, lossrate, pretime=None, premean=None, maxdoom=20, nsamples=100, add_spec=True)) if 0: draw_tree_names(coal_tree, scale=.5e-7, minlen=8) draw_tree_names(ex["locus_tree"], scale=.5e-7, minlen=8) print exp(dlcoal.prob_multicoal_recon_topology( coal_tree, ex["coal_recon"], ex["locus_tree"], n, ex["daughters"])) print exp(dlcoal.prob_multicoal_recon_topology2( coal_tree, ex["coal_recon"], ex["locus_tree"], n, ex["daughters"])) if 0: draw_tree_names(coal_tree, scale=1e-7)
def eval_proposal(self, proposal): """Compute probability of proposal""" ### util.tic("eval") # proposal.coal_tree.write() # compute recon probability info = {} # DEBUG counts = coal.count_lineages_per_branch(proposal.coal_tree, proposal.coal_recon, proposal.locus_tree) maxcount = max(x[0] for x in counts.values()) # util.logger("max lineage count %d" % maxcount) # do not continue if there are too many deep coalescences if maxcount > 10: return -util.INF # estimate coal_tree if self.stage == "coal_tree": #util.tic("reconprob") p = reconprob.prob_gene_species_alignment_recon( self.alnfile, self.partfile, self.stree, self.popsizes, self.duprate, self.lossrate, self.subrate, self.beta, self.pretime, self.premean, proposal.coal_tree, proposal.coal_recon, self.nsamples_coal, proposal.locus_tree, proposal.locus_recon, self.nsamples_locus, proposal.daughters, self.rates, self.freqs, self.alphas, self.threads, self.seed, self.eps, info=info) #util.toc() """ p_joint = reconprob.prob_locus_gene_species_alignment_recon(self.alnfile, self.partfile, self.stree, self.popsizes, self.duprate, self.lossrate, self.subrate, self.beta, self.pretime, self.premean, proposal.coal_tree, proposal.coal_recon, self.nsamples_coal, proposal.locus_tree, proposal.locus_recon, self.nsamples_locus, proposal.daughters, self.rates, self.freqs, self.alphas, self.threads, self.seed, self.eps, info=info) util.log("p = %f p_joint = %f [maxp = %f]" % (p, p_joint, self.maxp)) print '(p,p_joint,maxp', (p, p_joint, self.maxp) """ # estimate locus_tree else: p = dlcoal.prob_dlcoal_recon_topology( stree=self.stree, n=self.popsizes, duprate=self.duprate, lossrate=self.lossrate, pretime=self.pretime, premean=self.premean, coal_tree=proposal.coal_tree, coal_recon=proposal.coal_recon, locus_tree=proposal.locus_tree, locus_recon=proposal.locus_recon, locus_events=proposal.locus_events, daughters=proposal.daughters, nsamples=self.nsamples_locus, add_spec=False, info=info) """ p_joint = reconprob.prob_locus_gene_species_alignment_recon(self.alnfile, self.partfile, self.stree, self.popsizes, self.duprate, self.lossrate, self.subrate, self.beta, self.pretime, self.premean, proposal.coal_tree, proposal.coal_recon, self.nsamples_coal, proposal.locus_tree, proposal.locus_recon, self.nsamples_locus, proposal.daughters, self.rates, self.freqs, self.alphas, self.threads, self.seed, self.eps, info=info) util.log("p = %f p_joint = %f [maxp = %f]" % (p, p_joint, self.maxp)) print '(p,p_joint,maxp', (p, p_joint, self.maxp) """ proposal.data = info #util.toc() return p