satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.24k stars 902 forks source link

No anchors found when mapping annotations from reference to query datasets #9103

Open rcrueda opened 2 months ago

rcrueda commented 2 months ago

Hi I am trying to map the annotations of a reference scRNAseq dataset on to a new scRNAseq dataset.

Here is the pre processing of both the Reference and the Query datasets, which I integrate using harmony: seurat <- NormalizeData(seurat) seurat <- FindVariableFeatures(seurat) seurat <- ScaleData(seurat, vars.to.regress = c("S.Score", "G2M.Score","percent.mt")) seurat <- RunPCA(seurat) seurat <- RunHarmony(seurat, group.by.vars = c("Donor","Time"), lambda = c(1,200)) seurat <- RunUMAP(seurat, reduction = "harmony", dims = 1:20, seed.use = 1) seurat <- FindNeighbors(seurat,reduction = "harmony", dims = 1:20) seurat <- FindClusters(seurat,reduction = "harmony", resolution = 0.75, random.seed = 1)

Following the mapping vignette, the following code predicts the querry anotation quite well: anchors <- FindTransferAnchors( reference = seurat, query = sample, reference.reduction = "pca")

Projecting cell embeddings Finding neighborhoods Finding anchors Found 7286 anchors Filtering anchors Retained 1285 anchors

predictions <- TransferData(anchorset = anchors, refdata = seurat$seurat_clusters) sample$predicted.id <- predictions$predicted.id

My problem is that I have now subsampled the Reference dataset (to resolve better the cell types of interest) and after doing this the FindTransferAnchors is not able to find anchors anymore.

subset <- subset(seurat, Time == "T0") subset <- RunUMAP(subset, reduction = "harmony", dims = 1:20) subset <- FindNeighbors(subset,reduction = "harmony", dims = 1:20) subset <- FindClusters(subset,reduction = "harmony", resolution = 0.7)

anchors <- FindTransferAnchors( reference = subset, query = sample, reference.reduction = "pca")

Projecting cell embeddings Finding neighborhoods Finding anchors Found 25 anchors Filtering anchors Retained 0 anchors

Am I doing something wrong? I cant understand why it worked well the first time but after subsetting, the same type of Reference data (just with fewer cells) is unable to find anchors.

Thanks a lot!

zskylarli commented 1 month ago

Hi - I believe this is not necessarily a bug and more due to the data that you are now using. Have you made sure that your subsetted dataset has been normalized and scaled again from scratch?

rcrueda commented 1 month ago

Hi zskylarli,

Thanks a lot for your answer! Indeed normalizing and scaling the data after subsampling fixed this.

Best, Rocio