satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.3k stars 917 forks source link

Adding additional features to Seurat object #9339

Open mckennareale opened 1 month ago

mckennareale commented 1 month ago

Hello, referencing #2855, I have an integrated Seurat object ("so"). I want to add additional genes to the object after integration (I don't want the additional genes to be considered when integrating the object). I have tried to do the following:

assay_data_all <- GetAssayData(so, assay = "RNA", layer = "data") updated_expr_matrix <- rbind(as.matrix(assay_data_all), additional_genes_matrix) so.updated <- SetAssayData(so, assay = "RNA", layer = "data", new.data = updated_expr_matrix)

However, when I do this: print(Features(so.updated)), I do not see the additional genes I've added in the list of features, and I cannot plot these additional genes as FeaturePlots. Is there a different way to approach this? I am using Seurat v5, and I have confirmed that in updated_expr_matrix, the additional genes are being appended as rows to the end. Also, the column names are the same between assay_data_all and additional_genes_matrix.

Any help would be greatly appreciated. Thank you so much!

longmanz commented 1 month ago

Hi, Which integration workflow were you following? Is it Seurat v3/4 (IntegrateData) or Seurat v5 (IntegrateLayers())?

mckennareale commented 1 month ago

It was Seurat v5 (IntegrateLayers).