Adding sample level Metadata #9588
Ezoorp
started this conversation in
Show and tell
Replies: 1 comment
-
You can store object-level metadata in the foo <- pbmc_small
Misc(foo, "Sample_name") <- "XYZ"
Misc(foo)
## $Sample_name
## [1] "XYZ"
foo@misc # Another way to access it
## $Sample_name
## [1] "XYZ"
Misc(foo, "healthy") <- TRUE
# Another way to append data
foo@misc <- append(foo@misc, list(taxa = c("Eukaryote", "Animal", "Vertebrate", "Mammal", "Primate", "Human")))
Misc(foo)
## $Sample_name
## [1] "XYZ"
##
## $healthy
## [1] TRUE
##
## $taxa
## [1] "Eukaryote" "Animal" "Vertebrate" "Mammal" "Primate" "Human" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was struggling to add metadata to each seurat object or sample. Usually I use
AddMetaData()
, but this adds the metadata to every cell, and I didn't want this. However, we can append new attributes just like appending to any other list:data_sample <- append(data_sample, setNames(c("XYZ"), c("Sample_name")))
Note that
data_sample$Sample_name <- "XYZ"
just creates a new metadata label assigned to all cells.Beta Was this translation helpful? Give feedback.
All reactions