stuart-lab / signac

R toolkit for the analysis of single-cell chromatin data
https://stuartlab.org/signac/
Other
316 stars 85 forks source link

FindTransferAnchors replacement error #1767

Closed fahmadimoughari closed 4 weeks ago

fahmadimoughari commented 4 weeks ago

Hi I am using FindTransferAnchors to label transfer from an scRNA obj to a Spatial-derived obj. But I get an error which I do not know the reason for it. Here is my code:

DefaultAssay(scrna) <- "RNA";
DefaultAssay(seu) <- "Spatial";

seu <- NormalizeData(seu, normalization.method = "LogNormalize");
# find 2k hvg
seu <- FindVariableFeatures(seu, selection.method = "vst", nfeatures = 2000)
# scale the data based on all genes, not just the hvg
all.genes <- rownames(seu);
seu <- ScaleData(seu, features = all.genes);

seu <- RunPCA(seu, verbose = T, seed.use = seed, npcs = 30);
features1 <- VariableFeatures(object = scrna);
features <- intersect(features1, rownames(seu));
cat("\n ", length(features1), "\t", length(features)); ### The output of this line is:  2000     1522
#find anchors for label transfer
anchors <- FindTransferAnchors(
    reference = scrna, query = seu, normalization.method = "LogNormalize",
    reference.assay = "RNA", query.assay = "Spatial", reduction = "pcaproject",
    features = features, k.filter = NA
);

The error is:

