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

RunAzimuth error: Error in idx[i, ] <- res[[i]][[1]] #144

Open
dy-lin opened this issue Mar 31, 2023 · 7 comments
Open

RunAzimuth error: Error in idx[i, ] <- res[[i]][[1]] #144

dy-lin opened this issue Mar 31, 2023 · 7 comments

Comments

@dy-lin
Copy link

dy-lin commented Mar 31, 2023

When using RunAzimuth:

DefaultAssay(obj) <- "RNA"
obj <- RunAzimuth(
    obj,
    reference = "bonemarrowref",
    assay = "RNA",
    umap.name = "umap.bonemarrowref",
    verbose = TRUE
)

I get:

An AzimuthData object - reference version: 1.0.0 
Contains 2 meta.data field(s) to transfer.
...
Projecting reference PCA onto query
Finding integration vector weights
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Projecting back the query cells into original PCA space
Finding integration vector weights
Error in idx[i, ] <- res[[i]][[1]] : 
  number of items to replace is not a multiple of replacement length

Following other issues,

I've tried reducing the k.weight value and the error persists.

Would tweaking the other parameters like n.trees or mapping.score.k help?

RunAzimuth(
  query,
  reference,
  annotation.levels = NULL,
  umap.name = "ref.umap",
  do.adt = FALSE,
  verbose = TRUE,
  assay = "RNA",
  k.weight = 50,
  n.trees = 20,
  mapping.score.k = 100
)
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /gsc/software/linux-x86_64-centos7/R-4.1.3/lib64/R/lib/libRblas.so
LAPACK: /gsc/software/linux-x86_64-centos7/R-4.1.3/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               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] Azimuth_0.4.5      shinyBS_0.61.1     digest_0.6.29      forcats_0.5.1      stringr_1.4.0      dplyr_1.0.10      
 [7] purrr_0.3.5        readr_2.1.2        tidyr_1.2.0        tibble_3.1.8       ggplot2_3.3.6      tidyverse_1.3.1   
[13] glue_1.6.2         lubridate_1.8.0    Signac_1.7.0       sp_1.5-0           SeuratObject_4.1.0 Seurat_4.1.1      

loaded via a namespace (and not attached):
  [1] shinydashboard_0.7.2           utf8_1.2.2                     R.utils_2.12.0                
  [4] reticulate_1.25                tidyselect_1.1.2               AnnotationDbi_1.56.2          
  [7] poweRlaw_0.70.6                RSQLite_2.2.14                 htmlwidgets_1.5.4             
 [10] grid_4.1.3                     BiocParallel_1.28.3            Rtsne_0.16                    
 [13] munsell_0.5.0                  codetools_0.2-18               ica_1.0-3                     
 [16] DT_0.23                        future_1.27.0                  miniUI_0.1.1.1                
 [19] withr_2.5.0                    spatstat.random_2.2-0          colorspace_2.0-3              
 [22] progressr_0.10.1               Biobase_2.54.0                 knitr_1.39                    
 [25] rstudioapi_0.13                stats4_4.1.3                   SingleCellExperiment_1.16.0   
 [28] ROCR_1.0-11                    tensor_1.5                     bmcite.SeuratData_0.3.0       
 [31] listenv_0.8.0                  MatrixGenerics_1.6.0           GenomeInfoDbData_1.2.7        
 [34] polyclip_1.10-0                bit64_4.0.5                    parallelly_1.32.1             
 [37] vctrs_0.4.1                    generics_0.1.3                 xfun_0.31                     
 [40] R6_2.5.1                       GenomeInfoDb_1.30.1            hdf5r_1.3.5                   
 [43] bitops_1.0-7                   spatstat.utils_2.3-1           cachem_1.0.6                  
 [46] DelayedArray_0.20.0            assertthat_0.2.1               BiocIO_1.4.0                  
 [49] promises_1.2.0.1               scales_1.2.0                   googlesheets4_1.0.0           
 [52] rgeos_0.5-9                    gtable_0.3.0                   globals_0.16.0                
 [55] goftest_1.2-3                  seqLogo_1.60.0                 rlang_1.0.6                   
 [58] RcppRoll_0.3.0                 splines_4.1.3                  rtracklayer_1.54.0            
 [61] lazyeval_0.2.2                 gargle_1.2.0                   plyranges_1.14.0              
 [64] spatstat.geom_2.4-0            broom_0.8.0                    yaml_2.3.6                    
 [67] reshape2_1.4.4                 abind_1.4-5                    modelr_0.1.8                  
 [70] backports_1.4.1                httpuv_1.6.5                   SeuratDisk_0.0.0.9020         
 [73] tools_4.1.3                    SeuratData_0.2.2               nabor_0.5.0                   
 [76] ellipsis_0.3.2                 spatstat.core_2.4-4            RColorBrewer_1.1-3            
 [79] bonemarrowref.SeuratData_1.0.0 BiocGenerics_0.40.0            ggridges_0.5.3                
 [82] Rcpp_1.0.9                     plyr_1.8.7                     zlibbioc_1.40.0               
 [85] RCurl_1.98-1.7                 rpart_4.1.16                   deldir_1.0-6                  
 [88] pbapply_1.5-0                  cowplot_1.1.1                  S4Vectors_0.32.4              
 [91] zoo_1.8-10                     SummarizedExperiment_1.24.0    haven_2.5.0                   
 [94] ggrepel_0.9.1                  cluster_2.1.3                  fs_1.5.2                      
 [97] magrittr_2.0.3                 data.table_1.14.2              scattermore_0.8               
