Dragonmasterx87 / CompBio1-Tulane

https://dragonmasterx87.github.io/CompBio1-Tulane/
MIT License
2 stars 0 forks source link

STEP7 Merge objects #5

Closed Ksong11 closed 1 year ago

Ksong11 commented 1 year ago

When I try the merge script as shown bellow: STEP7 Merge objects Now we are merging the Seurat objects to create one unified Seurat object for downstream analysis.

pbmc <- merge(ifnb.list[["ctrl.d1"]], y = c(ifnb.list[["ctrl.d2"]], ifnb.list[["ctrl.d3"]], ifnb.list[["ctrl.d4"]],
                                            ifnb.list[["stim.d1"]], ifnb.list[["stim.d2"]], ifnb.list[["stim.d3"]], ifnb.list[["stim.d4"]]), 
              add.cell.ids = c("ctrl.d1", "ctrl.d2", "ctrl.d3", "ctrl.d4",
                               "stim.d1", "stim.d2", "stim.d3", "stim.d4"), project = "pbmc")

I got this:

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 328912, 265024, 333086, 377833, 373465, 368554, 378246

Please help to solve this issue. Thanks!

Dragonmasterx87 commented 1 year ago

Hi @Ksong11 !

Can you tell me what running ifnb.list gives?

Ksong11 commented 1 year ago
> Hi @Ksong11 !
> 
> Can you tell me what running `ifnb.list` gives?

I got this:

 ifnb.list <- list("ctrl.d1" = ctrl.d1, "ctrl.d2" = ctrl.d2, "ctrl.d3" = ctrl.d3, "ctrl.d4" = ctrl.d4,
+                   "stim.d1" = stim.d1, "stim.d2" = stim.d2, "stim.d3" = stim.d3, "stim.d4" = stim.d4)
Dragonmasterx87 commented 1 year ago

I mean when you just run ifnb.list I want to see what is in this object. There is a issue with this object it doesnt contain the data that is needed to complete the analysis. Thats why you are getting this error most likely!

Ksong11 commented 1 year ago

I mean when you just run ifnb.list I want to see what is in this object. There is a issue with this object it doesnt contain the data that is needed to complete the analysis. Thats why you are getting this error most likely!

image

Dragonmasterx87 commented 1 year ago

Okay so I see that the issue is. If you look carefully at the global environment (the top right box of Rstudio, where ctrl, ctrl.d1 etc is) you will see in case of ifnb.list, this object is made up of 8 dataframes, not seuratobjects. ifnb.list should be a list containing 8 seurat objects. This happens when you have not loaded Seurat on your computer and are attempting to create a list of objects. Also, I notice from your environment that the individual objects are dataframes, not seurat objects. Most likely you did not load Seurat at some point when the objects were being loaded/constructed so R doesn't know what they are and has coerced the data into S3-dataframe format. Can you give me an output when you run sessionInfo()? I am sure you will not see Seurat come up with attached base packages: or other attached packages:

When you run ifnb.list, this is what you should see:

> ifnb.list
$ctrl.d1
An object of class Seurat 
14053 features across 1658 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$ctrl.d2
An object of class Seurat 
14053 features across 1632 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$ctrl.d3
An object of class Seurat 
14053 features across 1598 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$ctrl.d4
An object of class Seurat 
14053 features across 1660 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d1
An object of class Seurat 
14053 features across 1896 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d2
An object of class Seurat 
14053 features across 1856 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d3
An object of class Seurat 
14053 features across 1809 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d4
An object of class Seurat 
14053 features across 1890 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)
Dragonmasterx87 commented 1 year ago

The solution to this would be as follows:

  1. restart R (save your script somewhere before so you dont have to type in all your commands again)
  2. Load Seurat via library(Seurat)
  3. Run the script, to create a ifnb.list object

Since you already have the components of ifnb.list in the data folder, what you need to do is just load all of the objects using the following (adjust to meet your file path):

# How to load files if you are using RDS
{
  ctrl.d1 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\ctrl.d1.rds)")
  ctrl.d2 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\ctrl.d2.rds)")
  ctrl.d3 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\ctrl.d3.rds)")
  ctrl.d4 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\ctrl.d4.rds)")

  stim.d1 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\stim.d1.rds)")
  stim.d2 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\stim.d2.rds)")
  stim.d3 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\stim.d3.rds)")
  stim.d4 <- readRDS(r"(C:\Users\mqadir\Box\Courses-Workshops\CompBioW1\Fahd_shared_with_participants\data\stim.d4.rds)")
}

Then the next thing is to add metadata:

ctrl.d1$donor <- "d1"
ctrl.d2$donor <- "d2"
ctrl.d3$donor <- "d3"
ctrl.d4$donor <- "d4"

stim.d1$donor <- "d1"
stim.d2$donor <- "d2"
stim.d3$donor <- "d3"
stim.d4$donor <- "d4"

Finally, create a ifnb.list object:

ifnb.list <- list("ctrl.d1" = ctrl.d1, "ctrl.d2" = ctrl.d2, "ctrl.d3" = ctrl.d3, "ctrl.d4" = ctrl.d4,
                  "stim.d1" = stim.d1, "stim.d2" = stim.d2, "stim.d3" = stim.d3, "stim.d4" = stim.d4)

Now when we run the following: > ifnb.list

You will get:

$ctrl.d1
An object of class Seurat 
14053 features across 1658 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$ctrl.d2
An object of class Seurat 
14053 features across 1632 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$ctrl.d3
An object of class Seurat 
14053 features across 1598 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$ctrl.d4
An object of class Seurat 
14053 features across 1660 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d1
An object of class Seurat 
14053 features across 1896 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d2
An object of class Seurat 
14053 features across 1856 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d3
An object of class Seurat 
14053 features across 1809 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

$stim.d4
An object of class Seurat 
14053 features across 1890 samples within 1 assay 
Active assay: RNA (14053 features, 0 variable features)

Notice how each component of the ifnb.list object is infact coming up as "class Seurat" meaning it is a Seurat object not a "S3 dataframe", which is what it is showing up right now based on the picture you have added.

Dragonmasterx87 commented 1 year ago

Sorry I closed the issue by mistake, I re-opened, so that we can continue to troubleshoot till it is resolved. Let me know if its solved if not let me know the error. Thanks!

