add patient information to the metadata or Make New Orig.ident in seurat object
1
0
Entering edit mode
3.0 years ago
Maria17 ▴ 40

Hi All,

I'm working on single-cell RNA seq data with the Seurat package. I need to change the orig.ident to patient numbers and cluster according to patient number.

row names in my data are = 111_DC.C001 , and 111 is Patient number.

I don't know how can I add the patient number to my metadata or how I grep 111 and add in orig.ident or making new orig.ident to plot according to patient number.

Any Recommendation or solution would be appreciated.

Maria

R RNA-SEQ Seurat • 4.7k views
ADD COMMENT
3
Entering edit mode
3.0 years ago
fracarb8 ★ 1.6k

You can use strsplit to extract the first entry before the _

 metadata <- seurat_object@meta.data
 metadata$orig.ident <-  unlist(strsplit(rownames(metadata),"_"))[1]   # split by "_" and select the first element

I would suggest to keep the original orig.ident column and create an additional clumn for your new identity. You can then use Idents() to select the new ones when you need that information

seurat_object@meta.data$PatientID <- unlist(strsplit(rownames(seurat_object@meta.data),"_"))[1]
ADD COMMENT

Login before adding your answer.

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