[100] lmtest_0.9-40                  reprex_2.0.1                   RANN_2.6.1                    
[103] googledrive_2.0.0              fitdistrplus_1.1-8             matrixStats_0.62.0            
[106] shinyjs_2.1.0                  evaluate_0.15                  hms_1.1.1                     
[109] patchwork_1.1.1                mime_0.12                      xtable_1.8-4                  
[112] XML_3.99-0.10                  readxl_1.4.0                   IRanges_2.28.0                
[115] gridExtra_2.3                  compiler_4.1.3                 KernSmooth_2.23-20            
[118] crayon_1.5.1                   R.oo_1.25.0                    htmltools_0.5.3               
[121] mgcv_1.8-40                    later_1.3.0                    tzdb_0.3.0                    
[124] TFBSTools_1.32.0               DBI_1.1.3                      dbplyr_2.2.1                  
[127] rappdirs_0.3.3                 MASS_7.3-57                    Matrix_1.4-1                  
[130] cli_3.4.1                      R.methodsS3_1.8.2              parallel_4.1.3                
[133] igraph_1.3.2                   GenomicRanges_1.46.1           pkgconfig_2.0.3               
[136] GenomicAlignments_1.30.0       TFMPvalue_0.0.8                plotly_4.10.0                 
[139] spatstat.sparse_2.1-1          xml2_1.3.3                     annotate_1.72.0               
[142] DirichletMultinomial_1.36.0    XVector_0.34.0                 rvest_1.0.2                   
[145] pracma_2.3.8                   sctransform_0.3.3              RcppAnnoy_0.0.19              
[148] CNEr_1.30.0                    spatstat.data_2.2-0            Biostrings_2.62.0             
[151] rmarkdown_2.19                 cellranger_1.1.0               leiden_0.4.2                  
[154] fastmatch_1.1-3                uwot_0.1.11                    curl_4.3.2                    
[157] restfulr_0.0.15                shiny_1.7.2                    Rsamtools_2.10.0              
[160] gtools_3.9.2.2                 rjson_0.2.21                   lifecycle_1.0.1               
[163] nlme_3.1-158                   jsonlite_1.8.0                 BSgenome_1.62.0               
[166] viridisLite_0.4.0              fansi_1.0.3                    pillar_1.8.1                  
[169] lattice_0.20-45                GO.db_3.14.0                   KEGGREST_1.34.0               
[172] fastmap_1.1.0                  httr_1.4.3                     survival_3.3-1                
[175] png_0.1-7                      bit_4.0.4                      presto_1.0.0                  
[178] stringi_1.7.8                  blob_1.2.3                     caTools_1.18.2                
[181] memoise_2.0.1                  irlba_2.3.5                    future.apply_1.9.0   
@Gesmira
Copy link
Collaborator