Ksong11 commented 1 year ago

Sorry I closed the issue by mistake, I re-opened, so that we can continue to troubleshoot till it is resolved. Let me know if its solved if not let me know the error. Thanks!

Here is what I got by doing > sessionInfo(). I will follow your instruction and restart the R.

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] ggplot2_3.4.3         qs_0.25.5            
 [3] ifnb.SeuratData_3.1.0 SeuratData_0.2.1     
 [5] patchwork_1.1.3       Seurat_4.3.0         
 [7] harmony_0.1.1         Rcpp_1.0.11          
 [9] dplyr_1.1.2           SeuratObject_4.1.3   
[11] sp_2.0-0             

loaded via a namespace (and not attached):
  [1] deldir_1.0-9           pbapply_1.7-2         
  [3] gridExtra_2.3          rlang_1.1.1           
  [5] magrittr_2.0.3         RcppAnnoy_0.0.21      
  [7] matrixStats_1.0.0      ggridges_0.5.4        
  [9] compiler_4.3.1         spatstat.geom_3.2-4   
 [11] png_0.1-8              vctrs_0.6.3           
 [13] reshape2_1.4.4         stringr_1.5.0         
 [15] crayon_1.5.2           pkgconfig_2.0.3       
 [17] fastmap_1.1.1          ellipsis_0.3.2        
 [19] utf8_1.2.3             promises_1.2.0.1      
 [21] purrr_1.0.1            jsonlite_1.8.7        
 [23] goftest_1.2-3          later_1.3.1           
 [25] spatstat.utils_3.0-3   irlba_2.3.5.1         
 [27] parallel_4.3.1         cluster_2.1.4         
 [29] R6_2.5.1               ica_1.0-3             
 [31] stringi_1.7.12         RColorBrewer_1.1-3    
 [33] spatstat.data_3.0-1    reticulate_1.31       
 [35] parallelly_1.36.0      lmtest_0.9-40         
 [37] scattermore_1.2        tensor_1.5            
 [39] future.apply_1.11.0    zoo_1.8-12            
 [41] sctransform_0.3.5      httpuv_1.6.11         
 [43] Matrix_1.6-0           splines_4.3.1         
 [45] igraph_1.5.1           tidyselect_1.2.0      
 [47] rstudioapi_0.15.0      abind_1.4-5           
 [49] stringfish_0.15.8      spatstat.random_3.1-5 
 [51] codetools_0.2-19       miniUI_0.1.1.1        
 [53] spatstat.explore_3.2-1 listenv_0.9.0         
 [55] lattice_0.21-8         tibble_3.2.1          
 [57] plyr_1.8.8             withr_2.5.0           
 [59] shiny_1.7.5            ROCR_1.0-11           
 [61] Rtsne_0.16             future_1.33.0         
 [63] survival_3.5-5         RcppParallel_5.1.7    
 [65] polyclip_1.10-4        fitdistrplus_1.1-11   
 [67] pillar_1.9.0           KernSmooth_2.23-22    
 [69] plotly_4.10.2          generics_0.1.3        
 [71] munsell_0.5.0          scales_1.2.1          
 [73] RApiSerialize_0.1.2    globals_0.16.2        
 [75] xtable_1.8-4           glue_1.6.2            
 [77] lazyeval_0.2.2         tools_4.3.1           
 [79] data.table_1.14.8      RANN_2.6.1            
 [81] leiden_0.4.3           cowplot_1.1.1         
 [83] grid_4.3.1             tidyr_1.3.0           
 [85] colorspace_2.1-0       nlme_3.1-163          
 [87] cli_3.6.1              rappdirs_0.3.3        
 [89] spatstat.sparse_3.0-2  fansi_1.0.4           
 [91] viridisLite_0.4.2      uwot_0.1.16           
 [93] gtable_0.3.3           digest_0.6.33         
 [95] progressr_0.14.0       ggrepel_0.9.3         
 [97] htmlwidgets_1.6.2      htmltools_0.5.5       
 [99] lifecycle_1.0.3        httr_1.4.7            
[101] mime_0.12              MASS_7.3-60  
Dragonmasterx87 commented 1 year ago

Thanks! So as you can see we cant see Seurat anywhere. Either in the "attached base packages:", "other attached packages:" or in the "loaded via a namespace (and not attached):" headers. This means that Seurat is not loaded into your current Rstudio environment. In order for Seurat to be loaded, you need to run library(Seurat) every time you open a new Rstudio session. You only need to install it once, but loading needs to be performed every time you open a new R/Rstudio session. See in my current R session you can see Seurat shows up (see line number [67] 2nd column in "other attached packages:" heading):

>sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] BiocParallel_1.34.1               cicero_1.3.9                      Gviz_1.44.0                      
 [4] SeuratWrappers_0.3.1              chromVAR_1.22.1                   motifmatchr_1.22.0               
 [7] BSgenome.Hsapiens.UCSC.hg38_1.4.5 BSgenome_1.68.0                   rtracklayer_1.60.0               
