Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when attempting to merge Seurat Objects after filtering #59

Open
william-hutchison opened this issue May 2, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@william-hutchison
Copy link
Collaborator

Hello,

I am encountering an error when trying to merge two Seurat Objects after using tidyseurat's filter(). The error can only be produced when the attached data's "integrated" assay is present.

The error is produced by calling merge() with the following code:

library("Seurat")
library("tidyseurat")

pbmc_complex <-
  readRDS("pbmc_complex.rds")

pbmc_complex_filtered <-
  pbmc_complex |>
  tidyseurat::filter(sample %in% c("SI-GA-G9", "SI-GA-G6"))

pbmc_complex_filtered_split <- 
  SplitObject(pbmc_complex_filtered, "sample")

pbmc_complex_filtered_merged <- 
  merge(pbmc_complex_filtered_split[[1]], pbmc_complex_filtered_split[[2]])

The error message is:

Error in names(model.list) <- all.levels : 
  attempt to set an attribute on NULL

The pbmc_complex_filtered_split object looks like:

$`SI-GA-G9`
# A Seurat-tibble abstraction: 14 × 111
# Features=59856 | Cells=14 | Active assay=RNA | Assays=RNA, integrated,
#  prediction.score.celltype.l1, prediction.score.celltype.l2, predicted_ADT,
#  prediction.score.curated_cell_type, prediction.score.curated_cell_type_pretty
   .cell       Barcode race  sex   chemi…¹ note  batch BCB   type  DOB   date.…² Sampl…³ Stage…⁴
   <chr>       <chr>   <chr> <chr> <lgl>   <chr> <chr> <chr> <chr> <chr> <chr>   <chr>   <chr>  
 1 8_AGACACTT… AGACAC… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 2 8_TTCCGGTT… TTCCGG… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 3 8_GGCACGTT… GGCACG… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 4 8_ATCACAGA… ATCACA… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 5 8_CGCATGGA… CGCATG… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 6 8_TACTTACT… TACTTA… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 7 8_CAAGCTAG… CAAGCT… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 8 8_CATTCCGC… CATTCC… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov… 9 8_CATTCTAG… CATTCT… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov…
10 8_ATCCCTGG… ATCCCT… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov…
11 8_CTGCGAGT… CTGCGA… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov…
12 8_AGATAGAC… AGATAG… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov…
13 8_TCTACCGG… TCTACC… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov…
14 8_TATATCCC… TATATC… white NA    NA      NA    3     BCB0… MBC   6/11… 11/12/… 4/6/20… De nov…
# … with 98 more variables: intrinsic.subtype <chr>,
#   STAGE.WHEN.BIOPSY.TAKEN..EBC.vs..MBC. <chr>,
#   Treatment.response.at.time.sample.taken..progressing..responding..stable.disease. <chr>,
#   menopausal.status..premenopausal..perimenopausal..postmenopausal. <chr>,
#   neoadjuvant.therapy..specified. <chr>, radiotherapy..y.n. <chr>,
#   endocrine.therapy..y.n. <chr>, her2.targeted.therapy..y.n. <chr>,
#   adjuvant.chemotherapy..y.n. <chr>, …
# ℹ Use `colnames()` to see all variable names

$`SI-GA-G6`
# A Seurat-tibble abstraction: 6 × 111
# Features=59856 | Cells=6 | Active assay=RNA | Assays=RNA, integrated,
#  prediction.score.celltype.l1, prediction.score.celltype.l2, predicted_ADT,
#  prediction.score.curated_cell_type, prediction.score.curated_cell_type_pretty
  .cell        Barcode race  sex   chemi…¹ note  batch BCB   type  DOB   date.…² Sampl…³ Stage…⁴
  <chr>        <chr>   <chr> <chr> <lgl>   <chr> <chr> <chr> <chr> <chr> <chr>   <chr>   <chr>  