Gesmira commented Apr 18, 2023

Hi, what does your query object look like (how many cells/features)?

@dy-lin
Copy link
Author

dy-lin commented Apr 21, 2023

There are 15,015 features and 1,144 cells.

@FerrenaAlexander
Copy link

Hi all, same issue here. 20179 genes by 3965 cells. Thank you for all your work.

@Gesmira
Copy link
Collaborator

Gesmira commented Jan 5, 2024

Hi,
Sorry for the late response. Did you try lowering the mapping.score.k parameter? Generally, this should be lower than the number of cells. You have more cells than the mapping.score.k default of 100, but could be worth trying in the meantime as well.

@tirk999
Copy link

tirk999 commented Jan 22, 2024

Hi, Sorry for the late response. Did you try lowering the mapping.score.k parameter? Generally, this should be lower than the number of cells. You have more cells than the mapping.score.k default of 100, but could be worth trying in the meantime as well.

Hello, I am having the same error as the author of the post. I have 70 cells and about 28000 genes. Is there a way to make Azimuth work with such a small dataset (in terms of number of cells)? Thank you. I have Seurat 4 and Azimuth 0.4.5

@Gesmira
Copy link
Collaborator

Gesmira commented Jan 22, 2024

Hi, did you try lowering the k.weight and mapping.score.k parameters? The mapping.score.k default of 100 is more than the number of cells you have.

@tirk999
Copy link

tirk999 commented Jan 22, 2024

Hi, did you try lowering the k.weight and mapping.score.k parameters? The mapping.score.k default of 100 is more than the number of cells you have.

Hi! Yes, I lowered both in order to have k.weight < number of cells and mapping.score.k < number of cells. The problem is that at some point it seems like mapping.score.k gets reset to 100.
I get:

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
Using reference SCTModel to calculate pearson residuals
Determine variable features
Setting min_variance to:  -Inf
Calculating residuals of type pearson for 2882 genes
  |=================================================================================| 100%
  |=================================================================================| 100%
Set default assay to refAssay
Normalizing query using reference SCT model
Projecting cell embeddings
Finding query neighbors
Finding neighborhoods
Finding anchors
	Found 244 anchors
Finding integration vectors
Finding integration vector weights
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Predicting cell labels
Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from predictionscorecelltype.l2_ to predictionscorecelltypel2_
Predicting cell labels
Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from predictionscorecelltype.l1_ to predictionscorecelltypel1_
  |                                                  | 0 % ~calculating  
Integrating dataset 2 with reference dataset
Finding integration vectors
Integrating data
Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from integrated_dr_ to integrateddr_
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=06s  
Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from integrated_dr_ to integrateddr_
Computing nearest neighbors
Running UMAP projection
19:00:25 Read 70 rows
19:00:25 Processing block 1 of 1
19:00:25 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 20
19:00:25 Initializing by weighted average of neighbor coordinates using 1 thread
19:00:25 Commencing optimization for 67 epochs, with 1400 positive edges
Using method 'umap'
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
19:00:25 Finished
Recomputing query neighborhoods.
**Setting mapping.score.k in FindTransferAnchors to the ksmooth 
value here (100)**, can bypass this calculation in future runs.
Projecting reference PCA onto query
Finding integration vector weights
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Projecting back the query cells into original PCA space
Finding integration vector weights
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Computing scores:
    Finding neighbors of original query cells
    Finding neighbors of transformed query cells
Error in idx[i, ] <- res[[i]][[1]] : 

Thank you a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants