wangke16 / MSMC-IM

A tool for estimating time-dependent migration rates based on cross-/within-population coalescent rates from MSMC
16 stars 2 forks source link

IndexError on time segements option #5

Open stsmall opened 3 years ago

stsmall commented 3 years ago

Hi @wangke16, I am using MSMC_IM with msmc and chose a different time segment pattern than the default. For msmc, -p 20*1 (as suggested in the msmc readme). When running MSMC_IM.py with the -p option set to the time segment, I get an index error. First it was associated with line 51, where I added an Try/Except statement, now it is occurring on line 52. I was not sure how to fix that line. Any suggestions? thanks, @stsmall

first error python MSMC_IM.py -beta 1e-8,1e-6 -mu 2.8e-9 -p "201" -N1 200000 -N2 400000 -o X_4haps/X.msmc --printfittingdetails --plotfittingdetails --xlog KirFol.K-F.4haps.X.Xcr.msmc.out.final.txt Traceback (most recent call last): File "MSMC_IM.py", line 51, in ln = repeat[-1] segs[-1] + repeat[-2] * segs[-2] #Artifically correct lambdas in the most right time interval(s) to lambda into the second most right time interval IndexError: list index out of range

second error after fixing with Except (shifted all the lines down with new statement) python MSMC_IM.py -beta 1e-8,1e-6 -mu 2.8e-9 -p "201" -N1 200000 -N2 400000 -o X_4haps/X.msmc --printfittingdetails --plotfittingdetails --xlog KirFol.K-F.4haps.X.Xcr.msmc.out.final.txt Traceback (most recent call last): File "MSMC_IM.py", line 55, in if msmc_lambdas00[-(ln+1)] > 1.5 min(msmc_lambdas00[-ln:]) or msmc_lambdas00[-(ln+1)] < max(msmc_lambdas00[-ln:])/1.5: msmc_lambdas00[-ln:] = [msmc_lambdas00[-(ln+1)]] * ln IndexError: list index out of range

wangke16 commented 3 years ago

Hi @stsmall,

The error occurs in line 51 and 52 because in line 51-52 I am artificially correcting lambda estimates in the last time segment to be the same as the last second time segment when there are outrageous MSMC lambda estimates in the last two time segments (which rarely happens but affects MSMC-IM's estimates). This auto-correction reads in at least two items from '-p' options (by which I mean with at least one sum sign e.g. 10*1+5*2). When you use '-p 20*1' this correction isn't applicable in such case.

Thank you for pointing me to this bug. I will fix this bug this week so that other users wont have this problem again. that's important for the longer-term usage of this code.

Best, Ke