satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.25k stars 904 forks source link

RunAzimuth ERROR: Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 't': non-conformable arrays #9193

Open aminards opened 1 month ago

aminards commented 1 month ago

I have 10X multiomics data and have generated a Seurat object. Next I want to run RunAzimuth on my Seurat Object however this fails with the error mentioned in the title of this report.

Here is the code I have run and any messages:

library(remotes)
library(Seurat)
library(Azimuth)
library(SeuratData)
library(tidyverse)
library("loupeR")
library(patchwork)

# Read 10x h5 file
ExpressionMatrix<-Read10X_h5("filtered_feature_bc_matrix.h5")
# Read aggr.csv
AggrCSV<-read.table("aggr.csv",sep=",",header = T)

index<-sapply(strsplit(colnames(ExpressionMatrix$`Gene Expression`),"-"),function(X){return(X[2])})
index<-as.numeric(index)
# Now we use this to access the metadata from the csv file
AggrCSV<-AggrCSV[index,]
# Add Barcode to metadata
rownames(AggrCSV)<-colnames(ExpressionMatrix$`Gene Expression`)
# Create Seurat Object
SeuratObject<-CreateSeuratObject(counts = ExpressionMatrix,meta.data = AggrCSV)
# Inspect the object to confirm that metadata was added appropriately
head(SeuratObject@meta.data)
                      orig.ident nCount_RNA nFeature_RNA                                library_id
AAACATGCAAAGCCTC-7 SeuratProject        648          597 Cell_Ranger_ARC_analysis_Sample_M2
AAACATGCAGACAAAC-4 SeuratProject        313          292 Cell_Ranger_ARC_analysis_Sample_C2
AAACCAACAAGTGTCC-8 SeuratProject        318          280 Cell_Ranger_ARC_analysis_Sample_H2
AAACCGCGTTGACTTC-4 SeuratProject        343          319 Cell_Ranger_ARC_analysis_Sample_C2
AAACCGGCACAGACTC-5 SeuratProject       1023          824 Cell_Ranger_ARC_analysis_Sample_21
AAACGCGCACGTGCTG-4 SeuratProject        341          319 Cell_Ranger_ARC_analysis_Sample_C2
                                                               atac_fragments
AAACATGCAAAGCCTC-7 b76c586c-ea6a-40e4-974c-3489e617e3ad/atac_fragments.tsv.gz
AAACATGCAGACAAAC-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/atac_fragments.tsv.gz
AAACCAACAAGTGTCC-8 a0de25e8-5c8a-437c-9691-dbc92aad5c8c/atac_fragments.tsv.gz
AAACCGCGTTGACTTC-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/atac_fragments.tsv.gz
AAACCGGCACAGACTC-5 8e6af46c-09a5-4c51-85b8-66415a25abf5/atac_fragments.tsv.gz
AAACGCGCACGTGCTG-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/atac_fragments.tsv.gz
                                                            per_barcode_metrics
AAACATGCAAAGCCTC-7 b76c586c-ea6a-40e4-974c-3489e617e3ad/per_barcode_metrics.csv
AAACATGCAGACAAAC-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/per_barcode_metrics.csv
AAACCAACAAGTGTCC-8 a0de25e8-5c8a-437c-9691-dbc92aad5c8c/per_barcode_metrics.csv
AAACCGCGTTGACTTC-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/per_barcode_metrics.csv
AAACCGGCACAGACTC-5 8e6af46c-09a5-4c51-85b8-66415a25abf5/per_barcode_metrics.csv
AAACGCGCACGTGCTG-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/per_barcode_metrics.csv
                                                           gex_molecule_info  condition
AAACATGCAAAGCCTC-7 b76c586c-ea6a-40e4-974c-3489e617e3ad/gex_molecule_info.h5      Mid_2
AAACATGCAGACAAAC-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/gex_molecule_info.h5 Clean_2
AAACCAACAAGTGTCC-8 a0de25e8-5c8a-437c-9691-dbc92aad5c8c/gex_molecule_info.h5     High_2
AAACCGCGTTGACTTC-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/gex_molecule_info.h5 Clean_2
AAACCGGCACAGACTC-5 8e6af46c-09a5-4c51-85b8-66415a25abf5/gex_molecule_info.h5      Low_2
AAACGCGCACGTGCTG-4 fd4af269-1ba0-4a4c-8619-b89fb1634daf/gex_molecule_info.h5 Clean_2

