Question: SCRAN - Question: Error when calling cosineNorm through fastMNN
gravatar for tobi
8 months ago by
tobi0 wrote:


I have been running the mnnCorrect from the SCRAN package without issues, and now wanted to run the fastMNN (scripts downloaded form github; However, when calling the fastMNN function ( mnn.out <-, c(original, list(k=20, d=50))) ) I end up getting the error:

 Fejl i FUN(X[[i]], ...) : objekt 'cxx_cosine_norm' blev ikke fundet

I can see that "cxx_cosine_norm" is called within the cosineNorm function (out <- .Call(cxx_cosine_norm, X, mode!="l2norm")), which is called within the fastMNN function. I am puzzled as the mnnCorrect calls the same cosineNorm function, without any issues. Does anybody how an suggestion to why the "cxx_cosine_norm" can't be found when called through fastMNN?

All help will be greatly appreciated!


Session info:

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

[1] da_DK.UTF-8/da_DK.UTF-8/da_DK.UTF-8/C/da_DK.UTF-8/da_DK.UTF-8

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

other attached packages:
 [1] BiocManager_1.30.1          dplyr_0.7.6                 Matrix_1.2-14               scran_1.8.2                
 [5] DropletUtils_1.1.5          scater_1.9.7                SingleCellExperiment_1.3.6  SummarizedExperiment_1.11.5
 [9] DelayedArray_0.7.19         BiocParallel_1.14.2         matrixStats_0.53.1          GenomicRanges_1.33.7       
[13] GenomeInfoDb_1.17.1         IRanges_2.15.14             S4Vectors_0.19.17           ggplot2_3.0.0              
[17] Biobase_2.41.1              BiocGenerics_0.27.1        

loaded via a namespace (and not attached):
 [1] viridis_0.5.1            dynamicTreeCut_1.63-1    edgeR_3.23.3             viridisLite_0.3.0        DelayedMatrixStats_1.3.4
 [6] shiny_1.1.0              assertthat_0.2.0         statmod_1.4.30           GenomeInfoDbData_1.1.0   vipor_0.4.5             
[11] pillar_1.3.0             lattice_0.20-35          glue_1.2.0               limma_3.37.3             digest_0.6.15           
[16] promises_1.0.1           XVector_0.21.3           colorspace_1.3-2         htmltools_0.3.6          httpuv_1.4.4.2          
[21] plyr_1.8.4               pkgconfig_2.0.1          zlibbioc_1.27.0          purrr_0.2.5              xtable_1.8-2            
[26] scales_0.5.0             later_0.7.3              tibble_1.4.2             DT_0.4                   withr_2.1.2             
[31] lazyeval_0.2.1           magrittr_1.5             crayon_1.3.4             mime_0.5                 beeswarm_0.2.3          
[36] FNN_1.1                  tools_3.5.0              data.table_1.11.4        stringr_1.3.1            Rhdf5lib_1.3.1          
[41] munsell_0.5.0            locfit_1.5-9.1           bindrcpp_0.2.2           compiler_3.5.0           rlang_0.2.1             
[46] rhdf5_2.25.4             grid_3.5.0               RCurl_1.95-4.10          tximport_1.9.8           rstudioapi_0.7          
[51] rjson_0.2.20             htmlwidgets_1.2          igraph_1.2.1             bitops_1.0-6             gtable_0.2.0            
[56] reshape2_1.4.3           R6_2.2.2                 gridExtra_2.3            bindr_0.1.1              stringi_1.2.3           
[61] ggbeeswarm_0.6.0         Rcpp_0.12.17             tidyselect_0.2.4

scran mnncorrect fastmnn • 271 views
ADD COMMENTlink modified 8 months ago by Aaron Lun23k • written 8 months ago by tobi0
Answer: SCRAN - Question: Error when calling cosineNorm through fastMNN
gravatar for Aaron Lun
8 months ago by
Aaron Lun23k
Cambridge, United Kingdom
Aaron Lun23k wrote:

I imagine that you're sourceing the fastMNN.R file and trying to run the function. Unfortunately, packages don't work that way. The cxx_cosine_norm object provides a registered entry point to the C++ shared library within scran, which is only visible to other scran functions in the installed package (i.e., following R CMD INSTALL or friends). It's not exported, nor should it be - why would a user ever need to deal with C++ code? You'll face similar issues with several internal R functions that are used by fastMNN but are not exported.

The only solution is to actually install the version of scran that contains fastMNN. This requires switching packages over to BioC-devel, see the instructions at

ADD COMMENTlink modified 8 months ago • written 8 months ago by Aaron Lun23k

Dear Aron,

Yes I was sourcing through the R files, but seem to have gotten it to work now through the BioC-devel. Thank you very much for the help and for creating and maintaining scran!

ADD REPLYlink written 8 months ago by tobi0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 448 users visited in the last hour