1 4_ATATCCTGT… ATATCC… white NA    NA      NA    2     BCB0… OMBC  13/0… 01/07/… 1/5/20… WLE + …
2 4_GGGAGTACA… GGGAGT… white NA    NA      NA    2     BCB0… OMBC  13/0… 01/07/… 1/5/20… WLE + …
3 4_CCCTGATAG… CCCTGA… white NA    NA      NA    2     BCB0… OMBC  13/0… 01/07/… 1/5/20… WLE + …
4 4_CGCATAATC… CGCATA… white NA    NA      NA    2     BCB0… OMBC  13/0… 01/07/… 1/5/20… WLE + …
5 4_GGATCTAAG… GGATCT… white NA    NA      NA    2     BCB0… OMBC  13/0… 01/07/… 1/5/20… WLE + …
6 4_CGTTCTGTC… CGTTCT… white NA    NA      NA    2     BCB0… OMBC  13/0… 01/07/… 1/5/20… WLE + …
# … with 98 more variables: intrinsic.subtype <chr>,
#   STAGE.WHEN.BIOPSY.TAKEN..EBC.vs..MBC. <chr>,
#   Treatment.response.at.time.sample.taken..progressing..responding..stable.disease. <chr>,
#   menopausal.status..premenopausal..perimenopausal..postmenopausal. <chr>,
#   neoadjuvant.therapy..specified. <chr>, radiotherapy..y.n. <chr>,
#   endocrine.therapy..y.n. <chr>, her2.targeted.therapy..y.n. <chr>,
#   adjuvant.chemotherapy..y.n. <chr>, …
# ℹ Use `colnames()` to see all variable names

Merging with the same data works fine without filtering:

pbmc_complex_split <-
  SplitObject(pbmc_complex, "sample")

pbmc_complex_merged <-
  merge(pbmc_complex_split[[1]], pbmc_complex_split[[2]])

And merging after filtering works fine when the "integrated" assay is removed:

pbmc_complex[['integrated']] <- 
  NULL

pbmc_complex_filtered <-
  pbmc_complex |>
  tidyseurat::filter(sample %in% c("SI-GA-G9", "SI-GA-G6"))

pbmc_complex_filtered_split <- 
  SplitObject(pbmc_complex_filtered, "sample")

pbmc_complex_filtered_merged <- 
  merge(pbmc_complex_filtered_split[[1]], pbmc_complex_filtered_split[[2]])

sessionInfo():

R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /stornext/System/data/apps/R/R-4.2.1/lib64/R/lib/libRblas.so
LAPACK: /stornext/System/data/apps/R/R-4.2.1/lib64/R/lib/libRlapack.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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] tidyHeatmap_1.9.2  cowplot_1.1.1      ggrepel_0.9.3      sccomp_1.2.1      
 [5] tidyseurat_0.5.9   ttservice_0.2.2    SeuratObject_4.1.3 Seurat_4.3.0      
 [9] forcats_1.0.0      stringr_1.5.0      dplyr_1.1.1        purrr_1.0.1       
[13] readr_2.1.4        tidyr_1.3.0        tibble_3.2.1       ggplot2_3.4.2     
[17] tidyverse_1.3.2   

