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

Cannot create idx.annoy for mouse pansci reference Azimuth #248

Open
ruggerobelluomo opened this issue Nov 20, 2024 · 4 comments
Open

Cannot create idx.annoy for mouse pansci reference Azimuth #248

ruggerobelluomo opened this issue Nov 20, 2024 · 4 comments

Comments

@ruggerobelluomo
Copy link

Hi all,
I downloaded the mouse pansci reference object from here: https://zenodo.org/records/14042645
However, the annoy index is not present at this link so I tried to create it myself following a previous issue:
obj.azimuth=readRDS("C:/Users/rugge/Downloads/mouse_pansci/pansci_filtered.rds")
SaveAnnoyIndex(object = obj.azimuth[["refdr.annoy.neighbors"]], file = "C:/Users/rugge/Downloads/mouse_pansci//idx.annoy")
And got this error:
Error in obj.azimuth[["refdr.annoy.neighbors"]]:
! 'refdr.annoy.neighbors' not found in this Seurat object

Run rlang::last_trace() to see where the error occurred

Any help please? Thanks!

sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
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: Europe/Amsterdam
tzcode source: internal

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

other attached packages:
[1] SeuratData_0.2.2.9001 shiny_1.8.0 org.Mm.eg.db_3.17.0 AnnotationDbi_1.62.2
[5] harmony_1.2.0 Rcpp_1.0.11 clusterProfiler_4.8.3 SingleR_2.2.0
[9] scater_1.28.0 scran_1.28.2 scuttle_1.10.3 data.table_1.15.2
[13] reticulate_1.35.0 SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2 Biobase_2.60.0
[17] GenomicRanges_1.52.0 GenomeInfoDb_1.36.4 IRanges_2.34.1 S4Vectors_0.38.1
[21] BiocGenerics_0.46.0 MatrixGenerics_1.12.3 matrixStats_1.2.0 sctransform_0.4.1
[25] pheatmap_1.0.12 SeuratWrappers_0.3.1 cowplot_1.1.3 dplyr_1.1.4
[29] DoubletFinder_2.0.4 EnhancedVolcano_1.18.0 ggrepel_0.9.5 ggplot2_3.5.0
[33] Seurat_5.1.0 SeuratObject_5.0.2 sp_2.1-2 Azimuth_0.5.0
[37] shinyBS_0.61.1

