Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created April 1, 2015 10:24
Show Gist options
  • Save explodecomputer/003e424f22a31eadf326 to your computer and use it in GitHub Desktop.
Save explodecomputer/003e424f22a31eadf326 to your computer and use it in GitHub Desktop.
Estimating variance explained by CpGs from p-values
# Sample size of PAPA replication
n <- 149
# Pvals from first 14 CpGs in PAPA replication
pval <- c(9.6e-6, 7.2e-5, 2.8e-6, 3.7e-5, 4.8e-4, 6.2e-3, 4.6e-6, 1.3e-2, 2.6e-3, 3.8e-4, 3.2e-5, 9.0e-4, 8.8e-5, 8.3e-5)
# Estimate F statistics
qval <- qf(pval, 1, n-1, low=F)
# Estimate proportion of variance explained by each CpG
# Fval = (var_explained / k - 1) / (var_unexplained / n - k - 1)
pvar <- qval / (n - 3)
# Proportion of variance explained by all CpGs
sum(pvar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment