stdupas / EnvironmentalDemogeneticsABC

Statistical models of coalescent on a graph
0 stars 3 forks source link

Bug in coalescent #12

Open Becheler opened 9 years ago

Becheler commented 9 years ago

There is a bug in the simul_coalescent_only. :-1: And perhaps in spatialCoalescentSimulation too :-1: :-1:

Sometimes, it seems that several nodes can arrive in a deme with 0 carrying capacity. Hence the bug, when trying to compute the parentality attribution. It occurs in many cases, and I don't know exactly why the program does not crash (it just gets stucked), but this is a problem :) Perhaps cause of the "while" loop ?

For the moment, I focus on spatialCoalescentSimulation, it will be safer for me to verificate if the bug occurs or not (this is weird but spatialCoalescentSimulation does not seem to crash... and everybody seems to coalesce nicely : invisible error ? the worst ones ! ^^)

Becheler commented 9 years ago

I begin to understand what is happening ... If there are no individuals in deme 5, the probability of backward transition to this deme should be 0. Currently, it's not the case. So I think I will do some modifications in migration matrix.

In a branch "migrationBug" : 1 - modificate the way to compute transition matrix (basically, introduce zeroes for empty deme states), then re-normalize 2 - test Merge it in develop and close it

In a "fast coal" branch : 1 - introduce the new coalescent in the main (easier for me to debug, normally faster) 2 - compute branch length and number of mutations according to the value of fast coalescent function (a matrix of coalescent events) 3 - Incorporate the computing of forward probabilities Merge the branch with develop and close it

Becheler commented 9 years ago

Currently, forward probabilities are not computed : the most important was to run and debug the functions. After modifications of mclapply arguments (mc.preschedule=TRUE in mclapply resulted in a 50% loss in simulations... :-1: ), when running 10 000 simulations, "only" 4 crashed. No precise idea why, i will try to relaunch the crashed simulations in order to verificate if the bug comes from forbidden parameters values. If the bug is a random one, I will have to destroy the mclapply, because the mc.preschedule=FALSE in mclapply is ruining the debugging ! :)