loaded via a namespace (and not attached):
[1] R.methodsS3_1.8.2 progress_1.2.3 poweRlaw_0.80.0
[4] goftest_1.2-3 DT_0.32 Biostrings_2.68.1
[7] vctrs_0.6.5 spatstat.random_3.2-3 digest_0.6.33
[10] png_0.1-8 deldir_2.0-4 parallelly_1.37.0
[13] MASS_7.3-60 Signac_1.14.0 reshape2_1.4.4
[16] qvalue_2.32.0 httpuv_1.6.14 withr_3.0.2
[19] ggfun_0.1.4 ellipsis_0.3.2 survival_3.5-7
[22] EnsDb.Hsapiens.v86_2.99.0 memoise_2.0.1 ggbeeswarm_0.7.2
[25] gson_0.1.0 tidytree_0.4.6 zoo_1.8-12
[28] gtools_3.9.5 pbapply_1.7-2 R.oo_1.26.0
[31] prettyunits_1.2.0 KEGGREST_1.40.1 promises_1.2.1
[34] httr_1.4.7 downloader_0.4 restfulr_0.0.15
[37] globals_0.16.3 fitdistrplus_1.1-11 rhdf5filters_1.12.1
[40] ps_1.7.6 rhdf5_2.44.0 rstudioapi_0.15.0
[43] DOSE_3.26.2 miniUI_0.1.1.1 generics_0.1.3
[46] processx_3.8.4 curl_5.2.1 zlibbioc_1.46.0
[49] ggraph_2.2.1 ScaledMatrix_1.8.1 polyclip_1.10-6
[52] GenomeInfoDbData_1.2.10 xtable_1.8-4 stringr_1.5.1
[55] desc_1.4.3 pracma_2.4.4 S4Arrays_1.0.6
[58] BiocFileCache_2.8.0 hms_1.1.3 irlba_2.3.5.1
[61] colorspace_2.1-0 filelock_1.0.3 hdf5r_1.3.10
[64] ROCR_1.0-11 readxl_1.4.3 spatstat.data_3.0-4
[67] magrittr_2.0.3 lmtest_0.9-40 readr_2.1.5
[70] ggtree_3.8.2 viridis_0.6.5 later_1.3.2
[73] lattice_0.21-9 spatstat.geom_3.2-9 future.apply_1.11.1
[76] shadowtext_0.1.3 scattermore_1.2 XML_3.99-0.16.1
[79] RcppAnnoy_0.0.22 pillar_1.9.0 nlme_3.1-163
[82] caTools_1.18.2 compiler_4.3.2 beachmat_2.16.0
[85] RSpectra_0.16-1 stringi_1.8.3 tensor_1.5
[88] GenomicAlignments_1.36.0 plyr_1.8.9 crayon_1.5.2
[91] abind_1.4-5 BiocIO_1.10.0 gridGraphics_0.5-1
[94] googledrive_2.1.1 loupeR_1.1.2 locfit_1.5-9.9
[97] graphlayouts_1.1.1 bit_4.0.5 fastmatch_1.1-4
[100] codetools_0.2-19 BiocSingular_1.16.0 bslib_0.6.1
[103] plotly_4.10.4 mime_0.12 splines_4.3.2
[106] fastDummies_1.7.3 dbplyr_2.3.4 sparseMatrixStats_1.12.2
[109] HDO.db_0.99.1 cellranger_1.1.0 blob_1.2.4
[112] utf8_1.2.4 seqLogo_1.66.0 AnnotationFilter_1.24.0
[115] fs_1.6.3 listenv_0.9.1 DelayedMatrixStats_1.22.6
[118] pkgbuild_1.4.4 ggplotify_0.1.2 tibble_3.2.1
[121] Matrix_1.6-4 callr_3.7.5 statmod_1.5.0
[124] tzdb_0.4.0 tweenr_2.0.3 pkgconfig_2.0.3
[127] tools_4.3.2 cachem_1.0.8 RSQLite_2.3.5
[130] viridisLite_0.4.2 DBI_1.2.2 fastmap_1.1.1
[133] scales_1.3.0 grid_4.3.2 ica_1.0-3
[136] shinydashboard_0.7.2 Rsamtools_2.16.0 sass_0.4.9
[139] patchwork_1.2.0 ggprism_1.0.4 BiocManager_1.30.22
[142] dotCall64_1.1-1 RANN_2.6.1 farver_2.1.1
[145] scatterpie_0.2.1 tidygraph_1.3.1 yaml_2.3.8
[148] rtracklayer_1.60.1 cli_3.6.1 purrr_1.0.2
[151] writexl_1.5.0 leiden_0.4.3.1 lifecycle_1.0.4
[154] uwot_0.1.16 presto_1.0.0 bluster_1.10.0
[157] BSgenome.Hsapiens.UCSC.hg38_1.4.5 BiocParallel_1.34.2 annotate_1.78.0
[160] gtable_0.3.4 rjson_0.2.21 ggridges_0.5.6
[163] progressr_0.14.0 ape_5.7-1 parallel_4.3.2
[166] limma_3.56.2 jsonlite_1.8.8 edgeR_3.42.4
[169] RcppHNSW_0.6.0 TFBSTools_1.38.0 bitops_1.0-7
[172] bit64_4.0.5 Rtsne_0.17 yulab.utils_0.1.4
[175] spatstat.utils_3.1-1 BiocNeighbors_1.18.0 CNEr_1.36.0
[178] jquerylib_0.1.4 metapod_1.8.0 GOSemSim_2.26.1
[181] dqrng_0.3.2 shinyjs_2.1.0 SeuratDisk_0.0.0.9020
[184] R.utils_2.12.3 lazyeval_0.2.2 enrichplot_1.20.3
[187] htmltools_0.5.7 GO.db_3.17.0 rappdirs_0.3.3
[190] ensembldb_2.24.1 glue_1.7.0 TFMPvalue_0.0.9
[193] spam_2.10-0 googlesheets4_1.1.1 XVector_0.40.0
[196] RCurl_1.98-1.14 treeio_1.24.3 BSgenome_1.68.0
[199] gridExtra_2.3 JASPAR2020_0.99.10 igraph_2.0.3
[202] R6_2.5.1 tidyr_1.3.1 RcppRoll_0.3.1
[205] GenomicFeatures_1.52.2 cluster_2.1.4 Rhdf5lib_1.22.1
[208] gargle_1.5.2 aplot_0.2.2 DirichletMultinomial_1.42.0
[211] vipor_0.4.7 DelayedArray_0.26.7 tidyselect_1.2.1
[214] ProtGenerics_1.32.0 ggforce_0.4.2 xml2_1.3.6
[217] future_1.33.1 rsvd_1.0.5 munsell_0.5.0
[220] KernSmooth_2.23-22 fgsea_1.26.0 htmlwidgets_1.6.4
[223] RColorBrewer_1.1-3 biomaRt_2.56.1 rlang_1.1.2
[226] spatstat.sparse_3.0-3 spatstat.explore_3.2-7 remotes_2.5.0
[229] fansi_1.0.6 beeswarm_0.4.0

