This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Trouble setting "ident" argument in FindMarkers in Seurat

I'm having trouble setting the FindMarkers function in Seurat to particular clusters in my dataset. I've tried this code and some variations of it several times but nothing seems to be working unfortunately:

DefaultAssay(seurat_integrated) <- "RNA"
cell.8.markers <- FindMarkers(seurat_integrated, ident.1=8, group.by="groups")
write.csv(cell.8.markers %>% group_by(cluster), 'cluster_8_markers_seurat_integrated_01072022.csv')
DefaultAssay(seurat_integrated) <- "integrated"

It returns this error:

Error in WhichCells.Seurat(object = object, idents = ident.1) : 
Cannot find the following identities in the object: 1

Could tell me why this might be happening? I have already put my data through an integration pipeline and I've heard that the FindMarkers function should be run on the "RNA" data instead of the "integrated," which is why I set the assay to "RNA" in the first line. From what I understand, it does seem that "8" is a cluster in my dataset:

> head(Idents(seurat_integrated), 5)
AAACCTGAGAGGGATA-1_1 AAACCTGAGCTTTGGT-1_1 AAACCTGAGGACAGAA-1_1 
                   1                    6                    1 
AAACCTGAGGATGCGT-1_1 AAACCTGAGTGAAGAG-1_1 
                  18                    6 
26 Levels: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 25

I hope this question isn't too simple, but would someone be able to help me with this?

seurat findmarkers

Did you try to run FindConservedMarker on the same cluster?

1 answer

You have to put the 8 in quotation marks so it should be

FindMarkers(seurat_integrated, ident.1="8", group.by="groups")

another possible problem is that the Identities have to be set to the correct metadata category that contains your cluster "8" so if that metdata column is named "clustering" there should be a line before like:

Idents(seurat_integrated) <- seurat_integrated@meta.data$clustering

I think the problem is the usage of group.by="groups". If you remove it, it will work. If you want to do the differential expression analysis between two conditions, then you should keep group.by="groups", then use ident.1="condition1", ident.2="condition2", and subset.ident=8. In this case, it will work, it will generate the differentially expressed genes in cluster 8 between condition 1 and condition 2.

Log in to answer this question.