[10] Biostrings_2.68.1                 XVector_0.40.0                    TFBSTools_1.38.0                 
[13] JASPAR2020_0.99.10                qs_0.25.5                         R.utils_2.12.2                   
[16] R.oo_1.25.0                       R.methodsS3_1.8.2                 devtools_2.4.5                   
[19] usethis_2.1.6                     ggVennDiagram_1.2.2               ggvenn_0.1.10                    
[22] DropletUtils_1.20.0               Nebulosa_1.10.0                   scCustomize_1.1.1                
[25] circlize_0.4.15                   ComplexHeatmap_2.16.0             viridis_0.6.3                    
[28] viridisLite_0.4.2                 EnrichmentBrowser_2.30.1          graph_1.78.0                     
[31] escape_1.10.0                     dittoSeq_1.12.0                   DOSE_3.26.1                      
[34] clusterProfiler_4.8.1             MeSHDbi_1.36.0                    AnnotationHub_3.8.0              
[37] BiocFileCache_2.8.0               dbplyr_2.3.2                      org.Hs.eg.db_3.17.0              
[40] GOSemSim_2.26.0                   glmGamPoi_1.12.1                  EnhancedVolcano_1.18.0           
[43] DoubletFinder_2.0.3               patchwork_1.1.2                   clustree_0.5.0                   
[46] ggraph_2.1.0                      plotly_4.10.1                     EnsDb.Hsapiens.v86_2.99.0        
[49] ensembldb_2.24.0                  AnnotationFilter_1.24.0           GenomicFeatures_1.52.0           
[52] AnnotationDbi_1.62.1              scDblFinder_1.14.0                Signac_1.9.0                     
[55] harmony_0.1.1                     monocle3_1.3.1                    SingleCellExperiment_1.22.0      
[58] SummarizedExperiment_1.30.1       GenomicRanges_1.52.0              GenomeInfoDb_1.36.0              
[61] IRanges_2.34.0                    S4Vectors_0.38.1                  MatrixGenerics_1.12.0            
[64] matrixStats_0.63.0                Biobase_2.60.0                    BiocGenerics_0.46.0              
[67] SeuratObject_4.1.3                Seurat_4.3.0.9002                 reticulate_1.28                  
[70] data.table_1.14.8                 lubridate_1.9.2                   forcats_1.0.0                    
[73] purrr_1.0.1                       readr_2.1.4                       tidyr_1.3.0                      
[76] tibble_3.2.1                      tidyverse_2.0.0                   dplyr_1.1.2                      
[79] ggridges_0.5.4                    Matrix_1.5-4                      cowplot_1.1.1                    
[82] Rcpp_1.0.10                       SoupX_1.6.2                       hdf5r_1.3.8                      
[85] stringr_1.5.0                     leiden_0.4.3                      ggrepel_0.9.3                    
[88] ggplot2_3.4.2                    

loaded via a namespace (and not attached):
  [1] igraph_1.4.2                  Formula_1.2-5                 ica_1.0-3                    
  [4] rematch2_2.1.2                scater_1.28.0                 zlibbioc_1.46.0              
  [7] tidyselect_1.2.0              bit_4.0.5                     doParallel_1.0.17            
 [10] clue_0.3-64                   lattice_0.21-8                rjson_0.2.21                 
 [13] blob_1.2.4                    urlchecker_1.0.1              S4Arrays_1.0.4               
 [16] dichromat_2.0-0.1             parallel_4.3.0                seqLogo_1.66.0               
 [19] png_0.1-8                     cli_3.6.1                     ggplotify_0.1.0              
 [22] ProtGenerics_1.32.0           goftest_1.2-3                 BiocIO_1.10.0                
 [25] bluster_1.10.0                BiocNeighbors_1.18.0          uwot_0.1.14                  
 [28] shadowtext_0.1.2              curl_5.0.0                    evaluate_0.21                
 [31] mime_0.12                     tidytree_0.4.2                stringi_1.7.12               
 [34] backports_1.4.1               XML_3.99-0.14                 httpuv_1.6.11                
 [37] paletteer_1.5.0               magrittr_2.0.3                rappdirs_0.3.3               
 [40] splines_4.3.0                 mclust_6.0.0                  RcppRoll_0.3.0               
 [43] RApiSerialize_0.1.2           jpeg_0.1-10                   DT_0.28                      
 [46] sctransform_0.3.5.9002        ggbeeswarm_0.7.2              sessioninfo_1.2.2            
 [49] DBI_1.1.3                     terra_1.7-29                  HDF5Array_1.28.1             
 [52] withr_2.5.0                   rprojroot_2.0.3               enrichplot_1.20.0            
 [55] xgboost_1.7.5.1               lmtest_0.9-40                 GSEABase_1.62.0              
 [58] tidygraph_1.2.3               BiocManager_1.30.20           htmlwidgets_1.6.2            
 [61] fs_1.6.2                      biomaRt_2.56.0                annotate_1.78.0              
 [64] VariantAnnotation_1.46.0      zoo_1.8-12                    knitr_1.42                   
 [67] TFMPvalue_0.0.9               timechange_0.2.0              foreach_1.5.2                
 [70] fansi_1.0.4                   caTools_1.18.2                ggtree_3.8.0                 
 [73] rhdf5_2.44.0                  poweRlaw_0.70.6               irlba_2.3.5.1                
 [76] ggrastr_1.0.1                 gridGraphics_0.5-1            ellipsis_0.3.2               
 [79] lazyeval_0.2.2                yaml_2.3.7                    survival_3.5-5               
 [82] scattermore_1.1               BiocVersion_3.17.1            crayon_1.5.2                 
 [85] RcppAnnoy_0.0.20              RColorBrewer_1.1-3            progressr_0.13.0             
 [88] tweenr_2.0.2                  later_1.3.1                   Rgraphviz_2.44.0             
 [91] base64enc_0.1-3               codetools_0.2-19              GlobalOptions_0.1.2          
 [94] profvis_0.3.8                 KEGGREST_1.40.0               Rtsne_0.16                   
 [97] shape_1.4.6                   limma_3.56.1                  Rsamtools_2.16.0             
