To obtain a subset of a Seurat object using metadata as a criterion, you can use the subset
function with the cells
parameter.
For example, if you have a Seurat object called pbmc
, and you want to obtain a subset of cells that have a metadata called stimulation
with a value of IL2
, you can use the following code:
subset_pbmc <- subset(pbmc, cells = WhichCells(pbmc, metadata = "stimulation", values = "IL2"))
In this code, WhichCells
is used to obtain the cell indices that have the desired metadata and value, and these indices are used to subset the Seurat object. The resulting subset is stored in a new Seurat object called subset_pbmc
.
Asked: 2021-11-22 11:00:00 +0000
Seen: 9 times
Last updated: Jul 07 '21