const-ae / proDA

Protein Differential Abundance for Label-Free Mass Spectrometry https://const-ae.github.io/proDA/
18 stars 8 forks source link

Sigma is 0 when calculating hess_fnc #21

Closed elena-krismer closed 1 year ago

elena-krismer commented 1 year ago

Hi, Our prottipackage is using proDAfor the differential abundance calculation. One of our users recently encountered following error, when using protti: image

proDA_fit <- proDA(proDA_input_clashing, design = proDA_design_clashing)

Screenshot 2023-10-27 at 08 52 39

After further investigation I found that:

I guess the error comes from the fact that R is very bad when it comes to handling values very close to zero and can only handle doubles/64 bit floating numbers. When comparing 1e-100284 (in this case) with 1-e-100, R messes up.

elena-krismer commented 1 year ago

here would be the link to the data to reproduce the error: https://github.com/elena-krismer/proDA_troubleshoot_data

const-ae commented 1 year ago

Hi Elena,

this is an excellent bug report; thanks a lot for taking the time to investigate what went wrong and how it can be fixed and making a minimal PR.

Checking for sigma2 <= 0 in hess_fnc seems reasonable to me. Is there a particular reason though that it is preferable over changing line 314 to fit_sigma2 <- max(1e-100, nl_res$par[p+1])? This would mirror the behavior in lines 280, 290, and 300.

Alternatively, we could keep your check in hess_fnc and remove the checks in lines 280, 290, and 300. What do you think is best?

Best, Constantin

const-ae commented 1 year ago

Thanks again for your contribution. I merged the PR.