[100] filelock_1.0.2                foreign_0.8-84                pkgconfig_2.0.3              
[103] KEGGgraph_1.60.0              xml2_1.3.4                    GenomicAlignments_1.36.0     
[106] aplot_0.1.10                  biovizBase_1.48.0             spatstat.sparse_3.0-1        
[109] ape_5.7-1                     xtable_1.8-4                  interp_1.1-4                 
[112] plyr_1.8.8                    httr_1.4.6                    tools_4.3.0                  
[115] globals_0.16.2                pkgbuild_1.4.0                checkmate_2.2.0              
[118] htmlTable_2.4.1               beeswarm_0.4.0                broom_1.0.4                  
[121] nlme_3.1-162                  HDO.db_0.99.1                 lme4_1.1-33                  
[124] digest_0.6.31                 farver_2.1.1                  tzdb_0.4.0                   
[127] reshape2_1.4.4                ks_1.14.0                     yulab.utils_0.0.6            
[130] rpart_4.1.19                  DirichletMultinomial_1.42.0   glue_1.6.2                   
[133] cachem_1.0.8                  polyclip_1.10-4               Hmisc_5.1-0                  
[136] generics_0.1.3                mvtnorm_1.1-3                 parallelly_1.35.0            
[139] pkgload_1.3.2                 statmod_1.5.0                 here_1.0.1                   
[142] ScaledMatrix_1.8.1            minqa_1.2.5                   pbapply_1.7-0                
[145] gson_0.1.0                    dqrng_0.3.0                   utf8_1.2.3                   
[148] gtools_3.9.4                  graphlayouts_1.0.0            gridExtra_2.3                
[151] shiny_1.7.4                   GSVA_1.48.0                   GenomeInfoDbData_1.2.10      
[154] rhdf5filters_1.12.1           RCurl_1.98-1.12               memoise_2.0.1                
[157] rmarkdown_2.21                pheatmap_1.0.12               downloader_0.4               
[160] scales_1.2.1                  future_1.32.0                 RANN_2.6.1                   
[163] stringfish_0.15.7             spatstat.data_3.0-1           rstudioapi_0.14              
[166] cluster_2.1.4                 msigdbr_7.5.1                 janitor_2.2.0                
[169] spatstat.utils_3.0-3          hms_1.1.3                     fitdistrplus_1.1-11          
[172] munsell_0.5.0                 colorspace_2.1-0              rlang_1.1.1                  
[175] DelayedMatrixStats_1.22.0     sparseMatrixStats_1.12.0      ggforce_0.4.1                
[178] scuttle_1.10.1                xfun_0.39                     RVenn_1.1.0                  
[181] CNEr_1.36.0                   remotes_2.4.2                 iterators_1.0.14             
[184] abind_1.4-5                   interactiveDisplayBase_1.38.0 treeio_1.24.0                
[187] Rhdf5lib_1.22.0               bitops_1.0-7                  ps_1.7.5                     
[190] promises_1.2.0.1              scatterpie_0.2.0              RSQLite_2.3.1                
[193] qvalue_2.32.0                 fgsea_1.26.0                  DelayedArray_0.26.2          
[196] GO.db_3.17.0                  compiler_4.3.0                prettyunits_1.1.1            
[199] boot_1.3-28.1                 beachmat_2.16.0               listenv_0.9.0                
[202] edgeR_3.42.2                  BiocSingular_1.16.0           tensor_1.5                   
[205] MASS_7.3-60                   progress_1.2.2                UCell_2.4.0                  
[208] babelgene_22.9                spatstat.random_3.1-5         R6_2.5.1                     
[211] fastmap_1.1.1                 fastmatch_1.1-3               vipor_0.4.5                  
[214] ROCR_1.0-11                   nnet_7.3-19                   rsvd_1.0.5                   
[217] gtable_0.3.3                  KernSmooth_2.23-21            latticeExtra_0.6-30          
[220] miniUI_0.1.1.1                deldir_1.0-9                  htmltools_0.5.5              
[223] RcppParallel_5.1.7            bit64_4.0.5                   spatstat.explore_3.2-1       
[226] lifecycle_1.0.3               ggprism_1.0.4                 processx_3.8.1               
[229] nloptr_2.0.3                  callr_3.7.3                   restfulr_0.0.15              
[232] vctrs_0.6.2                   VGAM_1.1-8                    spatstat.geom_3.2-1          
[235] snakecase_0.11.0              scran_1.28.1                  ggfun_0.0.9                  
[238] sp_1.6-0                      pracma_2.4.2                  future.apply_1.11.0          
[241] pillar_1.9.0                  metapod_1.8.0                 locfit_1.5-9.7               
[244] jsonlite_1.8.4                GetoptLong_1.0.5

So basically you need to load Seurat. Once Seurat is loaded and when you run the commands everything should work. Let me know either way.

Ksong11 commented 1 year ago

Thanks! So as you can see we cant see Seurat anywhere. Either in the "attached base packages:", "other attached packages:" or in the "loaded via a namespace (and not attached):" headers. This means that Seurat is not loaded into your current Rstudio environment. In order for Seurat to be loaded, you need to run library(Seurat) every time you open a new Rstudio session. You only need to install it once, but loading needs to be performed every time you open a new R/Rstudio session. See in my current R session you can see Seurat shows up (see line number [67] 2nd column in "other attached packages:" heading):

>sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] BiocParallel_1.34.1               cicero_1.3.9                      Gviz_1.44.0                      
 [4] SeuratWrappers_0.3.1              chromVAR_1.22.1                   motifmatchr_1.22.0               
 [7] BSgenome.Hsapiens.UCSC.hg38_1.4.5 BSgenome_1.68.0                   rtracklayer_1.60.0               
[10] Biostrings_2.68.1                 XVector_0.40.0                    TFBSTools_1.38.0                 
[13] JASPAR2020_0.99.10                qs_0.25.5                         R.utils_2.12.2                   
[16] R.oo_1.25.0                       R.methodsS3_1.8.2                 devtools_2.4.5                   
[19] usethis_2.1.6                     ggVennDiagram_1.2.2               ggvenn_0.1.10                    
[22] DropletUtils_1.20.0               Nebulosa_1.10.0                   scCustomize_1.1.1                
[25] circlize_0.4.15                   ComplexHeatmap_2.16.0             viridis_0.6.3                    
[28] viridisLite_0.4.2                 EnrichmentBrowser_2.30.1          graph_1.78.0                     
[31] escape_1.10.0                     dittoSeq_1.12.0                   DOSE_3.26.1                      
[34] clusterProfiler_4.8.1             MeSHDbi_1.36.0                    AnnotationHub_3.8.0              
[37] BiocFileCache_2.8.0               dbplyr_2.3.2                      org.Hs.eg.db_3.17.0              
[40] GOSemSim_2.26.0                   glmGamPoi_1.12.1                  EnhancedVolcano_1.18.0           
[43] DoubletFinder_2.0.3               patchwork_1.1.2                   clustree_0.5.0                   
[46] ggraph_2.1.0                      plotly_4.10.1                     EnsDb.Hsapiens.v86_2.99.0        
[49] ensembldb_2.24.0                  AnnotationFilter_1.24.0           GenomicFeatures_1.52.0           
[52] AnnotationDbi_1.62.1              scDblFinder_1.14.0                Signac_1.9.0                     
[55] harmony_0.1.1                     monocle3_1.3.1                    SingleCellExperiment_1.22.0      
[58] SummarizedExperiment_1.30.1       GenomicRanges_1.52.0              GenomeInfoDb_1.36.0              
[61] IRanges_2.34.0                    S4Vectors_0.38.1                  MatrixGenerics_1.12.0            
[64] matrixStats_0.63.0                Biobase_2.60.0                    BiocGenerics_0.46.0              
[67] SeuratObject_4.1.3                Seurat_4.3.0.9002                 reticulate_1.28                  
[70] data.table_1.14.8                 lubridate_1.9.2                   forcats_1.0.0                    
[73] purrr_1.0.1                       readr_2.1.4                       tidyr_1.3.0                      
[76] tibble_3.2.1                      tidyverse_2.0.0                   dplyr_1.1.2                      
[79] ggridges_0.5.4                    Matrix_1.5-4                      cowplot_1.1.1                    
[82] Rcpp_1.0.10                       SoupX_1.6.2                       hdf5r_1.3.8                      
[85] stringr_1.5.0                     leiden_0.4.3                      ggrepel_0.9.3                    
[88] ggplot2_3.4.2                    

