chuiqin / irGSEA

The integration of single cell rank-based gene set enrichment analysis
Other
106 stars 17 forks source link

how to use seurat v5+ bpcells with irGSEA #26

Closed Lucyyang1991 closed 8 months ago

Lucyyang1991 commented 8 months ago

我用的object是seurat v5+ bpcells做出来的,所以情况特殊,我已经将所有的数据转换成dgCMatrix了,但是依旧不可行。 代码如下:

library(irGSEA)
CD4 = JoinLayers(obj.sp.t.list$CD4)
CD4@assays$RNA$counts = as(object = CD4@assays$RNA$counts, Class = "dgCMatrix")
CD4@assays$RNA$data = as(object = CD4@assays$RNA$data, Class = "dgCMatrix")
CD4@assays$RNA$scale.data = as(object = CD4@assays$RNA$scale.data, Class = "dgCMatrix")
CD4 = irGSEA.score(object = CD4, species = "Mus musculus", assay = "RNA", slot = "data", method = "ssgsea")

报错如下:

Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc 'pca'
Updating matrix keys for DimReduc 'umap.unintegrated'
Updating matrix keys for DimReduc 'harmony'
Updating matrix keys for DimReduc 'umap.harmony'
Updating matrix keys for DimReduc 're.harmony'
Updating matrix keys for DimReduc 'umap.re.harmony'
Updating matrix keys for DimReduc 're2.harmony'
Updating matrix keys for DimReduc 'umap.re2.harmony'
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Updating slots in RNA_nn
Setting default assay of RNA_nn to RNA
Updating slots in RNA_snn
Setting default assay of RNA_snn to RNA
Updating slots in pca
Updating slots in umap.unintegrated
Setting umap.unintegrated DimReduc to global
Updating slots in harmony
Updating slots in umap.harmony
Setting umap.harmony DimReduc to global
Updating slots in re.harmony
Updating slots in umap.re.harmony
Setting umap.re.harmony DimReduc to global
Updating slots in re2.harmony
Updating slots in umap.re2.harmony
Setting umap.re2.harmony DimReduc to global
Setting assay used for RunUMAP.RNA.pca to RNA
Setting assay used for FindNeighbors.RNA.pca to RNA
Setting assay used for RunUMAP.RNA.harmony to RNA
Setting assay used for FindNeighbors.RNA.harmony to RNA
Setting assay used for RunUMAP.RNA.re.harmony to RNA
Setting assay used for FindNeighbors.RNA.re.harmony to RNA
Setting assay used for NormalizeData.RNA to RNA
Setting assay used for FindVariableFeatures.RNA to RNA
Setting assay used for ScaleData.RNA to RNA
Setting assay used for RunPCA.RNA to RNA
Setting assay used for RunUMAP.RNA.re2.harmony to RNA
Setting assay used for FindNeighbors.RNA.re2.harmony to RNA
No assay information could be found for FindClusters
Validating object structure for Assay5 'RNA'
Validating object structure for Graph 'RNA_nn'
Validating object structure for Graph 'RNA_snn'
Validating object structure for DimReduc 'pca'
Validating object structure for DimReduc 'umap.unintegrated'
Validating object structure for DimReduc 'harmony'
Validating object structure for DimReduc 'umap.harmony'
Validating object structure for DimReduc 're.harmony'
Validating object structure for DimReduc 'umap.re.harmony'
Validating object structure for DimReduc 're2.harmony'
Validating object structure for DimReduc 'umap.re2.harmony'
Object representation is consistent with the most current Seurat version
Error in validObject(.Object) : 
  invalid class "Assay" object: invalid object for slot "scale.data" in class "Assay": got class "dgCMatrix", should be or extend class "matrix"
In addition: Warning message:
Adding a command log without an assay associated with it 

sessioninfo如下:

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8  LC_CTYPE=Chinese (Simplified)_China.utf8    LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C                                LC_TIME=Chinese (Simplified)_China.utf8    

time zone: Asia/Shanghai
tzcode source: internal

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

other attached packages:
 [1] shinyBS_0.61.1              irGSEA_3.1.7                ComplexHeatmap_2.18.0       scRepertoire_1.12.0         BiocParallel_1.36.0        
 [6] SingleR_2.4.0               SummarizedExperiment_1.32.0 Biobase_2.62.0              GenomicRanges_1.54.1        GenomeInfoDb_1.38.1        
