rr1859 / R.4Cker

MIT License
16 stars 15 forks source link

parameter estimation issues #29

Open daler opened 7 years ago

daler commented 7 years ago

Hi @rr1859 -

For a 4-bp cutter experiment with 3 replicates, using the recommend k=3 or k=5 in a near-bait analysis causes lots of warnings ("Warning: only 1 iteration. Using starting parameters") followed by the error Error in 2:nrow(windows) : argument of length 0. Interestingly this does not happen with k=4.

This appears to be from repeated calls to parameterEstimationCis, which is returning parameters identical to the starting parameters. When this happens enough times, the value of lower is finally small enough to exit out of the while-loop in nearBaitAnalysis. At that point, the par_est_results$mod_fit is still the same as the starting parameters.

So that explains the "Using starting parameters" errors, but not the "Error in 2:nrow(windows)" error.

Tracking this down further, it appears that the error is from viterbi3State, in this line: https://github.com/rr1859/R.4Cker/blob/db41c4d54eafa2489a3817bc36b84854c188a55c/R/viterbi3State.R#L106. The problem is that in the table_intersect dataframe, there are no regions that are called as high-interacting in all replicates, and so final_intersect_trim_hi is NULL and merge_windows raises the error.

I tried changing set.seed(7) to set.seed(NULL) but this did not solve the issue.

Can you provide some insight into why this error is occurring on k=3 and k=5 but not k=4? I'd be happy to provide bedGraphs. Thanks.

rr1859 commented 7 years ago

Hi - sorry for the late reply but I was traveling this month. I would be interested in seeing the bedgraphs and also the stats file. Not sure why it only works for k=4.

daler commented 7 years ago

Thanks. I'm actually unable to consistently reproduce, and still trying to get a minimally working example. However, would it be possible to add some error checking in merge_windows to avoid such issues? It seems that finding less than 2 interacting regions in a replicate will cause a crash.

daler commented 7 years ago

@rr1859 is there an email I could send you some problematic bedgraphs?

rr1859 commented 7 years ago

rraviram@ucsd.edu

sameet commented 6 years ago

This error still seems to happen randomly. Admittedly the data did not pass QC. But the nearbait analysis failed at k=5, and k=4, but worked with k=3.