SingleR Cluster-wise annotation
1
0
Entering edit mode
8 months ago
mvis1231 ▴ 90

Hi, I have been trying to use SingleR to annotate the cell type per cluster. I used my Seurat object from integration analysis and the code was:

ref <- ImmGenData()
pred <- SingleR(as.SingleCellExperiment(seurat.integrated), ref, labels=ref$label.main, clusters=Idents(seurat.integrated))

But, when I checked rownames(pred), it still showed the name of each cell, not the cluster ids that I input in the function. Also, when I checked with table(pred$labels), it also showed the number of a single cell per cell type.

Could anyone help me get the cluster-wise annotation results (the code above only provided me a single-cell wise annotation results)?

Any advice will be greatly appreciated. Thank you!

Seurat SingleR annotation scRNA-seq CellType • 994 views
ADD COMMENT
1
Entering edit mode
8 months ago

Can you show the output of head(pred)? Sounds like everything's in order, check out the data structures described in the vignette. pred is supposed to be a data.frame where the number of rows correspond to the number of cells in your test data set (seurat.integrated).

ADD COMMENT
0
Entering edit mode

Thanks Friederike for your reply! The output of head(pred) looks exactly same as you described. It's rowname is the cell barcode and it has 5 columns: scores, first.labels, tuning scores, labels, pruned. labels as described in the vignette. And I was wondering where the cluster information was saved in "pred." When I tried table(predicted=pred$labels, cluster=rownames(pred)), it showed each cell barcode because rownames(pred) was still the cell barcode and I assume it was supposed to be cluster ids... Do you see any problem here? I really appreciate your input..

ADD REPLY
0
Entering edit mode

The cluster IDs are part of the metadata of your Seurat object, I assume. SingleR simply gives you an additional entry for the metadata, i.e. for any given cell you now know which cell type it is most similar to. Just as you (presumably) know the cluster membership for any given cell. I don't typically interact with Seurat objects, so I can't tell you how to properly extract the cluster membership from your Seurat object, but that's essentially what you'll need to do if you want your table command to work.

ADD REPLY
0
Entering edit mode

Thanks once again, Friederike. I can extract the cluster membership from my Seurat object by running Idents(seurat.integrated), so I thought clusters=Idents(seurat.integrated) in SingleR function that I wrote in my post could do the job to create additional entry for the cluster membership in "pred." But, unfortunately, "pred" didn't have a column for the cluster membership after the run. Then, do you know what clusters=Idents(seurat.integrated) in SingleR function is supposed to do? I am confused now..

ADD REPLY
0
Entering edit mode

Hi, from the manual pages, it states:

clusters,   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

Further:

test,   A numeric matrix of single-cell expression values where rows are genes and
columns are cells. Alternatively, a SummarizedExperiment object containing
such a matrix

In your example, 'test' is as.SingleCellExperiment(seurat.integrated). Perhaps just pass the actual expression matrix. By passing a SingleCellExperiment, it may be overlooking whatever you have passed to clusters - not sure.

ADD REPLY

Login before adding your answer.

Traffic: 2597 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