zdebruine / RcppML

Rcpp Machine Learning: Fast robust NMF, divisive clustering, and more
GNU General Public License v2.0
89 stars 15 forks source link

lnmf #45

Open nesilin opened 1 year ago

nesilin commented 1 year ago

Hi Zack!

Thanks for developing RcppML and for providing such clear posts about NMF. I would like to run Linked NMF in my cohort data to obtain shared factors. Before that, I was going through the example at the end of your post of Linked NMF (https://www.zachdebruine.com/post/linked-nmf-for-signal-source-separation/) and realized you updated the aml dataset. I tried the following to get a quick idea of how it works. I obtained the following error:

library(RcppML)
library(singlet)

data(aml)

# make sample names unique
aml$metadata_h$new_names <- paste(aml$metadata_h$samples, aml$metadata_h$category, sep="-")
colnames(aml$data) <- aml$metadata_h$new_names

# make list of datasets
data_examp <- list(
  aml$data[, which(grepl( "AML" , colnames(aml$data)))],
  aml$data[, which(grepl( "Control" , colnames(aml$data)))]
)

# run linked nmf
lnmf_model <- lnmf(data_examp, k_wh = 3, k_uv = c(2, 2))
Error in getClass(Class, where = topenv(parent.frame())): “lnmf” is not a defined class
Traceback:

1. lnmf(data_examp, k_wh = 3, k_uv = c(2, 2))
2. new("lnmf", w = w, u = u, v = v, h = h, d_wh = d_wh, d_uv = d_uv, 
 .     misc = model@misc)
3. getClass(Class, where = topenv(parent.frame()))
4. stop(gettextf("%s is not a defined class", dQuote(Class)), domain = NA)

These are the package versions

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /home/isentis/software/anaconda3/envs/ines_r4.1.1c/lib/libopenblasp-r0.3.21.so

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

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

other attached packages:
[1] singlet_0.99.27    dplyr_1.0.9        SeuratObject_4.0.2 Seurat_4.0.5      
[5] RcppML_0.5.6      

loaded via a namespace (and not attached):
  [1] fgsea_1.20.0          Rtsne_0.16            colorspace_2.0-3     
  [4] deldir_1.0-6          ellipsis_0.3.2        ggridges_0.5.3       
  [7] IRdisplay_1.0         base64enc_0.1-3       spatstat.data_3.0-1  
 [10] leiden_0.4.2          listenv_0.8.0         ggrepel_0.9.1        
 [13] fansi_1.0.3           codetools_0.2-18      splines_4.1.1        
 [16] knitr_1.40            polyclip_1.10-0       IRkernel_1.1         
 [19] jsonlite_1.8.0        ica_1.0-3             cluster_2.1.4        
 [22] rgeos_0.5-9           png_0.1-7             uwot_0.1.10          
 [25] shiny_1.7.2           sctransform_0.3.4     spatstat.sparse_3.0-1
 [28] msigdbr_7.5.1         compiler_4.1.1        httr_1.4.4           
 [31] assertthat_0.2.1      Matrix_1.4-1          fastmap_1.1.0        
 [34] lazyeval_0.2.2        limma_3.50.3          cli_3.3.0            
 [37] later_1.3.0           htmltools_0.5.3       tools_4.1.1          
 [40] igraph_1.3.4          gtable_0.3.0          glue_1.6.2           
 [43] RANN_2.6.1            reshape2_1.4.4        fastmatch_1.1-3      
 [46] Rcpp_1.0.9            scattermore_0.8       vctrs_0.4.1          
 [49] babelgene_22.9        nlme_3.1-159          lmtest_0.9-40        
 [52] spatstat.random_3.1-4 xfun_0.32             stringr_1.4.1        
 [55] globals_0.16.1        mime_0.12             miniUI_0.1.1.1       
 [58] lifecycle_1.0.1       irlba_2.3.5           goftest_1.2-3        
 [61] future_1.22.1         MASS_7.3-58.1         zoo_1.8-10           
 [64] scales_1.2.1          spatstat.core_2.4-4   promises_1.2.0.1     
 [67] spatstat.utils_3.0-2  parallel_4.1.1        RColorBrewer_1.1-3   
 [70] reticulate_1.25       pbapply_1.5-0         gridExtra_2.3        
 [73] ggplot2_3.3.6         rpart_4.1.16          stringi_1.7.8        
 [76] BiocParallel_1.28.3   repr_1.1.3            rlang_1.0.4          
 [79] pkgconfig_2.0.3       matrixStats_0.62.0    evaluate_0.16        
 [82] lattice_0.20-45       ROCR_1.0-11           purrr_0.3.4          
 [85] tensor_1.5            patchwork_1.1.2       htmlwidgets_1.5.4    
 [88] cowplot_1.1.1         tidyselect_1.1.2      parallelly_1.32.1    
 [91] RcppAnnoy_0.0.19      plyr_1.8.7            magrittr_2.0.3       
 [94] R6_2.5.1              generics_0.1.3        pbdZMQ_0.3-5         
 [97] DBI_1.1.3             mgcv_1.8-40           pillar_1.8.1         
[100] fitdistrplus_1.1-8    sp_1.5-0              survival_3.4-0       
[103] abind_1.4-5           tibble_3.1.8          future.apply_1.9.0   
[106] crayon_1.5.1          uuid_1.1-0            KernSmooth_2.23-20   
[109] utf8_1.2.2            spatstat.geom_3.1-0   plotly_4.10.0        
[112] grid_4.1.1            data.table_1.14.2     digest_0.6.29        
[115] xtable_1.8-4          tidyr_1.2.0           httpuv_1.6.5         
[118] munsell_0.5.0         viridisLite_0.4.1    

Thank you!

zdebruine commented 1 year ago

Got it, I'll try to address this issue early next week. You will see a significant change to the way we do LNMF however, as we have developed much better theoretical methods that complement the method for integration.

KaBach commented 10 months ago

Hey Zack, Thanks also from my side for the great pacakge and the clear posts. I am receiving the exact same error here with my own data ("lnmf" is not a defined class) version 0.5.6. Any idea as to when you'll find time to address the issue?

Thanks!