carmonalab / ProjecTILs

Interpretation of cell states using reference single-cell maps
GNU General Public License v3.0
231 stars 27 forks source link

Error in make.projection() #74

Closed wsullivan22 closed 3 months ago

wsullivan22 commented 4 months ago

Hello,

Thank you for making such a useful package!

I am running into an error when following the checkpoint blockade in melanoma patients tutorial (https://carmonalab.github.io/ProjecTILs_CaseStudies/SadeFeldman_ortho.html#background) and was hoping to get some help. I have a Seurat object of T and NK cells that I have subset from a larger dataset and pre-processed using the standard pre-processing steps:

TNKcell_object <- subset(lymphocyte_object, subset = singleR_CellTypeLabels == "NK cells" | singleR_CellTypeLabels == "NKT" 
         | singleR_CellTypeLabels == "T cells" | singleR_CellTypeLabels == "Tgd")
TNKcell_object <- NormalizeData(TNKcell_object, verbose = F)
TNKcell_object <- FindVariableFeatures(TNKcell_object, verbose = F)
TNKcell_object <- ScaleData(TNKcell_object, verbose = F)
TNKcell_object <- RunPCA(TNKcell_object, verbose = FALSE)
TNKcell_object <- FindNeighbors(TNKcell_object, dims = 1:30, reduction = "pca", verbose = FALSE)
TNKcell_object <- FindClusters(TNKcell_object, verbose = FALSE)
TNKcell_object <- RunUMAP(TNKcell_object, dims = 1:30, reduction = "pca", verbose = F)

I then proceed with the first steps of the tutorial:

ref_TILs <- load.reference.map()

[1] "Loading Default Reference Atlas..." [1] "pwd/ref_TILAtlas_mouse_v1.rds" [1] "Loaded Reference map ref_TILAtlas_mouse_v1"

But run into the following error with the next step:

TNKcell.projected <- make.projection(TNKcell_object, ref = ref_TILs)

| | 0%[1] "Using assay RNA for query" Pre-filtering cells with scGate... |===========================================================================================================| 100%

Error: BiocParallel errors 1 remote errors, element index: 1 0 unevaluated and other errors first remote error: Error in as.vector(x): no slot of name "var.features" for this object of class "Assay5"

When I run the following, I see that there were no issues with FindVariableFeatures():

head(VariableFeatures(TNKcell_object))

[1] "Igkc" "Jchain" "Mzb1" "Ccl5" "Igha" "Gzma"

I was thinking this may be related to how the Seurat v5 assay stores the variable features compared to previous versions of Seurat. I tried to create a new layer in the "RNA" assay named "var.features" but that led to another error. Any help would be much appreciated!

mass-a commented 4 months ago

Hello Will,

what versions of ProjecTILs and Seurat are you using? I just checked with the latest of both, and the code of the case study should run fine.

That said, this case study was generated in 2021, so I should probably do an update with newer versions of all packages. For example, ProjecTILs now has more convenient functions for cell type prediction, as you can see e.g. in this other case study: https://carmonalab.github.io/ProjecTILs_CaseStudies/Bassez_BC.html

Best -m

wsullivan22 commented 4 months ago

Hi Massimo,

Thanks so much for the quick reply! I included the output of sessionInfo() below. I followed the other case study and attempted to use ProjecTILs.classifier() for cell type prediction but ran into the same issue:

ref_TILs <- load.reference.map()

[1] "Loading Default Reference Atlas..." [1] "pwd/ref_TILAtlas_mouse_v1.rds" [1] "Loaded Reference map ref_TILAtlas_mouse_v1"

TNKcell_object <- ProjecTILs.classifier(TNKcell_object, ref = ref_TILs, filter.cells = TRUE, split.by = "Condition")

| | 0%[1] "Using assay RNA for query" Pre-filtering cells with scGate... |================================================================================================================================| 100%

Error: BiocParallel errors 1 remote errors, element index: 1 1 unevaluated and other errors first remote error: Error: BiocParallel errors 1 remote errors, element index: 1 0 unevaluated and other errors first remote error: Error in as.vector(x): no slot of name "var.features" for this object of class "Assay5"

I also followed along with the provided code in the linked case study, and all of the output was identical to the case study until:

# Classify CD8 T subtypes
ncores = 8
data.seurat <- ProjecTILs.classifier(data.seurat, ref.cd8, ncores = ncores, split.by = "patient_id")

Error: BiocParallel errors 1 remote errors, element index: 1 1 unevaluated and other errors first remote error: Error: BiocParallel errors 1 remote errors, element index: 1 0 unevaluated and other errors first remote error: Error in as.vector(x): no slot of name "var.features" for this object of class "Assay5"

sessionInfo()

R version 4.3.1 (2023-06-16) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Sonoma 14.3

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] C

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] reshape2_1.4.4 patchwork_1.2.0 ProjecTILs_3.3.0 remotes_2.4.2.1
[5] celldex_1.12.0 SingleR_2.4.1 SummarizedExperiment_1.32.0 Biobase_2.62.0
[9] GenomicRanges_1.54.1 GenomeInfoDb_1.38.5 IRanges_2.36.0 S4Vectors_0.40.2
[13] BiocGenerics_0.48.1 MatrixGenerics_1.14.0 matrixStats_1.2.0 openxlsx_4.2.5.2
[17] HGNChelper_0.8.1 RColorBrewer_1.1-3 presto_1.0.0 data.table_1.15.0
[21] Rcpp_1.0.12 devtools_2.4.5 usethis_2.2.2 SeuratWrappers_0.3.3
[25] Seurat_5.0.1 SeuratObject_5.0.1 sp_2.1-3 lubridate_1.9.3
[29] forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
[33] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 ggplot2_3.4.4
[37] tidyverse_2.0.0 BiocManager_1.30.22

