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

Problem with RunAzimuth : Error in index$getNNsbyVectorList(query[x,], k, search.k, include.distance) : fv.size() != vector_size #136

Closed
denizff opened this issue Feb 20, 2023 · 2 comments

Comments

@denizff
Copy link

denizff commented Feb 20, 2023

Hi,

First of all, thank you very much for this package. It helps me a lot in my work.

I had a problem recently with RunAzimuth() when I used a reference of my own.
My ref data has 30 PCs. I used the first 13 PCs to run FindNeighbors() and RunUmap()

Then I made a reference with still the first 13 PCs to get the same neighbors :

ref <- AzimuthReference(object = data,
refDR = "pca",
refAssay = "integrated",
refUMAP = "umap",
metadata = "clusters",
dims= 1:13)

After that, I used it with RunAzimuth :

options(Azimuth.map.ndims = 13)
query_projected <- RunAzimuth(query, "path_to_ref", do.adt = FALSE)

and I had the following error :

Error in index$getNNsbyVectorList(query[x,], k, search.k, include.distance) : fv.size() != vector_size

So I checked thourougly the code for RunAzimuth and I found out that the problem was with dims = 13 when I made the reference.
The neighbors were calculated with the first 13 PCs.
But in RunAzimuth code the dims variable takes as a value the length of the refDR which is 30 here :

dims <- as.double(length(slot(reference, "reductions")$refDR))

Because of that, there are errors in FindTransferAnchors and FindNeighbors where dims is set to 30 and not 13 the number of PCs used in the reference for FindNeighbors.

I runned RunAzmituh myself step by step by changing dims variable to 13 instead of 30 and it worked without errors.

I am not sure if it's better to set dims as follow : dims <- as.double(slot(reference, "neighbors")$refdr.annoy.neighbors@alg.info$ndim)
And change the following part :
query[["query_ref.nn"]] <- FindNeighbors(object = Embeddings(reference[["refDR"]][,1:dims],
query = Embeddings(reference[["refDR"]],
return.nghbor = TRUE,
l2.norm = TRUE,
verbose = F )

Best regards,

Deniz Fettahoglu

@denizff
Copy link
Author

denizff commented Feb 27, 2023

Sorry, I didn't write the changes correctly to make RunAzimuth work with a reference of my own :

dims <- as.double(slot(reference, "neighbors")$refdr.annoy.neighbors@alg.info$ndim)

query[["query_ref.nn"]] <- FindNeighbors(object = Embeddings(reference[["refDR"]])[,1:dims],
query = Embeddings(query[["integrated_dr"]]),
return.nghbor = TRUE,
l2.norm = TRUE,
verbose = F )

@Gesmira
Copy link
Collaborator

Gesmira commented Apr 19, 2023

Hi, thanks for bringing this up and providing a fix! This is now changed in the seurat5 branch of Azimuth and will be merged into the master branch soon. For details in installing seurat5 packages, see here: https://satijalab.org/seurat/articles/install.html

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

2 participants