@ieres-amgen
Copy link

I'm Interested in using the same reference object; I believe the annoy index needs to be calculated for it still. I used the below code I tried to piece together based off Azimuth reference building scripts, but those vary a lot and so I would certainly appreciate any insight from Azimuth authors themselves:

# Read in the data, set Idents, and run PCA + UMAP
reference_data <- readRDS("pansci_filtered.rds")
Idents(reference_data) <- "Sub_cell_type_organ"
reference_data <- SCTransform(reference_data, conserve.memory=TRUE, return.only.var.genes = FALSE) # SCTransform to take care of NormalizeData, FindVariableFeatures, and ScaleData
reference_data <- RunPCA(reference_data, npcs = 50) # RunPCA on the SCT residuals
reference_data <- RunUMAP(reference_data, dims=1:50, return.model = TRUE) # Build UMAP model
reference_data <- FindNeighbors(reference_data, dims=1:50) # Find neighbors

# Format object
azimuth.obj <- AzimuthReference(
  object = reference_data,
  refUMAP = "umap",
  refDR = "pca",
  refAssay = "SCT",
  metadata = c("Organ_name", "Main_cell_type", "Sub_cell_type", "Sub_cell_type_organ", "Lineage"),
  dims = 1:50,
  reference.version = "2.0.0"
)

ValidateAzimuthReference(azimuth.obj) #Validate proper reference creation

SaveAnnoyIndex(object=azimuth.obj[["refdr.annoy.neighbors"]], "idx.annoy")
saveRDS(azimuth.obj, "ref.Rds")

@ruggerobelluomo
Copy link
Author

@ieres-amgen Thanks for the reply! Do you think that I can subset only heart organ if I am only interested in creating a heart reference? ANd then chaning PCs for UMAP from 50 to maybe 20-30?
reference_data=subset(reference_data,Organ_name=="Heart")
reference_data <- SCTransform(reference_data, conserve.memory=TRUE, return.only.var.genes = FALSE) # SCTransform to take care of NormalizeData, FindVariableFeatures, and ScaleData
...
...

Thanks!

@ieres-amgen
Copy link

It seems reasonable to me! But please note I am not affiliated with Seurat/Azimuth in any way, so probably best to take direct advice on this from the package authors.

@ohsumit
Copy link

ohsumit commented Nov 23, 2024

Greetings, if there is any headway on getting a idx.annoy, I would be most interested in it too! Many thanks!

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

3 participants