Calculate (signed) Kolgomorov-Smirnov enrichment p-value in dataframe
Source:R/stats.R
get_kspval.RdIf no group of interest specified, pulls first condition against others.
Usage
get_kspval(
df,
value,
group,
goi = NULL,
rep0 = .Machine$double.xmin,
signed = FALSE,
viz = FALSE
)Arguments
- df
df; has columns
valueandgroup,NAvalues are filtered out- value
string; colname of values to rank by
- group
string; colname of categorizations
- goi
group of interest value within
df[,group]- rep0
numeric; value to replace
0results with- signed
logical;
TRUEto return GSEA-style enrichment score as second element of list:ks_pval[1] = pval,ks_pval[1] = ES- viz
logical;
TRUEto output density plot of values
Details
Signed ES score adapted from franapoli/signed-ks-test which is based on GSEA enrichment score calculation.
Positive ES indicates that by rank, the goi are "left" of / smaller than the rest of the values, while negative ES indicates the goi is "right" of / greater than the rest of values. Use viz = TRUE to visualize the values and resulting KS p-value.