loaded via a namespace (and not attached): [1] fs_1.6.3 spatstat.sparse_3.0-3 bitops_1.0-7 httr_1.4.7
[5] profvis_0.3.8 tools_4.3.1 sctransform_0.4.1 utf8_1.2.4
[9] R6_2.5.1 lazyeval_0.2.2 uwot_0.1.16 urlchecker_1.0.1
[13] withr_3.0.0 gridExtra_2.3 progressr_0.14.0 textshaping_0.3.7
[17] cli_3.6.2 spatstat.explore_3.2-6 fastDummies_1.7.3 labeling_0.4.3
[21] spatstat.data_3.0-4 askpass_1.2.0 ggridges_0.5.6 pbapply_1.7-2
[25] systemfonts_1.0.5 R.utils_2.12.3 parallelly_1.36.0 sessioninfo_1.2.2
[29] rstudioapi_0.15.0 RSQLite_2.3.5 generics_0.1.3 ica_1.0-3
[33] spatstat.random_3.2-2 zip_2.3.1 Matrix_1.6-5 fansi_1.0.6
[37] abind_1.4-5 R.methodsS3_1.8.2 lifecycle_1.0.4 yaml_2.3.8
[41] SparseArray_1.2.3 BiocFileCache_2.10.1 Rtsne_0.17 grid_4.3.1
[45] blob_1.2.4 promises_1.2.1 ExperimentHub_2.10.0 crayon_1.5.2
[49] miniUI_0.1.1.1 lattice_0.22-5 beachmat_2.18.0 cowplot_1.1.3
[53] KEGGREST_1.42.0 scGate_1.4.1 pillar_1.9.0 knitr_1.45
[57] future.apply_1.11.1 codetools_0.2-19 leiden_0.4.3.1 glue_1.7.0
[61] vctrs_0.6.5 png_0.1-8 spam_2.10-0 gtable_0.3.4
[65] cachem_1.0.8 xfun_0.42 S4Arrays_1.2.0 mime_0.12
[69] pracma_2.4.4 survival_3.5-7 SingleCellExperiment_1.24.0 pheatmap_1.0.12
[73] interactiveDisplayBase_1.40.0 ellipsis_0.3.2 fitdistrplus_1.1-11 ROCR_1.0-11
[77] nlme_3.1-164 bit64_4.0.5 filelock_1.0.3 RcppAnnoy_0.0.22
[81] irlba_2.3.5.1 KernSmooth_2.23-22 colorspace_2.1-0 DBI_1.2.0
[85] STACAS_2.2.2 UCell_2.6.2 tidyselect_1.2.0 bit_4.0.5
[89] compiler_4.3.1 curl_5.2.0 BiocNeighbors_1.20.2 DelayedArray_0.28.0
[93] plotly_4.10.4 scales_1.3.0 lmtest_0.9-40 rappdirs_0.3.3
[97] digest_0.6.34 goftest_1.2-3 spatstat.utils_3.0-4 XVector_0.42.0
[101] htmltools_0.5.7 pkgconfig_2.0.3 umap_0.2.10.0 sparseMatrixStats_1.14.0
[105] dbplyr_2.4.0 fastmap_1.1.1 rlang_1.1.3 htmlwidgets_1.6.4
[109] shiny_1.8.0 DelayedMatrixStats_1.24.0 farver_2.1.1 zoo_1.8-12
[113] jsonlite_1.8.8 BiocParallel_1.36.0 R.oo_1.26.0 BiocSingular_1.18.0
[117] RCurl_1.98-1.14 magrittr_2.0.3 GenomeInfoDbData_1.2.11 dotCall64_1.1-1
[121] munsell_0.5.0 reticulate_1.35.0 stringi_1.8.3 zlibbioc_1.48.0
[125] MASS_7.3-60.0.1 AnnotationHub_3.10.0 plyr_1.8.9 pkgbuild_1.4.3
[129] parallel_4.3.1 listenv_0.9.1 ggrepel_0.9.5 deldir_2.0-2
[133] Biostrings_2.70.2 splines_4.3.1 tensor_1.5 hms_1.1.3
[137] igraph_2.0.1.1 spatstat.geom_3.2-8 RcppHNSW_0.6.0 ScaledMatrix_1.10.0
[141] pkgload_1.3.4 BiocVersion_3.18.1 tzdb_0.4.0 httpuv_1.6.14
[145] openssl_2.1.1 RANN_2.6.1 polyclip_1.10-6 future_1.33.1
[149] scattermore_1.2 rsvd_1.0.5 xtable_1.8-4 RSpectra_0.16-1
[153] later_1.3.2 ragg_1.2.7 viridisLite_0.4.2 memoise_2.0.1
[157] AnnotationDbi_1.64.1 cluster_2.1.6 timechange_0.3.0 globals_0.16.2

mass-a commented 4 months ago

Thanks for posting the log and session info.

Checking the log it actually appears that the error comes from the pre-filtering by scGate. You can verify this is the case by setting filter.cells=FALSE when calling ProjecTILs. From the session info I see you have an older version of this package (1.4) which is probably not compatible with Seurat 5 objects. I suggest updating scGate with install.packages("scGate"), start a fresh session and try again?

wsullivan22 commented 4 months ago

It seems like the error was coming from scGate. When filter.cells=FALSE, the cell type prediction runs without issue. After updating scGate to version: scGate_1.4.1, the error persists when filter.cells=TRUE.

mass-a commented 4 months ago

Please note that the latest version of scGate on CRAN is 1.6.0: https://cran.r-project.org/web/packages/scGate/index.html Otherwise you can also get it from GitHub using: remotes::install_github("carmonalab/scGate")