seurat-object icon indicating copy to clipboard operation
seurat-object copied to clipboard

Adding feature metadata to Seurat v5 Object using SeuratObject::AddMetaData does not work

Open grantn5 opened this issue 9 months ago • 1 comments

When trying to add feature metadata to Seurat v5 object using the nromal SeuratObject::AddMetaData() you get the following error

Error in `LayerData<-`:
! 'layer' must be a single non-empty string

Reprex

library(Seurat)
library(SeuratData)
library(BPCells)
library(dplyr)
options(Seurat.object.assay.version = "v5")

pbmc3k <- SeuratData::LoadData("pbmc3k")

pbmc3k_feature_data <- pbmc3k[["RNA"]][["counts"]] |>
  dplyr::mutate(new_vairable =sample(1:100, nrow(pbmc3k), replace = TRUE))

pbmc3k[["RNA"]] <- SeuratObject::AddMetaData(pbmc3k[["RNA"]], metadata = pbmc3k_feature_data)

grantn5 avatar Sep 22 '23 09:09 grantn5