loaded via a namespace (and not attached):
  [1] igraph_1.4.2                  Formula_1.2-5                 ica_1.0-3                    
  [4] rematch2_2.1.2                scater_1.28.0                 zlibbioc_1.46.0              
  [7] tidyselect_1.2.0              bit_4.0.5                     doParallel_1.0.17            
 [10] clue_0.3-64                   lattice_0.21-8                rjson_0.2.21                 
 [13] blob_1.2.4                    urlchecker_1.0.1              S4Arrays_1.0.4               
 [16] dichromat_2.0-0.1             parallel_4.3.0                seqLogo_1.66.0               
 [19] png_0.1-8                     cli_3.6.1                     ggplotify_0.1.0              
 [22] ProtGenerics_1.32.0           goftest_1.2-3                 BiocIO_1.10.0                
 [25] bluster_1.10.0                BiocNeighbors_1.18.0          uwot_0.1.14                  
 [28] shadowtext_0.1.2              curl_5.0.0                    evaluate_0.21                
 [31] mime_0.12                     tidytree_0.4.2                stringi_1.7.12               
 [34] backports_1.4.1               XML_3.99-0.14                 httpuv_1.6.11                
 [37] paletteer_1.5.0               magrittr_2.0.3                rappdirs_0.3.3               
 [40] splines_4.3.0                 mclust_6.0.0                  RcppRoll_0.3.0               
 [43] RApiSerialize_0.1.2           jpeg_0.1-10                   DT_0.28                      
 [46] sctransform_0.3.5.9002        ggbeeswarm_0.7.2              sessioninfo_1.2.2            
 [49] DBI_1.1.3                     terra_1.7-29                  HDF5Array_1.28.1             
 [52] withr_2.5.0                   rprojroot_2.0.3               enrichplot_1.20.0            
 [55] xgboost_1.7.5.1               lmtest_0.9-40                 GSEABase_1.62.0              
 [58] tidygraph_1.2.3               BiocManager_1.30.20           htmlwidgets_1.6.2            
 [61] fs_1.6.2                      biomaRt_2.56.0                annotate_1.78.0              
 [64] VariantAnnotation_1.46.0      zoo_1.8-12                    knitr_1.42                   
 [67] TFMPvalue_0.0.9               timechange_0.2.0              foreach_1.5.2                
 [70] fansi_1.0.4                   caTools_1.18.2                ggtree_3.8.0                 
 [73] rhdf5_2.44.0                  poweRlaw_0.70.6               irlba_2.3.5.1                
 [76] ggrastr_1.0.1                 gridGraphics_0.5-1            ellipsis_0.3.2               
 [79] lazyeval_0.2.2                yaml_2.3.7                    survival_3.5-5               
 [82] scattermore_1.1               BiocVersion_3.17.1            crayon_1.5.2                 
 [85] RcppAnnoy_0.0.20              RColorBrewer_1.1-3            progressr_0.13.0             
 [88] tweenr_2.0.2                  later_1.3.1                   Rgraphviz_2.44.0             
 [91] base64enc_0.1-3               codetools_0.2-19              GlobalOptions_0.1.2          
 [94] profvis_0.3.8                 KEGGREST_1.40.0               Rtsne_0.16                   
 [97] shape_1.4.6                   limma_3.56.1                  Rsamtools_2.16.0             
