Convenience function to subset Seurat objects with multiple criteria.
Arguments
- seurat_obj
A Seurat object to subset.
- filters
Named list of filtering criteria. Each element should be a metadata column name with a vector of values to keep.
- min_cells
Minimum number of cells to retain after filtering. If fewer cells remain, returns NULL with a warning. Default is 1.
- verbose
Logical indicating whether to print progress messages. Default is TRUE.
Examples
if (FALSE) { # \dontrun{
# Subset by tissue and age
seurat_subset <- subset_seurat_by_metadata(
seurat_obj,
filters = list(
tissue = c("Kidney", "Liver"),
age = c("3m", "24m")
)
)
# Subset by multiple criteria
seurat_subset <- subset_seurat_by_metadata(
seurat_obj,
filters = list(
tissue = "Tongue",
sex = "male",
age = "24m"
),
min_cells = 100
)
} # }