loaded via a namespace (and not attached):
  [1] utf8_1.2.3                  spatstat.explore_3.1-0      reticulate_1.28            
  [4] tidyselect_1.2.0            htmlwidgets_1.6.2           grid_4.2.1                 
  [7] Rtsne_0.16                  munsell_0.5.0               codetools_0.2-18           
 [10] ica_1.0-3                   future_1.32.0               miniUI_0.1.1.1             
 [13] withr_2.5.0                 spatstat.random_3.1-4       colorspace_2.1-0           
 [16] progressr_0.13.0            Biobase_2.58.0              rstudioapi_0.14            
 [19] stats4_4.2.1                SingleCellExperiment_1.20.1 ROCR_1.0-11                
 [22] tensor_1.5                  listenv_0.9.0               MatrixGenerics_1.10.0      
 [25] labeling_0.4.2              rstan_2.21.8                GenomeInfoDbData_1.2.9     
 [28] polyclip_1.10-4             farver_2.1.1                parallelly_1.35.0          
 [31] vctrs_0.6.1                 generics_0.1.3              timechange_0.2.0           
 [34] doParallel_1.0.17           R6_2.5.1                    GenomeInfoDb_1.34.9        
 [37] clue_0.3-64                 bitops_1.0-7                spatstat.utils_3.0-2       
 [40] DelayedArray_0.24.0         promises_1.2.0.1            scales_1.2.1               
 [43] googlesheets4_1.1.0         gtable_0.3.1                globals_0.16.2             
 [46] processx_3.8.1              goftest_1.2-3               rlang_1.1.0                
 [49] systemfonts_1.0.4           GlobalOptions_0.1.2         splines_4.2.1              
 [52] lazyeval_0.2.2              gargle_1.4.0                spatstat.geom_3.1-0        
 [55] broom_1.0.4                 inline_0.3.19               reshape2_1.4.4             
 [58] abind_1.4-5                 modelr_0.1.11               backports_1.4.1            
 [61] httpuv_1.6.9                tools_4.2.1                 ellipsis_0.3.2             
 [64] RColorBrewer_1.1-3          BiocGenerics_0.44.0         ggridges_0.5.4             
 [67] Rcpp_1.0.10                 plyr_1.8.8                  zlibbioc_1.44.0            
 [70] RCurl_1.98-1.12             ps_1.7.5                    prettyunits_1.1.1          
 [73] deldir_1.0-6                viridis_0.6.2               GetoptLong_1.0.5           
 [76] pbapply_1.7-0               S4Vectors_0.36.2            zoo_1.8-12                 
 [79] SummarizedExperiment_1.28.0 haven_2.5.2                 cluster_2.1.3              
 [82] fs_1.6.1                    magrittr_2.0.3              data.table_1.14.8          
 [85] scattermore_0.8             circlize_0.4.15             lmtest_0.9-40              
 [88] reprex_2.0.2                RANN_2.6.1                  googledrive_2.1.0          
 [91] fitdistrplus_1.1-8          matrixStats_0.63.0          hms_1.1.3                  
 [94] patchwork_1.1.2             mime_0.12                   xtable_1.8-4               
 [97] readxl_1.4.2                shape_1.4.6                 IRanges_2.32.0             
[100] gridExtra_2.3               rstantools_2.3.1            compiler_4.2.1             
[103] KernSmooth_2.23-20          crayon_1.5.1                StanHeaders_2.21.0-7       
[106] htmltools_0.5.5             later_1.3.0                 tzdb_0.3.0                 
[109] RcppParallel_5.1.7          lubridate_1.9.2             DBI_1.1.3                  
[112] ComplexHeatmap_2.14.0       dbplyr_2.3.2                MASS_7.3-57                
[115] boot_1.3-28                 Matrix_1.5-3                cli_3.6.1                  
[118] parallel_4.2.1              igraph_1.4.2                GenomicRanges_1.50.2       
[121] pkgconfig_2.0.3             sp_1.6-0                    plotly_4.10.1              
[124] spatstat.sparse_3.0-1       foreach_1.5.2               xml2_1.3.3                 
[127] XVector_0.38.0              rvest_1.0.3                 callr_3.7.3                
[130] digest_0.6.31               sctransform_0.3.5           RcppAnnoy_0.0.20           
[133] spatstat.data_3.0-1         cellranger_1.1.0            leiden_0.4.3               
[136] dendextend_1.17.1           uwot_0.1.14                 shiny_1.7.4                
[139] rjson_0.2.21                lifecycle_1.0.3             nlme_3.1-157               
[142] jsonlite_1.8.4              viridisLite_0.4.1           limma_3.54.2               
[145] fansi_1.0.4                 pillar_1.8.1                lattice_0.20-45            
[148] loo_2.6.0                   fastmap_1.1.1               httr_1.4.5                 
[151] pkgbuild_1.4.0              survival_3.3-1              glue_1.6.2                 
[154] iterators_1.0.14            png_0.1-8                   stringi_1.7.12             
[157] irlba_2.3.5.1               future.apply_1.10.0

I have attached the data used to produce this error.

Let me know if I can provide any more information. Thank you!

pbmc_complex.rds.zip

@william-hutchison
Copy link
Collaborator Author

I just encountered an open issue in Seurat which could be related: satijalab/seurat#6462

@stemangiola
Copy link
Owner

Hello William,

would you like to tackle this issue?

@william-hutchison
Copy link
Collaborator Author

Hi Stefano,

Sure, I will investigate.

@stemangiola stemangiola added the bug Something isn't working label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants