I have a Seurat single-cell gene expression object, which has slots.
One of the slots is @meta.data
, which is a matrix.
I'd like to create a column $orig.ident by assigning it the value of meta$brain.region
as a factor. meta
is my original table of metadata.
I'm doing this for a bunch of datasets and would like to make it generalizable.
The idea is that the user would only have to enter the name of the original object, and everything from then on would be called accordingly.
User prompt:
> dataset <- "path/to/gw14.RData"
> seurat.obj <- "gw14"
The workspace is then loaded, which includes the Seurat object gw14.
> load(dataset)
> seurat.obj.new <- paste0(seurat.obj, ".", 2)
I don't understand why using get
here returns the error below:
> get(seurat.obj.new)@meta.data$orig.ident <- factor(meta$brain.region)
Error in get(seurat.obj.new)@meta.data$orig.ident = factor(meta$brain.region) :
could not find function "get<-"
Whereas using it here works as expected:
> assign(seurat.obj.new, CreateSeuratObject(raw.data = get(seurat.obj)@raw.data,
min.cells = 0, min.genes = 0, project=age))