# RunAzimuth
options(future.globals.maxSize= 891289600)
Prediction<-RunAzimuth(SeuratObject, "lungref")

Warning: Overwriting miscellanous data for model
Warning: Adding a dimensional reduction (refUMAP) without the associated assay being present
detected inputs from HUMAN with id type Gene.name
reference rownames detected HUMAN with id type Gene.name
Normalizing query using reference SCT model
Warning: No layers found matching search pattern provided
Warning: 192 features of the features specified were not present in both the reference query assays. 
Continuing with remaining 2808 features.
Projecting cell embeddings
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 't': non-conformable arrays

> SeuratObject[["RNA"]] <- JoinLayers(SeuratObject)
Error in `[<-.data.frame`(`*tmp*`, , i, value = new("Seurat", assays = list( : 
  replacement has 84438 rows, data has 3914

Here is my session info:

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

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/New_York
tzcode source: internal

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

other attached packages:
 [1] patchwork_1.2.0          loupeR_1.1.1             lubridate_1.9.3          forcats_1.0.0            stringr_1.5.1           
 [6] dplyr_1.1.4              purrr_1.0.2              readr_2.1.5              tidyr_1.3.1              tibble_3.2.1            
[11] ggplot2_3.5.1            tidyverse_2.0.0          lungref.SeuratData_2.0.0 SeuratData_0.2.2.9001    Azimuth_0.5.0           
[16] shinyBS_0.61.1           Seurat_5.1.0             SeuratObject_5.0.2       sp_2.1-4                 remotes_2.5.0           

loaded via a namespace (and not attached):
  [1] fs_1.6.4                          ProtGenerics_1.36.0               matrixStats_1.3.0                
  [4] spatstat.sparse_3.1-0             bitops_1.0-8                      DirichletMultinomial_1.46.0      
  [7] TFBSTools_1.42.0                  httr_1.4.7                        RColorBrewer_1.1-3               
 [10] tools_4.4.1                       sctransform_0.4.1                 utf8_1.2.4                       
 [13] R6_2.5.1                          DT_0.33                           lazyeval_0.2.2                   
 [16] uwot_0.2.2                        rhdf5filters_1.16.0               withr_3.0.0                      
 [19] gridExtra_2.3                     progressr_0.14.0                  cli_3.6.3                        
 [22] Biobase_2.64.0                    spatstat.explore_3.3-1            fastDummies_1.7.3                
 [25] EnsDb.Hsapiens.v86_2.99.0         shinyjs_2.1.0                     spatstat.data_3.1-2              
 [28] ggridges_0.5.6                    pbapply_1.7-2                     Rsamtools_2.20.0                 
 [31] R.utils_2.12.3                    parallelly_1.38.0                 BSgenome_1.72.0                  
 [34] rstudioapi_0.16.0                 RSQLite_2.3.7                     generics_0.1.3                   
 [37] BiocIO_1.14.0                     gtools_3.9.5                      ica_1.0-3                        
 [40] spatstat.random_3.3-1             googlesheets4_1.1.1               GO.db_3.19.1                     
 [43] Matrix_1.7-0                      fansi_1.0.6                       S4Vectors_0.42.1                 
 [46] abind_1.4-5                       R.methodsS3_1.8.2                 lifecycle_1.0.4                  
 [49] yaml_2.3.10                       SummarizedExperiment_1.34.0       BiocFileCache_2.12.0             
 [52] rhdf5_2.48.0                      SparseArray_1.4.8                 Rtsne_0.17                       
 [55] grid_4.4.1                        blob_1.2.4                        promises_1.3.0                   
 [58] ExperimentHub_2.12.0              shinydashboard_0.7.2              crayon_1.5.3                     
 [61] pwalign_1.0.0                     miniUI_0.1.1.1                    lattice_0.22-6                   
 [64] cowplot_1.1.3                     GenomicFeatures_1.56.0            annotate_1.82.0                  
 [67] KEGGREST_1.44.1                   pillar_1.9.0                      GenomicRanges_1.56.1             
 [70] rjson_0.2.21                      future.apply_1.11.2               codetools_0.2-20                 
 [73] fastmatch_1.1-4                   leiden_0.4.3.1                    glue_1.7.0                       
 [76] spatstat.univar_3.0-0             data.table_1.15.4                 vctrs_0.6.5                      
 [79] png_0.1-8                         spam_2.10-0                       cellranger_1.1.0                 
 [82] gtable_0.3.5                      poweRlaw_0.80.0                   cachem_1.1.0                     
 [85] Signac_1.13.0                     S4Arrays_1.4.1                    mime_0.12                        
 [88] pracma_2.4.4                      survival_3.6-4                    gargle_1.5.2                     
 [91] RcppRoll_0.3.1                    fitdistrplus_1.2-1                ROCR_1.0-11                      
 [94] nlme_3.1-164                      bit64_4.0.5                       filelock_1.0.3                   
 [97] RcppAnnoy_0.0.22                  GenomeInfoDb_1.40.1               irlba_2.3.5.1                    
[100] KernSmooth_2.23-24                SeuratDisk_0.0.0.9021             colorspace_2.1-1                 
[103] seqLogo_1.70.0                    BiocGenerics_0.50.0               DBI_1.2.3                        
[106] tidyselect_1.2.1                  bit_4.0.5                         compiler_4.4.1                   
[109] curl_5.2.1                        hdf5r_1.3.11                      DelayedArray_0.30.1              
[112] plotly_4.10.4                     rtracklayer_1.64.0                scales_1.3.0                     
[115] caTools_1.18.2                    lmtest_0.9-40                     rappdirs_0.3.3                   
[118] digest_0.6.36                     goftest_1.2-3                     spatstat.utils_3.0-5             
[121] presto_1.0.0                      XVector_0.44.0                    htmltools_0.5.8.1                
[124] pkgconfig_2.0.3                   MatrixGenerics_1.16.0             dbplyr_2.5.0                     
[127] fastmap_1.2.0                     ensembldb_2.28.0                  rlang_1.1.4                      
[130] htmlwidgets_1.6.4                 UCSC.utils_1.0.0                  shiny_1.9.0                      
[133] zoo_1.8-12                        jsonlite_1.8.8                    BiocParallel_1.38.0              
[136] R.oo_1.26.0                       RCurl_1.98-1.16                   magrittr_2.0.3                   
[139] GenomeInfoDbData_1.2.12           dotCall64_1.1-1                   Rhdf5lib_1.26.0                  
[142] munsell_0.5.1                     Rcpp_1.0.13                       reticulate_1.38.0                
[145] stringi_1.8.4                     zlibbioc_1.50.0                   MASS_7.3-60.2                    
[148] AnnotationHub_3.12.0              plyr_1.8.9                        parallel_4.4.1                   
[151] listenv_0.9.1                     ggrepel_0.9.5                     deldir_2.0-4                     
[154] CNEr_1.40.0                       Biostrings_2.72.1                 splines_4.4.1                    
[157] tensor_1.5                        hms_1.1.3                         BSgenome.Hsapiens.UCSC.hg38_1.4.5
[160] igraph_2.0.3                      spatstat.geom_3.3-2               RcppHNSW_0.6.0                   
[163] reshape2_1.4.4                    stats4_4.4.1                      TFMPvalue_0.0.9                  
[166] BiocVersion_3.19.1                XML_3.99-0.17                     BiocManager_1.30.23              
[169] JASPAR2020_0.99.10                tzdb_0.4.0                        httpuv_1.6.15                    
[172] RANN_2.6.1                        polyclip_1.10-7                   future_1.34.0                    
[175] scattermore_1.2                   xtable_1.8-4                      restfulr_0.0.15                  
[178] AnnotationFilter_1.28.0           RSpectra_0.16-2                   later_1.3.2                      
[181] viridisLite_0.4.2                 googledrive_2.1.1                 memoise_2.0.1                    
[184] AnnotationDbi_1.66.0              GenomicAlignments_1.40.0          IRanges_2.38.1                   
[187] cluster_2.1.6                     timechange_0.3.0                  globals_0.16.3  

How can I resolve this error?

ieres-amgen commented 1 week ago

I encountered the same error, but then found it was resolved when I ran JoinLayers() on my Seurat object after the initial merge, before executing RunAzimuth(). From what you shared here it looks like JoinLayers() failed, but perhaps it would work if run beforehand (without any subsetting/indexing, so just "seur_obj <- JoinLayers(seur_obj)". Hope this helps!