Skip to contents

Performs differential expression between two sample identities within each specified cell-type cluster using Seurat::FindMarkers. Results are filtered by adjusted p-value and absolute log2 fold-change thresholds, and annotated with a regulation-direction label.

Usage

run_cluster_de(
  obj,
  clusters,
  cluster_col = "final_celltype",
  ident_col = "sample",
  ident1,
  ident2,
  min.pct = 0.25,
  padj_thresh = 0.05,
  logfc_thresh = 0.5
)

Arguments

obj

A Seurat object containing the RNA assay and metadata columns specified by cluster_col and ident_col.

clusters

Character vector of cluster names (values in the cluster_col metadata column) to iterate over.

cluster_col

Character string naming the metadata column that holds cell-type cluster assignments. Default "final_celltype".

ident_col

Character string naming the metadata column to set as the active identity for the DE comparison (e.g., "sample", "condition"). Default "sample".

ident1

Character string. The first identity level (numerator in the log fold-change calculation). Positive fold-changes indicate genes up-regulated in ident1.

ident2

Character string. The second identity level (denominator).

min.pct

Numeric. Minimum fraction of cells in either group that must express a gene for it to be tested. Passed to Seurat::FindMarkers. Default 0.25.

padj_thresh

Numeric. Maximum adjusted p-value for a gene to be retained in the filtered output. Default 0.05.

logfc_thresh

Numeric. Minimum absolute log2 fold-change for a gene to be retained. Default 0.5.

Value

A named list of data frames (one per cluster). Each data frame contains the standard FindMarkers columns plus:

gene

Gene symbol (from row names).

cluster

The cluster label.

comparison

String "<ident1>_vs_<ident2>".

res

Direction label: "Upregulated in <ident1>" or "Upregulated in <ident2>".

Details

The function subsets the Seurat object to each cluster, sets the active identity to ident_col, and runs Seurat::FindMarkers(assay = "RNA"). A frequency table of regulation direction is printed for each cluster.