Alternatively, run SingleR as you are and label each cluster by the highest proportion of cell types within it. And then use the group.by parameter in your DimPlot call.
I'm trying to use SingleR to annotate UMAP plots in Seurat. I've been following this very helpful tutorial here (http://bioconductor.org/books/devel/SingleRBook/pancreas-case-study.html) and I see that SingleR can be used to annotate clusters in Scran but I haven't been able to figure out how to do the same thing in Seurat. Would someone be able to help me do it? I've pasted a portion of my code below to give a sense of what I want to achieve and what I have been trying.
library(Seurat)
library(DropletUtils)
library(SingleR)
library(celldex)
# Write seurat_integrated to 10X file
write10xCounts(x=seurat_integrated@assays$RNA@counts, path='seurat_integrated_10
X/')
# Annotate with SingleR
new.data <- Read10X("seurat_integrated_10X")
ref.data <- MouseRNAseqData()
predictions <- SingleR(test=new.data, assay.type.test="integrated",
ref=ref.data, labels=ref.data$label.main,
de.method="wilcox")
table(predictions$labels)
# Annotate UMAP clusters
seurat_integrated$celltypes <- predictions$pruned.labels
DimPlot(dummy_seurat_integrated, reduction="umap", split.by="celltypes")
I've had trouble pasting it in here but in the link, there is a SingleR-labelled TSNE plot achieved using Scran. I'm trying to do the same thing, but using Seurat.
1 answer
Provide the clusters parameter to your SingleR call and basically proceed as you've shown. I'd recommend reading the SingleR function documentation, i.e. ?SingleR from within R.
Or alternatively complement the UMAP with a stacked barplot that shows the percent of cells per cluster being assigned to a particular label. That sometimes can be informative when labels are very similar.
Log in to answer this question.
What exactly is the question? SingleR is agnostic in the sense that it only needs a reference expression matrix, marker genes and then the count matrix that you want to annotate against, and returns the most similar label per cell (so per column of your count matrix). So what do you mean by "in Seurat"? Is it extracting the counts from the object? See
Data Accessin https://satijalab.org/seurat/articles/essential_commands.html@ATpoint thanks for your comment, my question isn't so much about labelling cells or extracting the counts from the object. It's more about labelling clusters, and then showing those labels in a Seurat plot (for example, in a Seurat DimPlot()). Please let me know if I can clarify anything else!