[100] filelock_1.0.2                foreign_0.8-84                pkgconfig_2.0.3              
[103] KEGGgraph_1.60.0              xml2_1.3.4                    GenomicAlignments_1.36.0     
[106] aplot_0.1.10                  biovizBase_1.48.0             spatstat.sparse_3.0-1        
[109] ape_5.7-1                     xtable_1.8-4                  interp_1.1-4                 
[112] plyr_1.8.8                    httr_1.4.6                    tools_4.3.0                  
[115] globals_0.16.2                pkgbuild_1.4.0                checkmate_2.2.0              
[118] htmlTable_2.4.1               beeswarm_0.4.0                broom_1.0.4                  
[121] nlme_3.1-162                  HDO.db_0.99.1                 lme4_1.1-33                  
[124] digest_0.6.31                 farver_2.1.1                  tzdb_0.4.0                   
[127] reshape2_1.4.4                ks_1.14.0                     yulab.utils_0.0.6            
[130] rpart_4.1.19                  DirichletMultinomial_1.42.0   glue_1.6.2                   
[133] cachem_1.0.8                  polyclip_1.10-4               Hmisc_5.1-0                  
[136] generics_0.1.3                mvtnorm_1.1-3                 parallelly_1.35.0            
[139] pkgload_1.3.2                 statmod_1.5.0                 here_1.0.1                   
[142] ScaledMatrix_1.8.1            minqa_1.2.5                   pbapply_1.7-0                
[145] gson_0.1.0                    dqrng_0.3.0                   utf8_1.2.3                   
[148] gtools_3.9.4                  graphlayouts_1.0.0            gridExtra_2.3                
[151] shiny_1.7.4                   GSVA_1.48.0                   GenomeInfoDbData_1.2.10      
[154] rhdf5filters_1.12.1           RCurl_1.98-1.12               memoise_2.0.1                
[157] rmarkdown_2.21                pheatmap_1.0.12               downloader_0.4               
[160] scales_1.2.1                  future_1.32.0                 RANN_2.6.1                   
[163] stringfish_0.15.7             spatstat.data_3.0-1           rstudioapi_0.14              
[166] cluster_2.1.4                 msigdbr_7.5.1                 janitor_2.2.0                
[169] spatstat.utils_3.0-3          hms_1.1.3                     fitdistrplus_1.1-11          
[172] munsell_0.5.0                 colorspace_2.1-0              rlang_1.1.1                  
[175] DelayedMatrixStats_1.22.0     sparseMatrixStats_1.12.0      ggforce_0.4.1                
[178] scuttle_1.10.1                xfun_0.39                     RVenn_1.1.0                  
[181] CNEr_1.36.0                   remotes_2.4.2                 iterators_1.0.14             
[184] abind_1.4-5                   interactiveDisplayBase_1.38.0 treeio_1.24.0                
[187] Rhdf5lib_1.22.0               bitops_1.0-7                  ps_1.7.5                     
[190] promises_1.2.0.1              scatterpie_0.2.0              RSQLite_2.3.1                
[193] qvalue_2.32.0                 fgsea_1.26.0                  DelayedArray_0.26.2          
[196] GO.db_3.17.0                  compiler_4.3.0                prettyunits_1.1.1            
[199] boot_1.3-28.1                 beachmat_2.16.0               listenv_0.9.0                
[202] edgeR_3.42.2                  BiocSingular_1.16.0           tensor_1.5                   
[205] MASS_7.3-60                   progress_1.2.2                UCell_2.4.0                  
[208] babelgene_22.9                spatstat.random_3.1-5         R6_2.5.1                     
[211] fastmap_1.1.1                 fastmatch_1.1-3               vipor_0.4.5                  
[214] ROCR_1.0-11                   nnet_7.3-19                   rsvd_1.0.5                   
[217] gtable_0.3.3                  KernSmooth_2.23-21            latticeExtra_0.6-30          
[220] miniUI_0.1.1.1                deldir_1.0-9                  htmltools_0.5.5              
[223] RcppParallel_5.1.7            bit64_4.0.5                   spatstat.explore_3.2-1       
[226] lifecycle_1.0.3               ggprism_1.0.4                 processx_3.8.1               
[229] nloptr_2.0.3                  callr_3.7.3                   restfulr_0.0.15              
[232] vctrs_0.6.2                   VGAM_1.1-8                    spatstat.geom_3.2-1          
[235] snakecase_0.11.0              scran_1.28.1                  ggfun_0.0.9                  
[238] sp_1.6-0                      pracma_2.4.2                  future.apply_1.11.0          
[241] pillar_1.9.0                  metapod_1.8.0                 locfit_1.5-9.7               
[244] jsonlite_1.8.4                GetoptLong_1.0.5

So basically you need to load Seurat. Once Seurat is loaded and when you run the commands everything should work. Let me know either way.

Sorry, I can see the Seurat_4.3.0 from the other attached packages:

other attached packages:
 [1] ggplot2_3.4.3         qs_0.25.5            
 [3] ifnb.SeuratData_3.1.0 SeuratData_0.2.1     
 [5] patchwork_1.1.3       Seurat_4.3.0         
 [7] harmony_0.1.1         Rcpp_1.0.11          
 [9] dplyr_1.1.2           SeuratObject_4.1.3   
[11] sp_2.0-0             

loaded via a namespace (and not attached):
  [1] deldir_1.0-9           pbapply_1.7-2         
  [3] gridExtra_2.3          rlang_1.1.1           
  [5] magrittr_2.0.3         RcppAnnoy_0.0.21      
  [7] matrixStats_1.0.0      ggridges_0.5.4        
  [9] compiler_4.3.1         spatstat.geom_3.2-4   
 [11] png_0.1-8              vctrs_0.6.3           
 [13] reshape2_1.4.4         stringr_1.5.0         
 [15] crayon_1.5.2           pkgconfig_2.0.3       
 [17] fastmap_1.1.1          ellipsis_0.3.2        
 [19] utf8_1.2.3             promises_1.2.0.1      
 [21] purrr_1.0.1            jsonlite_1.8.7        
 [23] goftest_1.2-3          later_1.3.1           
 [25] spatstat.utils_3.0-3   irlba_2.3.5.1         
 [27] parallel_4.3.1         cluster_2.1.4         
 [29] R6_2.5.1               ica_1.0-3             
 [31] stringi_1.7.12         RColorBrewer_1.1-3    
 [33] spatstat.data_3.0-1    reticulate_1.31       
 [35] parallelly_1.36.0      lmtest_0.9-40         
 [37] scattermore_1.2        tensor_1.5            
 [39] future.apply_1.11.0    zoo_1.8-12            
 [41] sctransform_0.3.5      httpuv_1.6.11         
 [43] Matrix_1.6-0           splines_4.3.1         
 [45] igraph_1.5.1           tidyselect_1.2.0      
 [47] rstudioapi_0.15.0      abind_1.4-5           
 [49] stringfish_0.15.8      spatstat.random_3.1-5 
 [51] codetools_0.2-19       miniUI_0.1.1.1        
 [53] spatstat.explore_3.2-1 listenv_0.9.0         
 [55] lattice_0.21-8         tibble_3.2.1          
 [57] plyr_1.8.8             withr_2.5.0           
 [59] shiny_1.7.5            ROCR_1.0-11           
 [61] Rtsne_0.16             future_1.33.0         
 [63] survival_3.5-5         RcppParallel_5.1.7    
 [65] polyclip_1.10-4        fitdistrplus_1.1-11   
 [67] pillar_1.9.0           KernSmooth_2.23-22    
 [69] plotly_4.10.2          generics_0.1.3        
 [71] munsell_0.5.0          scales_1.2.1          
 [73] RApiSerialize_0.1.2    globals_0.16.2        
 [75] xtable_1.8-4           glue_1.6.2            
 [77] lazyeval_0.2.2         tools_4.3.1           
 [79] data.table_1.14.8      RANN_2.6.1            
 [81] leiden_0.4.3           cowplot_1.1.1         
 [83] grid_4.3.1             tidyr_1.3.0           
 [85] colorspace_2.1-0       nlme_3.1-163          
 [87] cli_3.6.1              rappdirs_0.3.3        
 [89] spatstat.sparse_3.0-2  fansi_1.0.4           
 [91] viridisLite_0.4.2      uwot_0.1.16           
 [93] gtable_0.3.3           digest_0.6.33         
 [95] progressr_0.14.0       ggrepel_0.9.3         
 [97] htmlwidgets_1.6.2      htmltools_0.5.5       
 [99] lifecycle_1.0.3        httr_1.4.7            