[11] IRanges_2.36.0              S4Vectors_0.40.2            BiocGenerics_0.48.1         MatrixGenerics_1.14.0       matrixStats_1.1.0          
[16] future_1.33.0               dplyr_1.1.4                 RColorBrewer_1.1-3          cowplot_1.1.1               patchwork_1.1.3            
[21] ggplot2_3.4.4               BPCells_0.1.0               SeuratWrappers_0.3.2        pbmcsca.SeuratData_3.0.0    pbmcref.SeuratData_1.0.0   
[26] ifnb.SeuratData_3.1.0       SeuratData_0.2.2.9001       Seurat_5.0.1                SeuratObject_5.0.1          sp_2.1-2                   

loaded via a namespace (and not attached):
  [1] R.methodsS3_1.8.2                 progress_1.2.3                    poweRlaw_0.70.6                   goftest_1.2-3                    
  [5] DT_0.31                           Biostrings_2.70.1                 vctrs_0.6.5                       spatstat.random_3.2-2            
  [9] digest_0.6.33                     png_0.1-8                         shape_1.4.6                       ggrepel_0.9.4                    
 [13] deldir_2.0-2                      parallelly_1.36.0                 permute_0.9-7                     MASS_7.3-60                      
 [17] Signac_1.12.0                     reshape2_1.4.4                    httpuv_1.6.13                     foreach_1.5.2                    
 [21] withr_2.5.2                       xfun_0.41                         ggpubr_0.6.0.999                  ellipsis_0.3.2                   
 [25] survival_3.5-7                    EnsDb.Hsapiens.v86_2.99.0         memoise_2.0.1                     gtools_3.9.5                     
 [29] zoo_1.8-12                        GlobalOptions_0.1.2               pbapply_1.7-2                     R.oo_1.25.0                      
 [33] prettyunits_1.2.0                 KEGGREST_1.42.0                   promises_1.2.1                    evmix_2.12                       
 [37] httr_1.4.7                        rstatix_0.7.2                     restfulr_0.0.15                   rhdf5filters_1.14.1              
 [41] globals_0.16.2                    fitdistrplus_1.1-11               rhdf5_2.46.1                      rstudioapi_0.15.0                
 [45] miniUI_0.1.1.1                    generics_0.1.3                    ggalluvial_0.12.5                 babelgene_22.9                   
 [49] curl_5.2.0                        zlibbioc_1.48.0                   ScaledMatrix_1.10.0               ggraph_2.1.0                     
 [53] polyclip_1.10-6                   GenomeInfoDbData_1.2.11           SparseArray_1.2.2                 pracma_2.4.4                     
 [57] xtable_1.8-4                      stringr_1.5.1                     doParallel_1.0.17                 evaluate_0.23                    
 [61] S4Arrays_1.2.0                    BiocFileCache_2.10.1              hms_1.1.3                         irlba_2.3.5.1                    
 [65] colorspace_2.1-0                  filelock_1.0.3                    hdf5r_1.3.8                       ROCR_1.0-11                      
 [69] reticulate_1.34.0                 spatstat.data_3.0-3               readr_2.1.4                       magrittr_2.0.3                   
 [73] lmtest_0.9-40                     later_1.3.2                       viridis_0.6.4                     lattice_0.22-5                   
 [77] spatstat.geom_3.2-7               future.apply_1.11.0               SparseM_1.81                      scattermore_1.2                  
 [81] XML_3.99-0.16                     RcppAnnoy_0.0.21                  pillar_1.9.0                      nlme_3.1-164                     
 [85] iterators_1.0.14                  caTools_1.18.2                    compiler_4.3.1                    beachmat_2.18.0                  
 [89] RSpectra_0.16-1                   stringi_1.8.2                     tensor_1.5                        GenomicAlignments_1.38.0         
 [93] plyr_1.8.9                        msigdbr_7.5.1                     crayon_1.5.2                      abind_1.4-5                      
 [97] BiocIO_1.12.0                     googledrive_2.1.1                 powerTCR_1.22.0                   graphlayouts_1.0.2               
