Skip to contents

Adds a metadata column labeling each cell as "high" / "low" (or "expressed" / "zero") for a given gene. The split is computed independently within each cell type. The column can be passed directly as condition.by in RunGSEA_pseudobulk() or used with Seurat::FindMarkers.

Usage

SplitByGene(
  seurat_object,
  gene,
  group.by,
  split = c("zero_vs_expressed", "quantile", "expressed_quantile"),
  quantile_range = c(0.25, 0.75),
  assay = NULL,
  layer = "data",
  col_name = NULL
)

Arguments

seurat_object

A Seurat object.

gene

Character. Gene to split on.

group.by

Character. Cell-type identity column.

split

Character. "zero_vs_expressed" (default), "quantile", or "expressed_quantile".

quantile_range

Numeric length-2. Quantile bounds for the two threshold modes. Default c(0.25, 0.75).

assay

Character or NULL. Assay to use.

layer

Character. Layer/slot. Default "data".

col_name

Character or NULL. New metadata column name. Defaults to "<gene>_split".

Value

Seurat object with a new metadata column. Prints a count table.

Details

Split modes

"zero_vs_expressed"

GOI = 0 → "zero"; GOI > 0 → "expressed". Cleanest for pseudobulk: maps to donor-level proportion.

"quantile"

Bottom quantile_range[1] → "low"; top 1 - quantile_range[2] → "high"; middle → NA (excluded).

"expressed_quantile"

Same as "quantile" but among GOI > 0 cells only. Zeros → NA. Avoids dropout in the low group but can confound with library size - regress out nCount_RNA downstream.