Renaming data in a Seurat object metadata

Viewed 40

I have a seurat object "gunion.data". The metadata for gunion.data@meta.data$orig.ident is either "control, "ischemia", "synIRI" or "alloIRI". I would like to change ""synIRI" and "alloIRI" into "other".

I tried this gunion.data@meta.data$orig.ident["alloIRI"] <- "other"

but it gave me an error: Error in $<-.data.frame(tmp, orig.ident, value = c("control", "control", : replacement has 26933 rows, data has 26932

How should I format the code to change all "alloIRI" and "synIRI" in the data into "other"?

1 Answers

What you want to do is rename an Ident. The below should work once you've changed your idents to 'orig.ident'.

Idents(gunion.data) <- 'orig.ident'
gunion.data <- RenameIdents(object = gunion.data, `synIRI` = "other", `alloIRI` = "other")

Idents(gunion.data) #to confirm the change has happened.

I would suggest you also have a look at the Seurat Essential commands, found here.

Please upvote the answer if this has solved your problem :)

Related