Skip to contents

Returns the subset of gene_list where the fraction of cells expressing each gene (above expr_threshold) meets pct_threshold in either any or all groups. Works with Assay, Assay5, and BPCells-backed objects.

Usage

FilterGenesByPct(
  seurat_object,
  gene_list,
  group_by,
  assay = NULL,
  layer = "data",
  expr_threshold = 0,
  pct_threshold = 20,
  mode = c("any_group", "all_groups")
)

Arguments

seurat_object

A Seurat object.

gene_list

Character vector of gene names to test.

group_by

Character. Metadata column defining the groups.

assay

Character or NULL. Assay to pull expression from. Defaults to DefaultAssay().

layer

Character. Layer/slot to use ("data", "counts", etc.). Default "data".

expr_threshold

Numeric. A cell is considered "expressing" the gene if its value is strictly above this threshold. Default 0.

pct_threshold

Numeric. Minimum percent (0–100) of cells in a group that must express the gene. Default 20.

mode

Character. "any_group" (default) keeps a gene if it passes the threshold in at least one group; "all_groups" requires every group to pass.

Value

A named list:

genes

Character vector of genes that passed the filter.

pct_table

Data frame (genes × groups) of percent-expressed values, with an extra gene column. Pass to PlotPctHeatmap().

See also