This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Assigning multiple identities to seurat metadata

Hi all,

I want to assign multiple idents to my seurat object. In my case, I have scRNA data of "Normal" and patient ID "11251". So far, I assigned identity following disease stage(normal or disease) like

seu.obj <- CreateSeuratObject(counts = 11251_mtx, project = "Normal")

and I found that seu.obj has orig.ident column, with Normal. I want to assign patient ID to my seurat object. Object has 2 columns, first, column with Normal and second, column with patient ID like 11251. How can I do that?

Please help me, thanks to you all in advance.

single-cell seurat scrna-seq

1 answer

You can add as much column/metadata to a Seurat object as you want. There is a Seurat function AddMetaData as well as list-like notation for setting/accessing the metadata. For example the following will do the same thing for you:

# use Seurat function
meta <- rep('11251', times = length(seu.obj$orig.ident))
seu.obj <- AddMetaData(object = seu.obj, metadata = meta, col.name = 'patient_id')

# use alternate method
seu.obj[['patient_id']] <- meta

https://mojaveazure.github.io/seurat-object/reference/AddMetaData.html

Log in to answer this question.