gphocs-dev / G-PhoCS

G-PhoCS is a software package for inferring ancestral population sizes, population divergence times, and migration rates from individual genome sequences.
33 stars 4 forks source link

Minor bug in traceLineage (patch.c) #41

Open evgenyidc opened 6 years ago

evgenyidc commented 6 years ago

Minor bug in traceLineage() (patch.c):

Before the main loop of this function starts (while(proceed)), the function initializes the migration rate at the bottom of the lineage being detached (or re-connected). This is done in the loop between line 969 and 978 in patch.c (version 1.3.2, 13/12/2017). This initialization identifies all migration bands whose target population is the current population and whose time span includes the start time (age). If age is very close to the start/end time of a migration band, we might get a slight rounding error and not correctly identify a migration band as being relevant. This doesn't cause a significant difference in computation, but the program might later encounter Fatal Error 0007 (migration rate is not 0 at top of population). Error encountered by Laura Bertola (slouisianae_rd data set).

Short-term solution: turn Fatal Error 0007 into a warning and allow program to continue

Mid-term solution:
change initialization of mig_rate to trace MIG_BAND_START and MIG_BAND_END events, so that it is consistent with later calculations regardless of rounding errors.

Long-term solution: change way in which "living mig bands" are determined (not through events but through an time table. Accessing a single data structure to determine this should solve this problem.