Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in projectR method for sparse matrix data #39

Closed
dimalvovs opened this issue Feb 15, 2024 · 3 comments · Fixed by #42
Closed

Errors in projectR method for sparse matrix data #39

dimalvovs opened this issue Feb 15, 2024 · 3 comments · Fixed by #42
Labels

Comments

@dimalvovs
Copy link
Collaborator

There is a method to run projectR on sparse data, but it fails with an error.

setMethod("projectR",signature(data="dgCMatrix",loadings="matrix"),function(

To reproduce:

load("data/p.RNAseq6l3c3t.RData")
load("data/CR.RNAseq6l3c3t.RData")

data <- as(p.RNAseq6l3c3t, "sparseMatrix")
loadings <- CR.RNAseq6l3c3t@featureLoadings
class(data)
class(loadings)

projectR(data, loadings)
[1] "108 row names matched between data and loadings"
[1] "Updated dimension of data: 108 54"
Error in t.default(dataM[[2]]) : argument is not a matrix

It looks like the first bug is that t.default is called instead of Matrix::t on dataM[[2]]. But even if using the correct t, the result still produces an error:

dataNames <- rownames(data)
loadingsNames <- rownames(loadings)

dataM <- geneMatchR(data1=data, data2=loadings, data1Names=dataNames, data2Names=loadingsNames, merge=FALSE)
projection <- MatrixModels:::lm.fit.sparse(Matrix::t(dataM[[2]]), dataM[[1]])
Error in MatrixModels:::lm.fit.sparse(Matrix::t(dataM[[2]]), dataM[[1]]) : 
  incompatible dimensions of (x,y)
@dimalvovs
Copy link
Collaborator Author

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.1.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] CoGAPS_3.22.0       projectR_1.19.01    testthat_3.2.1     
[4] bigmemory_4.6.4     Biobase_2.62.0      BiocGenerics_0.48.1

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3          rstudioapi_0.15.0          
  [3] jsonlite_1.8.8              umap_0.2.10.0              
  [5] magrittr_2.0.3              fs_1.6.3                   
  [7] zlibbioc_1.48.0             vctrs_0.6.5                
  [9] ROCR_1.0-11                 memoise_2.0.1              
 [11] RCurl_1.98-1.14             askpass_1.2.0              
 [13] forcats_1.0.0               progress_1.2.3             
 [15] htmltools_0.5.7             S4Arrays_1.2.0             
 [17] usethis_2.2.2               curl_5.2.0                 
 [19] Rhdf5lib_1.24.1             rhdf5_2.46.1               
 [21] SparseArray_1.2.3           KernSmooth_2.23-22         
 [23] htmlwidgets_1.6.4           desc_1.4.3                 
 [25] plyr_1.8.9                  cachem_1.0.8               
 [27] uuid_1.2-0                  mime_0.12                  
 [29] lifecycle_1.0.4             iterators_1.0.14           
 [31] pkgconfig_2.0.3             Matrix_1.6-5               
 [33] R6_2.5.1                    fastmap_1.1.1              
 [35] GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
 [37] shiny_1.8.0                 digest_0.6.34              
 [39] colorspace_2.1-0            AnnotationDbi_1.64.1       
 [41] S4Vectors_0.40.2            rprojroot_2.0.4            
 [43] RSpectra_0.16-1             pkgload_1.3.4              
 [45] RSQLite_2.3.5               GenomicRanges_1.54.1       
 [47] filelock_1.0.3              fansi_1.0.6                
 [49] httr_1.4.7                  abind_1.4-5                
 [51] compiler_4.3.2              rngtools_1.5.2             
 [53] remotes_2.4.2.1             bit64_4.0.5                
 [55] withr_3.0.0                 doParallel_1.0.17          
 [57] BiocParallel_1.36.0         DBI_1.2.0                  
 [59] viridis_0.6.5               pkgbuild_1.4.3             
 [61] gplots_3.1.3                biomaRt_2.58.1             
 [63] tsne_0.1-3.1                openssl_2.1.1              
 [65] rappdirs_0.3.3              DelayedArray_0.28.0        
 [67] sessioninfo_1.2.2           caTools_1.18.2             
 [69] gtools_3.9.5                tools_4.3.2                
 [71] httpuv_1.6.14               msigdbr_7.5.1              
 [73] glue_1.7.0                  rhdf5filters_1.14.1        
 [75] promises_1.2.1              grid_4.3.2                 
 [77] gridBase_0.4-7              cluster_2.1.6              
 [79] reshape2_1.4.4              fgsea_1.28.0               
 [81] generics_0.1.3              gtable_0.3.4               
 [83] hms_1.1.3                   data.table_1.15.0          
 [85] xml2_1.3.6                  utf8_1.2.4                 
 [87] XVector_0.42.0              ggrepel_0.9.5              
 [89] foreach_1.5.2               pillar_1.9.0               
 [91] stringr_1.5.1               babelgene_22.9             
 [93] limma_3.58.1                later_1.3.2                
 [95] dplyr_1.1.4                 BiocFileCache_2.10.1       
 [97] lattice_0.22-5              bit_4.0.5                  
 [99] tidyselect_1.2.0            registry_0.5-1             
[101] SingleCellExperiment_1.24.0 Biostrings_2.70.1          
[103] miniUI_0.1.1.1              bigmemory.sri_0.1.8        
[105] gridExtra_2.3               IRanges_2.36.0             
[107] SummarizedExperiment_1.32.0 stats4_4.3.2               
[109] statmod_1.5.0               NMF_0.26                   
[111] devtools_2.4.5              brio_1.1.4                 
[113] matrixStats_1.2.0           stringi_1.8.3              
[115] codetools_0.2-19            tibble_3.2.1               
[117] BiocManager_1.30.22         cli_3.6.2                  
[119] xtable_1.8-4                reticulate_1.35.0          
[121] munsell_0.5.0               Rcpp_1.0.12                
[123] GenomeInfoDb_1.38.5         dbplyr_2.4.0               
[125] png_0.1-8                   XML_3.99-0.16.1            
[127] parallel_4.3.2              MatrixModels_0.5-3         
[129] ellipsis_0.3.2              blob_1.2.4                 
[131] ggplot2_3.4.4               prettyunits_1.2.0          
[133] ggalluvial_0.12.5           profvis_0.3.8              
[135] urlchecker_1.0.1            bitops_1.0-7               
[137] viridisLite_0.4.2           scales_1.3.0               
[139] purrr_1.0.2                 crayon_1.5.2               
[141] rlang_1.1.3                 KEGGREST_1.42.0            
[143] cowplot_1.1.3               fastmatch_1.1-4 

@parkerstevenson
Copy link

Receiving the same error when trying to run projectR() on a sparse dgCMatrix.

Error in MatrixModels:::lm.fit.sparse(t(dataM[[2]]), dataM[[1]]) :
incompatible dimensions of (x,y)

@dimalvovs
Copy link
Collaborator Author

dimalvovs commented Jun 12, 2024

just pasting here in order not to forget

  • remove obsolete code and unused variables ie commented code and lines 95 111 112
  • refactor parameter checks (eg if(is.na()){... )will fail if something would be passed
  • implement sparse lm, e.g. SparseM
  • update bioconductor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants