ay-lab / dcHiC

dcHiC: Differential compartment analysis for Hi-C datasets
MIT License
60 stars 10 forks source link

Update hmmsegment to improve error handling #60

Closed robomics closed 1 year ago

robomics commented 1 year ago

Update hmmsegment to attempt model fitting with depmixS4::fit() up to 5 times before failing.

Model fitting in hmmsegment() can sometime fails with an error like:

Error in fb(init = init, A = trDens, B = dens, ntimes = ntimes(object),  :
  NA/NaN/Inf in foreign function call (arg 10)
Calls: subcompartment ... <Anonymous> -> .local -> em -> eval -> eval -> em.depmix -> fb
Execution halted

This is a known issue (see depmixS4/issues). The workaround from this commit is a quick fix. In the issue linked above, depmixS4 authors suggest more robust ways to workaround this issue.

If one is particularly unlucky, changing the default seed could also be an option (see https://github.com/ay-lab/dcHiC/pull/59)

ay-lab commented 1 year ago

Thanks a lot for your help!