gosianow / DRIMSeq

Package Homepage: http://bioconductor.org/packages/devel/bioc/html/DRIMSeq.html Bug Reports: https://support.bioconductor.org/p/new/post/?tag_val=DRIMSeq or https://github.com/gosianow/DRIMSeq/issues
9 stars 4 forks source link

Error on dmPrecision with complex design: optimHess non-finite value supplied by optim #8

Open tbrittoborges opened 3 years ago

tbrittoborges commented 3 years ago

Dear dev @gosianow

I am trying to run DRIMSeq for a experiment with 2 experimental groups and 2 batches, as in the following design matrix:

> design_full
              (Intercept)      conditionKD    batches
1            1                      0                     0
2            1                      0                     0
3            1                      0                     0
4            1                      0                     1
5            1                      0                     1
6            1                      0                     1
7            1                      1                     0
8            1                      1                     0
9            1                      1                     0
10           1                      1                     1
11           1                      1                     1
12           1                      1                     1

For which I get the following error on

> d <- dmPrecision(d, design = design_full)

Error in optimHess(par = par, fn = dm_lik_regG, gr = dm_score_regG, x = x,  :
  non-finite value supplied by optim

This issue is data specific, for example I can't reproduce the issue with a different setup, as for example the one used here: https://github.com/gosianow/DRIMSeq_before_BioC3.6/issues/4#issue-233123327 In the other hand, other people have experienced the same issue when using more complex design:

My question Is there a way around this issue?

tbrittoborges commented 3 years ago

Dear @mikelove, have you experienced this issue before?

mikelove commented 3 years ago

No I didn't see this.

danphillips28 commented 2 years ago

Just thought I'd chime in too - also having a similar issue;

> d
An object of class dmDSdata 
with 10700 genes and 238 samples
data accessors: counts(), samples()
> counts(d)[1:5,1:10]
             gene_id         feature_id   ABD0010   ABD0033    ABD0304    ABD0447   ABD0521   ABD0544   ABD0571    ABD0795
1 ENSG00000004059.11 ENST00000000233.10 210.80889 273.77921 256.111574 226.916899 452.61383 318.09729 298.04935 217.740709
2 ENSG00000004059.11  ENST00000463733.5  29.58746  16.08154  24.828693  23.089118  35.74108  35.58725  32.30751  21.995051
3 ENSG00000004059.11  ENST00000467281.5   0.00000  10.72324   6.816142   5.528162   3.14949  19.26969  13.98865   5.150737
4 ENSG00000004059.11  ENST00000489673.1 119.45742 115.46966   0.000000 157.064920 365.44199 240.86469 153.04874  94.759732
5  ENSG00000003056.8  ENST00000000412.8 177.34442 180.58722 181.797053 316.448715 429.59082 297.51875 247.10198 184.990516
design_full <- model.matrix(~0 + sex.depot + machine + age.at.Biopsy, data=DRIMSeq::samples(d))
d2 <- dmPrecision(d, design = design_full)

Last lines of the process (after "Warning in log(det(n * (-H))) : NaNs produced" being repeated countless times):

Warning in log(det(n * (-H))) : NaNs produced
Warning in log(det(n * (-H))) : NaNs produced
Warning in log(det(n * (-H))) : NaNs produced
Warning in log(det(n * (-H))) : NaNs produced
Warning in log(prop/prop[, q]) : NaNs produced
Error: BiocParallel errors
  element index: 9894, 9895, 9896, 9897, 9898, 9899, ...
  first error: non-finite value supplied by optim

Any suggestions are appreciated! Thank you

maryellenlynall commented 1 year ago

I am having the same issue. Any suggestions?

tbrittoborges commented 1 year ago

Have you tried to add to use add_uniform=TRUE?

d <- dmPrecision(d, design=design, add_uniform=TRUE)
d <- dmFit(d, design=design, add_uniform=TRUE)

This will reduce errors in the event of a full switch (transcript with 0 counts in one group).

Ilarius commented 1 year ago

Hello, did anyone solved this issue? I think it is connected with BioParallel since I am getting a different error if I use the multiCore or not.

This is my design:

design_full2 <- model.matrix(~ cohort + karyotype:ind.n + karyotype, data = samples(d2))

And if I run the dmPresicion with multicore I have this error:

d2 <- dmPrecision(d2, design = design_full2, BPPARAM = BiocParallel::MulticoreParam(8))

! Using a subset of 0.1 genes to estimate common precision !

Stop worker failed with the error: argumentos inválidos para sub-asignación de entorno Error: BiocParallel errors 0 remote errors, element index: 1117 unevaluated and other errors first remote error:

While If I do not use multicore the error changes:

d2 <- dmPrecision(d2, design = design_full2)

! Using a subset of 0.1 genes to estimate common precision !

_Error: BiocParallel errors 1 remote errors, element index: 1074 43 unevaluated and other errors first remote error: Error in optimHess(par = par, fn = dm_lik_regG, gr = dm_scoreregG, x = x, : non-finite value supplied by optim