trying to add SingleR label to Seurat Object fails
1
0
Entering edit mode
Assa Yeroslaviz ★ 1.5k
@assa-yeroslaviz-1597
Last seen 3 months ago
Germany

I previously worked with SingleR and Seurat to annotate my clusters. I have followed the workflow stated here and it all worked fine.

The Seurat object is already scaled and normalized.

Now, when trying to do it again, with the same data set,:

sce <- as.SingleCellExperiment(seurat_starsolo)
ref <- cells_highquality_ovary.sce
pred <- SingleR(test=sce, ref=ref, labels=ref$ident, method = "wilcox", clusters = colData(sce)$ident)

seurat_starsolo[["SingleR.labels"]] <- pred$labels

it throws an error:

Error: Cannot add more or fewer cell meta.data information without values being named with cell names

I don't understand why it's not working no, that I haven't change anything.

any help would be appreciated.

SingleR Seurat • 742 views
ADD COMMENT
1
Entering edit mode
Assa Yeroslaviz ★ 1.5k
@assa-yeroslaviz-1597
Last seen 3 months ago
Germany

I have found the problem, but this still doesn't explain the behaviour or the present error.

The clusters arguments says: A character vector or factor of cluster identities for each cell in test. If set, annotation is performed on the aggregated cluster profiles, otherwise it defaults to per-cell annotation.

This makes the analysis much faster, but yields a data frame with one row for each level of clusters. As I have 32 clusters in my original Seurat object, it outputs a data frame with 32 rows. Now the problem is to map these labels back to my Seurat object.

ADD COMMENT
0
Entering edit mode

I have found the problem, but this still doesn't explain the behaviour or the present error.

Yes, it does explain the problem. You have a vector with 32 values and try to feed that into an object that is much longer. This is a simple matching problem so you need some sort of join operation to give the label per cluster to every cell in your sce that belongs to this cluster. Many base R ways to do this, but that's not a Bioconductor issue.

ADD REPLY

Login before adding your answer.

Traffic: 510 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6