This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I add new column into Metadata of Seurat.obj in Xenium analysis

I want to add a column containing cell type (ct) information into my Seurat object whether in Metadata or in ident type so i can colour plot them in my DIMplots. Following is the data frame (meta) i have. I am working with Xenium data. I tried doing

AddMetaData(object = xenium.obj, metadata = meta, col.name = 'cell.type')
Error in `[[<-`:
! None of the meta data requested was found in the data frame
Run `rlang::last_trace()` to see where the error occurred.

enter image description here

seurat xenium spatial transcriptomics

If your dataframe is named meta, this should work :

xenium.obj[rownames(meta), "cell.type"] <- meta[,"ct"]

0 answers

No answers yet.

Log in to answer this question.