Error in simpleLoess: NA/NaN/Inf in foreign function call

gc5 picture gc5 · Oct 16, 2013 · Viewed 8.4k times · Source

I am trying to use normalize.loess() through lumiN() from lumi package.

At the 38th iteration, in loess() function it fails with

Error in simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize,  : 
NA/NaN/Inf in foreign function call (arg 1)

I have searched and it may be related with the fact that an argument is missing.

I checked with debug(loess) and all arguments are defined.

I cannot post data because they are very large (13237x566) and also because they are confidential but.. I found this:

  • a minimal example works (random matrix 20x5)
  • normalization fails between column 1 and 38
  • same normalization using only those columns completed successfully
  • it is not a memory issue
  • matrix has not NA values

What am I missing?

Thanks

Code

raw_matrix <- lumiR('example.txt')
norm_matrix <- lumiN(raw_matrix, method='loess')
Perform loess normalization ...
Done with 1 vs 2 in iteration 1 
Done with 1 vs 3 in iteration 1 
Done with 1 vs 4 in iteration 1 
Done with 1 vs 5 in iteration 1 
Done with 1 vs 6 in iteration 1 
Done with 1 vs 7 in iteration 1 
Done with 1 vs 8 in iteration 1 
Done with 1 vs 9 in iteration 1 
Done with 1 vs 10 in iteration 1 
Done with 1 vs 11 in iteration 1 
Done with 1 vs 12 in iteration 1 
Done with 1 vs 13 in iteration 1 
Done with 1 vs 14 in iteration 1 
Done with 1 vs 15 in iteration 1 
Done with 1 vs 16 in iteration 1 
Done with 1 vs 17 in iteration 1 
Done with 1 vs 18 in iteration 1 
Done with 1 vs 19 in iteration 1 
Done with 1 vs 20 in iteration 1 
Done with 1 vs 21 in iteration 1 
Done with 1 vs 22 in iteration 1 
Done with 1 vs 23 in iteration 1 
Done with 1 vs 24 in iteration 1 
Done with 1 vs 25 in iteration 1 
Done with 1 vs 26 in iteration 1 
Done with 1 vs 27 in iteration 1 
Done with 1 vs 28 in iteration 1 
Done with 1 vs 29 in iteration 1 
Done with 1 vs 30 in iteration 1 
Done with 1 vs 31 in iteration 1 
Done with 1 vs 32 in iteration 1 
Done with 1 vs 33 in iteration 1 
Done with 1 vs 34 in iteration 1 
Done with 1 vs 35 in iteration 1 
Done with 1 vs 36 in iteration 1 
Done with 1 vs 37 in iteration 1 
Done with 1 vs 38 in iteration 1 
Error in simpleLoess(y, x, w, span, degree, parametric, drop.square, normalize,  : 
  NA/NaN/Inf in foreign function call (arg 1)

Environment

My sessionInfo() is

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] affy_1.38.1          lumi_2.12.0          Biobase_2.20.0      
[4] BiocGenerics_0.6.0   BiocInstaller_1.10.2

loaded via a namespace (and not attached):
[1] affyio_1.28.0         annotate_1.38.0       AnnotationDbi_1.22.6 
[4] beanplot_1.1          Biostrings_2.28.0     colorspace_1.2-4     
[7] DBI_0.2-7             GenomicRanges_1.12.5  grid_3.0.2           
[10] illuminaio_0.2.0      IRanges_1.18.1        KernSmooth_2.23-10   
[13] lattice_0.20-24       limma_3.16.8          MASS_7.3-29          
[16] Matrix_1.0-14         matrixStats_0.8.12    mclust_4.2           
[19] methylumi_2.6.1       mgcv_1.7-27           minfi_1.6.0          
[22] multtest_2.16.0       nleqslv_2.0           nlme_3.1-111         
[25] nor1mix_1.1-4         preprocessCore_1.22.0 RColorBrewer_1.0-5   
[28] reshape_0.8.4         R.methodsS3_1.5.2     RSQLite_0.11.4       
[31] siggenes_1.34.0       splines_3.0.2         stats4_3.0.2         
[34] survival_2.37-4       tcltk_3.0.2           tools_3.0.2          
[37] XML_3.98-1.1          xtable_1.7-1          zlibbioc_1.6.0

Answer

gc5 picture gc5 · Oct 16, 2013

I somehow figured out what was not working: I was trying to normalize a log2 matrix. As far as I know normalize.loess by default log transforms the input matrix, so that was going to be log transformed twice.

This was a problem, because some values in input matrix were equal to 1, so:

log2(log2(1)) = Inf

that clearly is not allowed as value during normalization.

Hope this helps someone.