Error in `[<-.data.frame`(`*tmp*`, i[index], value = list(c(`AAACATGCAACACCTA-1` = 2993,  : 
  replacement element 1 has 3922 rows, need 6723

Here is the dimension of each obj:

> dim(scrna)
[1] 36601  3922
> dim(seu)
[1] 24919  2477
> "AAACATGCAACACCTA-1" %in% colnames(scrna)
[1] TRUE
> "AAACATGCAACACCTA-1" %in% colnames(seu)
[1] FALSE

I don't understand where does number 6723 come from in " replacement element 1 has 3922 rows, need 6723" error!

Here is the session info:

R version 4.1.0 (2021-05-18)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Rocky Linux 8.8 (Green Obsidian)

Matrix products: default
BLAS/LAPACK: /data/scratch/DBC/UBCN/BCRBIOIN/SHARED/software/conda_envs/R-4.1.0/lib/libopenblasp-r0.3.15.so

locale:
[1] C

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

other attached packages:
 [1] pracma_2.4.2                  FC14.genome.annotations_0.0.8
 [3] limma_3.50.1                  BCN.genesets.utilities_0.1.6 
 [5] fgsea_1.18.0                  png_0.1-7                    
 [7] FC14.genesets.DB_0.3.8        optparse_1.7.3               
 [9] ggplot2_3.3.5                 vegan_2.5-7                  
[11] lattice_0.20-45               permute_0.9-5                
[13] Signac_1.4.0                  FC14.plotting.lib_1.4.9      
[15] BCN.general.utilities_0.3.3   SeuratObject_4.1.3           
[17] Seurat_4.2.1                 

loaded via a namespace (and not attached):
  [1] fastmatch_1.1-3           plyr_1.8.7               
  [3] igraph_1.2.6              lazyeval_0.2.2           
  [5] sp_1.5-1                  splines_4.1.0            
  [7] BiocParallel_1.28.0       listenv_0.8.0            
  [9] scattermore_0.7           SnowballC_0.7.0          
 [11] GenomeInfoDb_1.28.4       digest_0.6.29            
 [13] htmltools_0.5.2           fansi_1.0.0              
 [15] memoise_2.0.1             magrittr_2.0.1           
 [17] tensor_1.5                cluster_2.1.2            
 [19] ROCR_1.0-11               globals_0.15.0           
 [21] Biostrings_2.62.0         matrixStats_0.61.0       
 [23] FC14.statistics.lib_0.1.2 docopt_0.7.1             
 [25] spatstat.sparse_3.0-0     colorspace_2.0-2         
 [27] blob_1.2.2                ggrepel_0.9.1            
 [29] dplyr_1.0.8               sparsesvd_0.2            
 [31] crayon_1.4.2              RCurl_1.98-1.6           
 [33] jsonlite_1.7.2            progressr_0.9.0          
 [35] spatstat.data_3.0-0       survival_3.2-13          
 [37] zoo_1.8-11                glue_1.6.2               
 [39] polyclip_1.10-0           gtable_0.3.0             
 [41] zlibbioc_1.40.0           XVector_0.34.0           
 [43] leiden_0.3.9              future.apply_1.8.1       
 [45] BiocGenerics_0.40.0       abind_1.4-5              
 [47] scales_1.1.1              DBI_1.1.2                
 [49] spatstat.random_3.0-1     miniUI_0.1.1.1           
 [51] Rcpp_1.0.7                viridisLite_0.4.0        
 [53] xtable_1.8-4              reticulate_1.25          
 [55] bit_4.0.4                 stats4_4.1.0             
 [57] getopt_1.20.3             htmlwidgets_1.5.4        
 [59] httr_1.4.2                RColorBrewer_1.1-3       
 [61] ellipsis_0.3.2            ica_1.0-2                
 [63] pkgconfig_2.0.3           farver_2.1.0             
 [65] ggseqlogo_0.1             uwot_0.1.14              
 [67] deldir_1.0-6              utf8_1.2.2               
 [69] AnnotationDbi_1.56.1      tidyselect_1.2.0         
 [71] rlang_1.0.6               reshape2_1.4.4           
 [73] later_1.2.0               cachem_1.0.6             
 [75] munsell_0.5.0             tools_4.1.0              
 [77] cli_3.4.1                 RSQLite_2.2.8            
 [79] generics_0.1.2            ggridges_0.5.3           
 [81] stringr_1.5.1             fastmap_1.1.0            
 [83] goftest_1.2-2             org.Hs.eg.db_3.13.0      
 [85] bit64_4.0.5               fitdistrplus_1.1-5       
 [87] purrr_0.3.4               RANN_2.6.1               
 [89] KEGGREST_1.34.0           pbapply_1.5-0            
 [91] future_1.25.0             nlme_3.1-152             
 [93] mime_0.12                 slam_0.1-50              
 [95] RcppRoll_0.3.0            compiler_4.1.0           
 [97] plotly_4.10.0             spatstat.utils_3.0-1     
 [99] tibble_3.1.8              tweenr_1.0.2             
[101] stringi_1.7.5             Matrix_1.5-3             
[103] vctrs_0.5.0               pillar_1.8.1             
[105] lifecycle_1.0.3           spatstat.geom_3.0-3      
[107] lmtest_0.9-38             RcppAnnoy_0.0.19         
[109] data.table_1.14.2         cowplot_1.1.1            
[111] bitops_1.0-7              irlba_2.3.5              
[113] httpuv_1.6.5              patchwork_1.1.1          
[115] GenomicRanges_1.46.1      R6_2.5.1                 
[117] promises_1.2.0.1          KernSmooth_2.23-20       
[119] gridExtra_2.3             lsa_0.73.2               
[121] IRanges_2.28.0            parallelly_1.31.1        
[123] codetools_0.2-18          MASS_7.3-58.1            
[125] assertthat_0.2.1          withr_2.5.0              
[127] qlcMatrix_0.9.7           sctransform_0.3.5        
[129] Rsamtools_2.8.0           S4Vectors_0.32.4         
[131] GenomeInfoDbData_1.2.7    mgcv_1.8-38              
[133] grid_4.1.0                tidyr_1.2.0              
[135] Rtsne_0.16                spatstat.explore_3.0-5   
[137] ggforce_0.3.3             Biobase_2.54.0           
[139] shiny_1.7.1              
timoast commented 4 weeks ago

Hi, please raise an issue in the Seurat github: https://github.com/satijalab/seurat