-
Notifications
You must be signed in to change notification settings - Fork 915
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
MapQuery error in Seurat reference mapping #5257
Comments
Could you post |
Thanks in advance! |
HI, @ceegilllns
If it works, we can focus on the ProjectUMAP step. |
Hi yuhanH, I ran the code without setting
And as you may have expected, MapQuery projected pbmc3k data onto ref.spca.
|
Great. That means the error happen in the umap projection step. Could you have a try on the below steps?
|
I tried 'Seurat::NNHelper' but failed with following message:
uninstallation and reinstallation of Seurat did not resolve this problem. And the results are as follows:
|
Hello, I have the exact same issue that you have, same error message. I also have the same message with NNHelper (to run it I think you needed it to run I'm also using Seurat_4.0.5. Did you manage to find a solution ? |
hi @ceegilllns Hi, @pebonte
|
@yuhanH I have the same problem: #> Running UMAP projection
#> Error in check_graph(graph, n_vertices, n_neighbors): ncol(idx) == expected_cols is not TRUE and my code works if I remove Full code (using code from your tutorial: https://satijalab.org/seurat/articles/integration_mapping.html) library(tidyverse)
library(Seurat)
#> Registered S3 method overwritten by 'spatstat.geom':
#> method from
#> print.boxx cli
#> Attaching SeuratObject
library(SeuratData)
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> Warning in if (is.na(desc)) {: the condition has length > 1 and only the first
#> element will be used
#> ── Installed datasets ───────────────────────────────────── SeuratData v0.2.1 ──
#> ✓ panc8 3.0.2
#> ────────────────────────────────────── Key ─────────────────────────────────────
#> ✓ Dataset loaded successfully
#> > Dataset built with a newer version of Seurat than installed
#> ❓ Unknown version of Seurat installed
library(patchwork)
data("panc8") # InstallData("panc8")
dataset.list <- SplitObject(panc8, split.by = "tech")
dataset.list <- dataset.list[c("fluidigmc1", "smartseq2")]
for (i in 1:length(dataset.list)) {
dataset.list[[i]] <- NormalizeData(dataset.list[[i]], verbose = FALSE)
dataset.list[[i]] <- FindVariableFeatures(dataset.list[[i]], selection.method = "vst", nfeatures = 2000,
verbose = FALSE)
}
seurat_obj.query <- dataset.list[["fluidigmc1"]]
seurat_obj.ref <- dataset.list[["smartseq2"]]
seurat_obj.ref <- ScaleData(seurat_obj.ref, verbose = FALSE)
seurat_obj.ref <- RunPCA(seurat_obj.ref, npcs = 30, verbose = FALSE) # must run PCA before FindTransferAnchors()
anchors_obj <- FindTransferAnchors(reference = seurat_obj.ref,
query = seurat_obj.query,
dims = 1:30,
reference.reduction = "pca")
#> Projecting cell embeddings
#> Finding neighborhoods
#> Finding anchors
#> Found 770 anchors
#> Filtering anchors
#> Retained 732 anchors
seurat_obj.ref <- RunUMAP(seurat_obj.ref, dims = 1:30, reduction = "pca", return.model = TRUE)
#> Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric
#> To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation'
#> This message will be shown once per session
#> UMAP will return its model
#> 14:33:05 UMAP embedding parameters a = 0.9922 b = 1.112
#> 14:33:05 Read 2394 rows and found 30 numeric columns
#> 14:33:05 Using Annoy for neighbor search, n_neighbors = 30
#> 14:33:05 Building Annoy index with metric = cosine, n_trees = 50
#> 0% 10 20 30 40 50 60 70 80 90 100%
#> [----|----|----|----|----|----|----|----|----|----|
#> **************************************************|
#> 14:33:05 Writing NN index file to temp file /tmp/RtmpdyN2gw/file16db777cc3d44
#> 14:33:05 Searching Annoy index using 1 thread, search_k = 3000
#> 14:33:06 Annoy recall = 100%
#> 14:33:07 Commencing smooth kNN distance calibration using 1 thread
#> 14:33:07 Initializing from normalized Laplacian + noise
#> 14:33:07 Commencing optimization for 500 epochs, with 96376 positive edges
#> 14:33:11 Optimization finished
seurat_obj.query <- MapQuery(anchorset = anchors_obj,
reference = seurat_obj.ref,
query = seurat_obj.query,
refdata = list(celltype = "celltype"),
reference.reduction = "pca",
reduction.model = "umap")
#> Finding integration vectors
#> Finding integration vector weights
#> Predicting cell labels
#> Warning: Feature names cannot have underscores ('_'), replacing with dashes
#> ('-')
#> 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 ref.pca_ to refpca_
#> Warning: Keys should be one or more alphanumeric characters followed by an
#> underscore, setting key from ref.pca_ to refpca_
#> Warning: All keys should be one or more alphanumeric characters followed by an
#> underscore '_', setting key to refpca_
#> Computing nearest neighbors
#> Running UMAP projection
#> Error in check_graph(graph, n_vertices, n_neighbors): ncol(idx) == expected_cols is not TRUE Created on 2021-12-02 by the reprex package (v2.0.1) devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.1.0 (2021-05-18)
#> os Ubuntu 20.04.3 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Copenhagen
#> date 2021-12-02
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> ! package * version date lib source
#> P backports 1.2.1 2020-12-09 [?] standard (@1.2.1)
#> cachem 1.0.6 2021-08-19 [1] CRAN (R 4.1.0)
#> P callr 3.7.0 2021-04-20 [?] CRAN (R 4.1.0)
#> P cli 3.0.1 2021-07-17 [?] CRAN (R 4.1.0)
#> P crayon 1.4.1 2021-02-08 [?] CRAN (R 4.1.0)
#> P desc 1.4.0 2021-09-28 [?] CRAN (R 4.1.0)
#> P devtools 2.4.2 2021-06-07 [?] CRAN (R 4.1.0)
#> P digest 0.6.28 2021-09-23 [?] CRAN (R 4.1.0)
#> P ellipsis 0.3.2 2021-04-29 [?] CRAN (R 4.1.0)
#> P evaluate 0.14 2019-05-28 [?] standard (@0.14)
#> P fansi 0.5.0 2021-05-25 [?] CRAN (R 4.1.0)
#> P fastmap 1.1.0 2021-01-25 [?] CRAN (R 4.1.0)
#> P fs 1.5.0 2020-07-31 [?] standard (@1.5.0)
#> P glue 1.4.2 2020-08-27 [?] standard (@1.4.2)
#> P highr 0.9 2021-04-16 [?] CRAN (R 4.1.0)
#> P htmltools 0.5.2 2021-08-25 [?] CRAN (R 4.1.0)
#> P knitr 1.36 2021-09-29 [?] CRAN (R 4.1.0)
#> P lifecycle 1.0.1 2021-09-24 [?] CRAN (R 4.1.0)
#> P magrittr 2.0.1 2020-11-17 [?] standard (@2.0.1)
#> P memoise 2.0.0 2021-01-26 [?] CRAN (R 4.1.0)
#> P pillar 1.6.4 2021-10-18 [?] CRAN (R 4.1.0)
#> P pkgbuild 1.2.0 2020-12-15 [?] standard (@1.2.0)
#> P pkgconfig 2.0.3 2019-09-22 [?] standard (@2.0.3)
#> P pkgload 1.2.3 2021-10-13 [?] CRAN (R 4.1.0)
#> P prettyunits 1.1.1 2020-01-24 [?] standard (@1.1.1)
#> P processx 3.5.2 2021-04-30 [?] CRAN (R 4.1.0)
#> P ps 1.6.0 2021-02-28 [?] CRAN (R 4.1.0)
#> P purrr 0.3.4 2020-04-17 [?] standard (@0.3.4)
#> P R.cache 0.15.0 2021-04-30 [?] CRAN (R 4.1.0)
#> P R.methodsS3 1.8.1 2020-08-26 [?] CRAN (R 4.1.0)
#> P R.oo 1.24.0 2020-08-26 [?] CRAN (R 4.1.0)
#> P R.utils 2.11.0 2021-09-26 [?] CRAN (R 4.1.0)
#> P R6 2.5.1 2021-08-19 [?] CRAN (R 4.1.0)
#> P remotes 2.4.1 2021-09-29 [?] CRAN (R 4.1.0)
#> P reprex 2.0.1 2021-08-05 [?] CRAN (R 4.1.0)
#> P rlang 0.4.12 2021-10-18 [?] CRAN (R 4.1.0)
#> P rmarkdown 2.11 2021-09-14 [?] CRAN (R 4.1.0)
#> P rprojroot 2.0.2 2020-11-15 [?] standard (@2.0.2)
#> P rstudioapi 0.13 2020-11-12 [?] standard (@0.13)
#> P sessioninfo 1.1.1 2018-11-05 [?] CRAN (R 4.1.0)
#> P stringi 1.7.5 2021-10-04 [?] CRAN (R 4.1.0)
#> P stringr 1.4.0 2019-02-10 [?] standard (@1.4.0)
#> P styler 1.6.2 2021-09-23 [?] CRAN (R 4.1.0)
#> P testthat 3.1.0 2021-10-04 [?] CRAN (R 4.1.0)
#> P tibble 3.1.5 2021-09-30 [?] CRAN (R 4.1.0)
#> P usethis 2.1.2 2021-10-25 [?] CRAN (R 4.1.0)
#> P utf8 1.2.2 2021-07-24 [?] CRAN (R 4.1.0)
#> P vctrs 0.3.8 2021-04-29 [?] CRAN (R 4.1.0)
#> P withr 2.4.2 2021-04-18 [?] CRAN (R 4.1.0)
#> P xfun 0.27 2021-10-18 [?] CRAN (R 4.1.0)
#> P yaml 2.2.1 2020-02-01 [?] standard (@2.2.1)
#>
#> P ── Loaded and on-disk path mismatch. Created on 2021-12-02 by the reprex package (v2.0.1) |
Hi @yuhanH ,
By removing reduction.model it worked but it was projected onto the pca space. And with NNHelper from Seurat I had :
I was trying to repeat the error with the tutorial dataset and not my own dataset for you to be able to reproduce the error but @pascaltimshel actually did it. |
@yuhanH :
For
|
HI,
hi @pascaltimshel |
Hi @yuhanH, I also ran into the same issue as described above and just tried to install the previous version of uwot as you specified. session info for Seurat here (and uwot version 0.1.10 is loaded):
But I am running into this error instead when trying RunUMAP on the example data set (pancreas)
I will wait for the update for fixing the bug but if anyone knows what is going on with this and if there is an easy fix, I would really appreciate it! |
Hi @SammiLyu |
No problem!
|
Hi @SammiLyu |
Thanks for reporting this issue. This bug is fixed in seurat 4.0.6 |
I found reference mapping very useful in single cell analysis using Azimuth app.
To deal with large data, I tried MapQuery function but failed with the following error message,
When I tried TransferData, IntegrateEmbeddings, and ProjectUMAP (or RunUMAP after FindNeighbors) step by step, the error occured when running ProjectUMAP(or RunUMAP).
I also tried reference mapping using (copy-pasted) the example code provided in "Seurat Multimodal reference mapping example 1 (Mapping human peripheral blood cells)" but same error occurred. I used Seurat version 4.0.5 and downloaded most recent reference data.
Does anyone has any suggestions to fix the problem?
Here is the full message,
The text was updated successfully, but these errors were encountered: