Ask Your Question
3

What is the method to obtain a subset of a Seurat object using metadata as a criterion?

asked 2021-11-22 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-07-07 05:00:00 +0000

bukephalos gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-11-22 11:00:00 +0000

Seen: 9 times

Last updated: Jul 07 '21