[101] mime_0.12              MASS_7.3-60  
Dragonmasterx87 commented 1 year ago

Yes, we can see Seurat loaded in my environment. In your environment, Seurat is not present so its not loaded, this is because we can't see it in any of the three headings of sessionInfo(). You need to run library(Seurat), once you do that, you will see Seurat as well, in your sessionInfo() just like I can see Seurat in my sessionInfo()

Ksong11 commented 1 year ago

Yes, we can see Seurat loaded in my environment. In your environment, Seurat is not present so its not loaded, this is because we can't see it in any of the three headings of sessionInfo(). You need to run library(Seurat), once you do that, you will see Seurat as well, in your sessionInfo() just like I can see Seurat in my sessionInfo()

Thank you so much! Restart the R helped! Now I encountered another issue. When I ran Harmony, I got this error massage;

 #Run Harmony batch correction with library and tissue source covariates
> pbmc <- RunHarmony(pbmc,
+                    assay.use = "RNA",
+                    reduction = "pca",
+                    dims.use = 1:20,
+                    group.by.vars = c("donor", "stim"),
+                    kmeans_init_nstart=20, kmeans_init_iter_max=100,
+                    plot_convergence = TRUE)
Error in RunHarmony(pbmc, assay.use = "RNA", reduction = "pca", dims.use = 1:20,  : 
  could not find function "RunHarmony"

Please help to troubleshooting. Thanks!

Dragonmasterx87 commented 1 year ago

Hi @Ksong11 ! So if you look at the error, it says:

Error in RunHarmony(pbmc, assay.use = "RNA", reduction = "pca", dims.use = 1:20, :
could not find function "RunHarmony"

So the could not find function "RunHarmony" error message suggests that either Harmony is not installed, or if it is installed it is not loaded. So I am guessing that you installed harmony, using:

# Install Harmony https://www.nature.com/articles/s41592-019-0619-0
# https://github.com/immunogenomics/harmony
install.packages("harmony")

In that case you need to load Harmony using: library(harmony)

Once you do that Harmony should work!

Dragonmasterx87 commented 1 year ago

Remember every time you restart Rstudio or R you need to load your packages. You dont need to keep installing them again and again, installing them once is enough. But you need to activate the packages or "load" them into your current environment.

Think of it like this, when you re-start your computer, Microsoft office Word will not automatically start working. you need to double-click on Word icon and 'load" it, however, you don't need to re-install Word each time you restart your PC, but in order to use Word you need to double-click on the Word icon and "load" it. Only then can you use Word. R packages like seurat and harmony are the same. Each time you restart R or Rstudio, you need to "load" packages that have been installed. So everytime you will have to run:

# Load packages into R
library(Seurat)
library(harmony)

The reason I ask for sessionInfo() is because that tells me what packages are loaded in your current Rstudio environment. Earlier, thats how I noticed that there was no seurat loaded and that at some point due to not loading seurat the workflow generated an error.

Hope that helps! Let me know if you have any more questions.

🐲

Ksong11 commented 1 year ago

Thank you so much for the help! Now I am getting to the point to plot top 2 candidate proteins of interferon response genes. And i got this error message. Please let me how can i get the "wrap_plots". Thanks!

  # Run plotting function
  wrap_plots(plots = plots, ncol = 1)

Error in wrap_plots(plots = plots, ncol = 1) : could not find function "wrap_plots"

Dragonmasterx87 commented 1 year ago

That is probably because your session doesn't have patchwork installed by default during the package installation process of Seurat or ggplot2. Can you tell me the output of sessionInfo() and packageVersion("patchwork") if the answer to the latter is NULL or some error, then install patchwork via: install.packages('patchwork')

Dragonmasterx87 commented 1 year ago

Once patchwork is installed you can load it via library(patchwork) like you would any other package.

Ksong11 commented 1 year ago

Here are what I got. I think I had this package installed.

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

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
[1] harmony_0.1.1      Rcpp_1.0.11        Seurat_4.3.0      
[4] SeuratObject_4.1.3 sp_2.0-0          

loaded via a namespace (and not attached):
  [1] deldir_1.0-9           pbapply_1.7-2          gridExtra_2.3         
  [4] rlang_1.1.1            magrittr_2.0.3         RcppAnnoy_0.0.21      
  [7] matrixStats_1.0.0      ggridges_0.5.4         compiler_4.3.1        
 [10] spatstat.geom_3.2-4    png_0.1-8              vctrs_0.6.3           
 [13] reshape2_1.4.4         stringr_1.5.0          pkgconfig_2.0.3       
 [16] fastmap_1.1.1          ellipsis_0.3.2         labeling_0.4.2        
 [19] utf8_1.2.3             promises_1.2.0.1       purrr_1.0.1           
 [22] jsonlite_1.8.7         goftest_1.2-3          later_1.3.1           
 [25] spatstat.utils_3.0-3   irlba_2.3.5.1          parallel_4.3.1        
 [28] cluster_2.1.4          R6_2.5.1               ica_1.0-3             
 [31] stringi_1.7.12         RColorBrewer_1.1-3     spatstat.data_3.0-1   
 [34] reticulate_1.31        parallelly_1.36.0      lmtest_0.9-40         
 [37] scattermore_1.2        tensor_1.5             future.apply_1.11.0   
 [40] zoo_1.8-12             sctransform_0.3.5      httpuv_1.6.11         
 [43] Matrix_1.6-0           splines_4.3.1          igraph_1.5.1          
 [46] tidyselect_1.2.0       rstudioapi_0.15.0      abind_1.4-5           
 [49] spatstat.random_3.1-5  codetools_0.2-19       miniUI_0.1.1.1        
 [52] spatstat.explore_3.2-1 listenv_0.9.0          lattice_0.21-8        
 [55] tibble_3.2.1           plyr_1.8.8             withr_2.5.0           
 [58] shiny_1.7.5            ROCR_1.0-11            Rtsne_0.16            
 [61] future_1.33.0          survival_3.5-5         polyclip_1.10-4       
 [64] fitdistrplus_1.1-11    pillar_1.9.0           KernSmooth_2.23-22    
 [67] plotly_4.10.2          generics_0.1.3         ggplot2_3.4.3         
 [70] munsell_0.5.0          scales_1.2.1           globals_0.16.2        
 [73] xtable_1.8-4           glue_1.6.2             lazyeval_0.2.2        
 [76] tools_4.3.1            data.table_1.14.8      RANN_2.6.1            
 [79] leiden_0.4.3           cowplot_1.1.1          grid_4.3.1            
 [82] tidyr_1.3.0            colorspace_2.1-0       nlme_3.1-163          
 [85] patchwork_1.1.3        cli_3.6.1              spatstat.sparse_3.0-2 
 [88] fansi_1.0.4            viridisLite_0.4.2      dplyr_1.1.2           
 [91] uwot_0.1.16            gtable_0.3.3           digest_0.6.33         
 [94] progressr_0.14.0       ggrepel_0.9.3          farver_2.1.1          
 [97] htmlwidgets_1.6.2      htmltools_0.5.5        lifecycle_1.0.3       
[100] httr_1.4.7             mime_0.12              MASS_7.3-60   
>       packageVersion("patchwork")      
[1] ‘1.1.3’
>       library(patchwork)     
Dragonmasterx87 commented 1 year ago

Interesting. Perhaps ggplot2 is missing, I didn't see it in your sessioninfo. For now, you should be able to run plots and it will plot the plots. Can you perform library(ggplot2) and then try? or try patchwork::wrap_plots(plots = plots, ncol = 1)

Ksong11 commented 1 year ago

Yes, it works by running this! Thanks! library(ggplot2)

  patchwork::wrap_plots(plots = plots, ncol = 1)  
Dragonmasterx87 commented 1 year ago

Great!

Ksong11 commented 1 year ago

Now, I have another issue:

# Metadata organization and addition to aggregated object
{
  Idents(combined_pbmc) <- 'celltype.stim.donor'
  combined_pbmc$celltype <- combined_pbmc@meta.data[["orig.ident"]]
  metadat <- combined_pbmc@meta.data
  metadat$celltype <- metadat[c('celltype')] <- str_split_i(metadat$celltype.stim.donor, "_", -3)
  metadat$stim <- metadat[c('stim')] <- str_split_i(metadat$celltype.stim.donor, '_', -2)
  metadat$donor <- metadat[c('donor')] <- str_split_i(metadat$celltype.stim.donor, '_', -1)
  combined_pbmc@meta.data = metadat
}

Error output:

Error in str_split_i(metadat$celltype.stim.donor, "_", -3) : 
  could not find function "str_split_i"
Dragonmasterx87 commented 1 year ago

Tidyverse is not loaded in your current environment :)

install.packages("tidyverse")
library(tidyverse)

It should work now. str_split are functions which is a part of stringr, which itself is a part of tidyverse

Ksong11 commented 1 year ago

Idents(combined_pbmc) <- "celltype.stim" b.interferon.response.aggr <- FindMarkers(combined_pbmc, ident.1 = "B_STIM", ident.2 = "B_CTRL", slot = 'data', test.use = "DESeq2", min.pct = 0.1, latent.vars = c("donor"), logfc.threshold = 0.5849, #~1.5FC only.pos = TRUE, verbose = FALSE) Warning: 'latent.vars' is only used for the following tests: negbinom, poisson, MAST, LR converting counts to integer mode gene-wise dispersion estimates mean-dispersion relationship final dispersion estimates

head(b.interferon.response.aggr, n = 15)

When I ran this script above, I got this error message below and I did not get the output table. Do you think if there is anything I need to concern?

Idents(combined_pbmc) <- "celltype.stim"

  b.interferon.response.aggr <- FindMarkers(combined_pbmc, ident.1 = "B_STIM", ident.2 = "B_CTRL",
  • slot = 'data',
  • test.use = "DESeq2",
  • min.pct = 0.1,
  • latent.vars = c("donor"),
  • logfc.threshold = 0.5849, #~1.5FC
  • only.pos = TRUE,
  • verbose = FALSE) Warning: 'latent.vars' is only used for the following tests: negbinom, poisson, MAST, LR converting counts to integer mode gene-wise dispersion estimates mean-dispersion relationship final dispersion estimates Warning: 'latent.vars' is only used for the following tests: negbinom, poisson, MAST, LR Error: unexpected symbol in " Warning: 'latent.vars' is"
Dragonmasterx87 commented 1 year ago

The warning comes when one cant use a latent variable with a certain test. so for example, since you are using test.use = "DESeq2", the warning comes up because you can only select negbinom, poisson, MAST, LR if you want to adjust for latent variables. Its a warning the test should still run. DEseq2 natively corrects for library size so it should be acceptable.

Ksong11 commented 1 year ago

I got this issue. Please let me know how to solve it. Thanks!

Lets look at genes in a venn diagram'

  LR.genes <- rownames(b.interferon.response)
  DESeq2.genes <- rownames(b.interferon.response.aggr)
  # Make a list
  x <- list("LR.genes" = LR.genes, "DESeq2.genes" = DESeq2.genes)
  # Make a Venn object
  venn <- Venn(x)

Error in Venn(x) : could not find function "Venn"

Dragonmasterx87 commented 1 year ago

Congrats, you have found the 2nd hidden test!

If you see the original package loadings, you will NOT see one for a venn diagram, so whenever you get an issue that states: Error in: could not find function "" that means you 1) either haven't installed or 2) haven't loaded your package. So, to correct this you need to first install the package: ggvenn you can acheive this by running: install.packages("ggvenn") and then loading it by performing library(ggvenn)

Ksong11 commented 1 year ago

Should I install all of the packages as listed below? install.packages("grid") Warning in install.packages : package ‘grid’ is a base package, and should not be updated

  library(ggvenn)    

Loading required package: dplyr

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

Loading required package: grid Loading required package: ggplot2

Dragonmasterx87 commented 1 year ago

R is smart, it does that for you on its own. All you have to do is check that its loaded into your environment. via sessionInfo() or packageVersion("ggvenn")

Dragonmasterx87 commented 1 year ago

I'm marking this issue as complete, if you have an issue either make a new post or reopen this one, thanks.