const-ae / proDA

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

Error in nlminb(), NA/NaN gradient evaluation #23

Open Sasimonthakan opened 1 month ago

Sasimonthakan commented 1 month ago

Hello,

I am following your instruction. However, I keep getting this error message: Warning: NAs producedWarning: NA/NaN function evaluationError in nlminb(start = c(beta_init, sigma2_init), objective = function(par) { : NA/NaN gradient evaluation Since proDA() can handle missing values, why do I get this error? What should I do to solve this?

Thanks in advance.

const-ae commented 1 month ago

Hi Sasimonthakan,

I am sorry that you ran into an issue with the package.

Warning: NAs producedWarning: NA/NaN function evaluationError in nlminb(start = c(beta_init, sigma2_init), objective = function(par) { : NA/NaN gradient evaluation

Even though the warning mentions NA it doesn't mean that the problems are missing values in the original data, but rather indicates some divergence when optimizing the coefficients of the model. There could be many different reasons for such divergences (e.g., extreme values like +-Inf or small variances). If you want to dig deeper, you can call debugonce(pd_lm.fit) to step through the function call and see the value of each variable while the function is evaluated.

One challenge will be that pd_lm.fit is called for each protein (i.e., row of your input matrix) and the warning might only occur for one or a few of all the proteins.

If you could identify the parameters to pd_lm.fit that cause the warning, I can help you debug and figure out how we can change the function to avoid such warnings.

Best, Constantin