Addmetadata to seurat obj
Dear all,
It is a bit of coding issue. I have Seurat obj seurat.obj.T and in the metadata, a column type contains three levels of arthritis " First arthritis", "Second arthritis" and "Osteoarthritis". I would like to create a another column called group based on the value of the type column by naming First arthritis" to ICI-arthritis and Second Arthritis to ICI-arthritis and Osteoarthritis still = Osteoarthritis. I tried the following codes, but error twice. Could you help check!
seurat.obj.T <- AddMetaData(object = seurat.obj.T, metadata = "group", data = ifelse(seurat_obj@meta.data$type %in% c("First arthritis", "Second arthritis"), "ICI-arthritis", "Osteoarthritis"))
or
seurat.obj.T$group <- ifelse(seurat.obj.T$type %in% c("First arthritis", "Second arthritis"), "ICI-arthritis", "Osteoarthritis")
seurat.obj.T <- AddMetaData(object = seurat.obj.T, metadata = "group")
Thanks in advance.
Kind Regards
• 1,237 views
•
link
0 answers
No answers yet.
Log in to answer this question.
You should include, or specify, the errors that you are getting.
I fixed it. in case anyone faced the same issue.
You can do something like below:-
Thanks you! Regards