abelson-lab / scATOMIC

Pan-Cancer Single Cell Classifier
MIT License
57 stars 5 forks source link

invalid class “Graph” object: superclass "mMatrix" not defined in the environment of the object's class #23

Closed zhoutianrui-tongji closed 6 months ago

zhoutianrui-tongji commented 6 months ago

Dear developer:

I follow the tutorial step by step, everything is normal before, know this step, it went wrong: results_scATOMIC <- create_summary_matrix(prediction_list = cell_predictions, raw_counts = allmat, mc.cores = 10)

Error reported as follows: Warning: The following features are not present in the object: MLF1IP, not searching for symbol synonyms Warning: The following features are not present in the object: FAM64A, HN1, not searching for symbol synonyms Regressing out S.Score, G2M.Score |=================================================================================================| 100% Centering and scaling data matrix |=================================================================================================| 100% Error in validObject(.Object) : invalid class “Graph” object: superclass "mMatrix" not defined in the environment of the object's class

Thank you very much for your attention!

inofechm commented 6 months ago

Hi thank you for your interest in our work.

I am not sure exactly what the issue is, it may be that the input is not a 'dgCMatrix' Could you please provide your sessionInfo() after loading all the libraries Can you also provide the output of class(allmat)? Can you let me know if you were able to run the tutorial data?

Hopefully this additional info can help me diagnose the bug or input issue.

Thanks, Ido

zhoutianrui-tongji commented 6 months ago

Thank u for your reply, I followed your instructions as follows : sessionInfo()

R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

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

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

other attached packages: [1] copykat_1.0.5 cutoff.scATOMIC_0.1.0 agrmt_1.42.12 SeuratObject_4.1.3
[5] Seurat_4.3.0.1 Rmagic_2.0.3 reticulate_1.30 caret_6.0-93
[9] lattice_0.20-45 ggplot2_3.4.2 randomForest_4.7-1.1 data.table_1.14.8
[13] dplyr_1.1.2 plyr_1.8.8 scATOMIC_2.0.1 sp_2.0-0
[17] Matrix_1.6-4

loaded via a namespace (and not attached): [1] Rtsne_0.16 colorspace_2.1-0 deldir_1.0-9 ellipsis_0.3.2
[5] class_7.3-19 ggridges_0.5.4 rprojroot_2.0.3 spatstat.data_3.0-1
[9] rstudioapi_0.14 leiden_0.4.3 listenv_0.9.0 ggrepel_0.9.3
[13] prodlim_2023.08.28 fansi_1.0.4 lubridate_1.9.3 codetools_0.2-18
[17] splines_4.1.2 extrafont_0.19 polyclip_1.10-4 jsonlite_1.8.5
[21] pROC_1.18.5 Rttf2pt1_1.3.12 ica_1.0-3 cluster_2.1.2
[25] png_0.1-8 uwot_0.1.14 spatstat.sparse_3.0-2 sctransform_0.3.5
[29] shiny_1.7.4 compiler_4.1.2 httr_1.4.6 lazyeval_0.2.2
[33] fastmap_1.1.1 cli_3.6.1 later_1.3.1 htmltools_0.5.5
[37] tools_4.1.2 igraph_1.5.0 gtable_0.3.3 glue_1.6.2
[41] RANN_2.6.1 reshape2_1.4.4 maps_3.4.1 rappdirs_0.3.3
[45] Rcpp_1.0.10 scattermore_1.2 vctrs_0.6.3 ggalt_0.4.0
[49] spatstat.explore_3.2-1 nlme_3.1-153 progressr_0.13.0 extrafontdb_1.0
[53] iterators_1.0.14 lmtest_0.9-40 spatstat.random_3.1-5 timeDate_4022.108
[57] gower_1.0.1 stringr_1.5.0 globals_0.16.2 timechange_0.2.0
[61] mime_0.12 miniUI_0.1.1.1 lifecycle_1.0.3 irlba_2.3.5.1
[65] goftest_1.2-3 future_1.32.0 MASS_7.3-54 zoo_1.8-12
[69] scales_1.2.1 ipred_0.9-14 spatstat.utils_3.0-3 promises_1.2.0.1
[73] proj4_1.0-13 RColorBrewer_1.1-3 gridExtra_2.3 pbapply_1.7-0
[77] rpart_4.1-15 stringi_1.7.12 foreach_1.5.2 hardhat_1.3.0
[81] lava_1.7.3 rlang_1.1.1 pkgconfig_2.0.3 matrixStats_1.0.0
[85] tensor_1.5 ROCR_1.0-11 purrr_1.0.1 htmlwidgets_1.6.2
[89] recipes_1.0.8 patchwork_1.1.2 cowplot_1.1.1 tidyselect_1.2.0
[93] here_1.0.1 parallelly_1.36.0 RcppAnnoy_0.0.20 magrittr_2.0.3
[97] R6_2.5.1 generics_0.1.3 pillar_1.9.0 withr_2.5.0
[101] fitdistrplus_1.1-11 abind_1.4-5 survival_3.2-13 nnet_7.3-16
[105] ash_1.0-15 tibble_3.2.1 future.apply_1.11.0 KernSmooth_2.23-20
[109] utf8_1.2.3 spatstat.geom_3.2-1 plotly_4.10.2 grid_4.1.2
[113] ModelMetrics_1.2.2.2 digest_0.6.31 xtable_1.8-4 tidyr_1.3.0
[117] httpuv_1.6.11 stats4_4.1.2 munsell_0.5.0 viridisLite_0.4.2

class(allmat) [1] "dgCMatrix" attr(,"package") [1] "Matrix"

Thanks again! : )

zhoutianrui-tongji commented 6 months ago

As a supplement, here's all my code:

#######scATOMIC#######
library(scATOMIC)
library(plyr)
library(dplyr)
library(data.table)
library(randomForest)
library(caret)
library(parallel)
library(reticulate)
library(Rmagic)
library(Matrix)
library(Seurat)
library(agrmt)
library(cutoff.scATOMIC)
library(copykat)
library(ggplot2)

Rmagic::pymagic_is_available()
install.magic()
pymagic_is_available()

pct_mt <- colSums(allmat[grep("^MT-", row.names(allmat)),])/colSums(allmat) * 100
nFeatureRNA <- colSums(allmat > 0)
allmat <- allmat[, names(which(pct_mt < 25))]
allmat <- allmat[, intersect(names(which(nFeatureRNA > 500)), colnames(allmat))]
# cell_predictions <- run_scATOMIC(allmat)
load("./cell_predictions.RData")
results_scATOMIC <- create_summary_matrix(prediction_list = cell_predictions, raw_counts = allmat, mc.cores = 10)

dim(allmat) [1] 37682 13078 colnames(allmat)[1:5] [1] "100052_all" "100067_all" "100083_all" "100126_all" "100143_all" row.names(allmat)[1:5] [1] "A2M" "AC005480.1" "AC025279.1" "AC104825.1" "ADH1B"

inofechm commented 6 months ago

Can you clarify whether you get the same error if you run on the tutorial dataset? I want to confirm whether this issue is with the input data or the R setup and a bug due to some package version incompatibilities.

These checks look pretty normal in terms of the input data.

I think it may be an issue with the version of the Matrix package and the version of Seurat (see the following discussion ). I would try reinstalling the Matrix package as described in the linked issue or upgrading Seurat to v5, you may also need to change the SeuratObject package.

Let me know if this fixes the issue.

zhoutianrui-tongji commented 6 months ago

I do this : remotes::install_version("Matrix", "1.6.1")

And it worked! I can't thank u more! : ) 👍