Split samples into high and low expressers of a gene or signature
Source:R/tcga.R
stratify_by_expression.RdRanks samples by the expression of one gene, or by a signature score for several genes (the mean of each gene's z-score across samples), and returns the samples in the top and bottom quantile.
Examples
set.seed(1)
expr <- matrix(rexp(200), nrow = 4,
dimnames = list(c("NKG7", "GZMB", "CD3E", "ACTB"), paste0("s", 1:50)))
strata <- stratify_by_expression(expr, "NKG7")
lengths(strata[c("high", "low")])
#> high low
#> 13 13
stratify_by_expression(expr, c("NKG7", "GZMB"))$high
#> [1] "s2" "s4" "s6" "s14" "s17" "s19" "s22" "s23" "s27" "s38" "s39" "s43"
#> [13] "s44"