carmonalab / ProjecTILs

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

no slot of name "var.features" for this object of class "Assay5" #85

Open apal6 opened 4 months ago

apal6 commented 4 months ago

Hi,

I am encountering the issue with the var.features which is not present in the meta.data. I tried to manually add the col var.features and still no luck.

query.projected <- Run.ProjecTILs(merged_obj_unintegrated_TIL, ref=ref,reduction = "pca") | | 0%[1] "Using assay RNA for query" Pre-filtering cells with scGate... 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"

Seurat object is just merged object which contains 4 samples. merged_obj_unintegrated_TIL An object of class Seurat 20138 features across 31797 samples within 1 assay Active assay: RNA (20138 features, 2000 variable features) 3 layers present: data, counts, scale.data 3 dimensional reductions calculated: pca, umap.unintegrated, umap

slotNames(merged_obj_unintegrated_TIL) [1] "assays" "meta.data" "active.assay" "active.ident" "graphs" "neighbors" "reductions" [8] "images" "project.name" "misc" "version" "commands" "tools"

How can I debug this? Thank you!

mass-a commented 4 months ago

Hello,

perhaps it could be due to incompatible package versions? can you share your SessionInfo()?

apal6 commented 4 months ago

Hi,

Here it is-

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

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] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Los_Angeles tzcode source: internal

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

other attached packages: [1] BiocParallel_1.36.0 ProjecTILs_3.3.1 magrittr_2.0.3 plot1cell_0.0.0.9000
[5] ComplexHeatmap_2.18.0 wordcloud_2.6 simplifyEnrichment_1.12.0 GEOquery_2.70.0
[9] rlang_1.1.3 cowplot_1.1.3 EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.26.0
[13] AnnotationFilter_1.26.0 GenomicFeatures_1.54.4 AnnotationDbi_1.64.1 Biobase_2.62.0
[17] GenomicRanges_1.54.1 GenomeInfoDb_1.38.8 IRanges_2.36.0 S4Vectors_0.40.2
[21] BiocGenerics_0.48.1 loomR_0.2.1.9000 R6_2.5.1 hdf5r_1.3.10
[25] Matrix_1.7-0 data.table_1.15.4 DoubletFinder_2.0.3 matrixStats_1.3.0
[29] ComplexUpset_1.3.3 ggbeeswarm_0.7.2 biomaRt_2.58.2 progress_1.2.3
[33] scales_1.3.0 MASS_7.3-60.0.1 ggh4x_0.2.8 circlize_0.4.16
[37] plotly_4.10.4 scCustomize_2.1.2 lubridate_1.9.3 forcats_1.0.0
[41] stringr_1.5.1 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1
[45] tibble_3.2.1 tidyverse_2.0.0 viridis_0.6.5 viridisLite_0.4.2
[49] ggplot2_3.5.1 RColorBrewer_1.1-3 reshape2_1.4.4 harmony_1.2.0 `

mass-a commented 4 months ago

Looking more closely at your error log, I suspect you have an older version of scGate installed. Can you try updating it and see if solves the issue? install.packages("scGate") and then start a fresh session.

apal6 commented 4 months ago

Hi @mass-a,

I tried updating the scGate pacakge to version 1.2.0 as mentioned here, https://github.com/carmonalab/scGate

Still I get this error:

`query.projected <- Run.ProjecTILs(merged_obj_TIL, ref=ref) | | 0%[1] "Using assay RNA for query" Pre-filtering cells with scGate...

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"`

merged_obj_TIL <- readRDS("~/Desktop/Yang_scData/merged_obj_TIL.rds") merged_obj_TIL <- JoinLayers(merged_obj_TIL)

Is it something with the seurat version?

mass-a commented 4 months ago

scGate 1.2.0 is from mid-2022 (prior to Seurat 5 release). If you install from CRAN, as I suggested, you will get version 1.6.2, which should solve your problem.

apal6 commented 4 months ago

Sure, I tried to do it using the command above and still it downloads the 1.4.1 version:

install.packages("scGate") trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.3/scGate_1.4.1.tgz' Content type 'application/x-gzip' length 2034227 bytes (1.9 MB)

I then tried to specify the version:

install.packages("scGate", version = "1.6.2") trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.3/scGate_1.4.1.tgz' Content type 'application/x-gzip' length 2034227 bytes (1.9 MB)

mass-a commented 4 months ago

Hello, if for some reason the CRAN download doesn't work, you can also get a specific version of the package from GitHub, using:

library(remotes)
remotes::install_github("carmonalab/scGate", ref="v1.6.2")

Best -m

apal6 commented 4 months ago

Thank you. I did try using remotes and still the same error:

query.projected <- Run.ProjecTILs(merged_obj_TIL, ref=ref) | | 0%[1] "Using assay RNA for query" Pre-filtering cells with scGate... 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"

GBeattie commented 3 months ago

Just putting this here as it's a similar issue, and my workaround is likely generic.

My issue was no slot called "images":

seu.int <- ProjecTILs.classifier(query = seu.int, ref = ref)
  |================================================================================================| 100%

Error: BiocParallel errors
  1 remote errors, element index: 1
  0 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 slot(object = object, name = s): no slot of name "images" for this object of class "Seurat"

Fixed by just copying a slot and naming it "images" (this slot is not used at all by projecTILs so no behaviour is altered):

> ref <- load.reference.map(ref = "/Users/gordonbeattie/Documents/Projects/Felipe/ref_TILAtlas_mouse_v1.rds")
[1] "Loading Custom Reference Atlas..."
[1] "Loaded Custom Reference map ref_TILAtlas_mouse_v1"
> ref@images
Error: no slot of name "images" for this object of class "Seurat"
> ref@images <- ref@reductions
> ref@images
$pca
A dimensional reduction object with key PC_ 
 Number of dimensions: 50 
 Number of cells: 16803 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: integrated 

> ProjecTILs.classifier(query = UpdateSeuratObject(seu.int), ref = ref)
Validating object structure
Updating object slots
Ensuring keys are in the proper structure...