[101] bit_4.0.5                         fastmatch_1.1-4                   codetools_0.2-19                  BiocSingular_1.18.0              
[105] GetoptLong_1.0.5                  plotly_4.10.3                     mime_0.12                         splines_4.3.1                    
[109] circlize_0.4.15                   Rcpp_1.0.11                       fastDummies_1.7.3                 dbplyr_2.4.0                     
[113] sparseMatrixStats_1.14.0          cellranger_1.1.0                  knitr_1.45                        blob_1.2.4                       
[117] utf8_1.2.4                        seqLogo_1.68.0                    clue_0.3-65                       AnnotationFilter_1.26.0          
[121] fs_1.6.3                          listenv_0.9.0                     evd_2.3-6.1                       DelayedMatrixStats_1.24.0        
[125] gsl_2.1-8                         ggsignif_0.6.4                    tibble_3.2.1                      Matrix_1.6-4                     
[129] tzdb_0.4.0                        tweenr_2.0.2                      pkgconfig_2.0.3                   tools_4.3.1                      
[133] cachem_1.0.8                      RSQLite_2.3.4                     viridisLite_0.4.2                 DBI_1.1.3                        
[137] fastmap_1.1.1                     rmarkdown_2.25                    scales_1.3.0                      ica_1.0-3                        
[141] shinydashboard_0.7.2              Rsamtools_2.18.0                  broom_1.0.5                       BiocManager_1.30.22              
[145] dotCall64_1.1-1                   carData_3.0-5                     RANN_2.6.1                        farver_2.1.1                     
[149] tidygraph_1.2.3                   mgcv_1.9-0                        yaml_2.3.7                        VGAM_1.1-9                       
[153] rtracklayer_1.62.0                cli_3.6.2                         purrr_1.0.2                       leiden_0.4.3.1                   
[157] lifecycle_1.0.4                   uwot_0.1.16                       presto_1.0.0                      backports_1.4.1                  
[161] BSgenome.Hsapiens.UCSC.hg38_1.4.5 annotate_1.80.0                   gtable_0.3.4                      rjson_0.2.21                     
[165] ggridges_0.5.4                    progressr_0.14.0                  cubature_2.1.0                    parallel_4.3.1                   
[169] jsonlite_1.8.8                    RcppHNSW_0.5.0                    TFBSTools_1.40.0                  bitops_1.0-7                     
[173] bit64_4.0.5                       Rtsne_0.17                        vegan_2.6-4                       spatstat.utils_3.0-4             
[177] CNEr_1.38.0                       shinyjs_2.1.0                     SeuratDisk_0.0.0.9021             R.utils_2.12.3                   
[181] truncdist_1.0-2                   lazyeval_0.2.2                    shiny_1.8.0                       Azimuth_0.5.0                    
[185] htmltools_0.5.7                   GO.db_3.18.0                      sctransform_0.4.1                 rappdirs_0.3.3                   
[189] ensembldb_2.26.0                  glue_1.6.2                        TFMPvalue_0.0.9                   googlesheets4_1.1.1              
[193] spam_2.10-0                       XVector_0.42.0                    RCurl_1.98-1.13                   BSgenome_1.70.1                  
[197] gridExtra_2.3                     JASPAR2020_0.99.10                igraph_1.5.1                      R6_2.5.1                         
[201] tidyr_1.3.0                       SingleCellExperiment_1.24.0       RcppRoll_0.3.0                    GenomicFeatures_1.54.1           
[205] cluster_2.1.6                     Rhdf5lib_1.24.0                   gargle_1.5.2                      stringdist_0.9.12                
[209] DirichletMultinomial_1.44.0       DelayedArray_0.28.0               tidyselect_1.2.0                  ProtGenerics_1.34.0              
[213] ggforce_0.4.1                     xml2_1.3.6                        car_3.1-2                         AnnotationDbi_1.64.1             
[217] rsvd_1.0.5                        munsell_0.5.0                     KernSmooth_2.23-22                data.table_1.14.10               
[221] htmlwidgets_1.6.4                 biomaRt_2.58.0                    rlang_1.1.2                       spatstat.sparse_3.0-3            
[225] spatstat.explore_3.2-5            remotes_2.4.2.1                   fansi_1.0.6                      
Lucyyang1991 commented 8 months ago

Dear all, I have found the solution. Here are the codes:

library(irGSEA)
CD4 = JoinLayers(obj.sp.t.list$CD4)
CD4@assays$RNA$data = as(object = CD4@assays$RNA$data, Class = "dgCMatrix")
CD4@assays$RNA$scale.data = as(object = CD4@assays$RNA$scale.data, Class = "matrix")
CD4 = irGSEA.score(object = CD4, species = "Mus musculus", assay = "RNA", slot = "data", method = "ssgsea")
result.deg = irGSEA.integrate(object = CD4, group.by = "harmony_re.clusters.0.2", method = "ssgsea")