Extract Differentially Expressed Genes per Subtype
Source:R/extract_top_genes.R
extract_top_genes.RdFor each molecular subtype, performs gene-level differential expression analysis comparing samples of that subtype against all other samples (one-vs-rest). Returns genes passing user-specified fold-change and adjusted p-value thresholds, sorted by significance.
Usage
extract_top_genes(
expr,
subtype,
idType = "SYMBOL",
method = c("wilcox", "t.test"),
log2fc_cutoff = 1,
p_cutoff = 0.05,
min_samples = 3
)Arguments
- expr
A numeric gene expression matrix with genes in rows and samples in columns. Row names must be gene symbols (or identifiers matching
idType). Values should be log2-transformed (e.g. log2(TPM + 1)).- subtype
A named character vector or factor giving the predicted subtype for each sample, as returned by
classifyHNSC(outputType = "class").- idType
Character string specifying the gene identifier type. One of
"SYMBOL"(default),"ENSEMBL","ENTREZID", or"REFSEQ". Non-symbol IDs are auto-converted to gene symbols via org.Hs.eg.db.- method
Character string specifying the statistical test. One of
"wilcox"(default) for Wilcoxon rank-sum test or"t.test"for Welch's t-test.- log2fc_cutoff
Numeric. Minimum absolute log2 fold-change to retain a gene (default: 1, i.e. 2-fold change).
- p_cutoff
Numeric. Adjusted p-value (FDR) threshold (default: 0.05).
- min_samples
Numeric. Minimum number of samples required in each group (subtype vs rest) to run the comparison (default: 3).
Value
A named list of data frames, one per subtype. Each data frame contains genes passing the thresholds, with columns:
gene: gene symbollog2FC: log2 fold-change (positive = up in this subtype)mean_expr: mean expression in this subtypemean_other: mean expression in all other subtypesp_value: raw p-value from the chosen testadj_p_value: Benjamini-Hochberg adjusted p-value (FDR)
Details
For each subtype, the function compares in-subtype samples against all remaining samples on every gene. P-values are corrected across all genes within each subtype using the Benjamini-Hochberg procedure.
method = "wilcox" uses wilcox.test which makes
no distributional assumptions. method = "t.test" uses Welch's
t-test via t.test which assumes approximate normality.
Examples
if (FALSE) { # \dontrun{
data(TCGA_LUSC)
subtypes <- classifyHNSC(TCGA_LUSC, outputType = "class")
degs <- extract_top_genes(TCGA_LUSC, subtypes,
log2fc_cutoff = 1, p_cutoff = 0.05)
head(degs$Basal)
} # }