set.seed(123)
# Simulated EWAS result: a mix of signal and noise
n_cpg <- 500
ewas <- data.frame(
cpg = paste0("cg", sprintf("%08d", 1:n_cpg)),
p_value = c(runif(n_cpg*0.1, 1e-9, 1e-5), runif(n_cpg*0.2, 1e-3, 0.05), runif(n_cpg*0.7, 0.05, 1))
)
# Corresponding eQTM mapping (some of these CpGs have gene links)
signal_genes <- c("5290", "673", "1956", "7157", "7422")
background_genes <- as.character(1000:9999)
entrez_signal <- sample(signal_genes, n_cpg * 0.1, replace = TRUE)
entrez_background <- sample(setdiff(background_genes, signal_genes), n_cpg * 0.9, replace = TRUE)
eqtm_data <- data.frame(
cpg = ewas$cpg,
statistics = rnorm(n_cpg, mean = 2, sd = 1),
p_value = runif(n_cpg, min = 0.001, max = 0.05),
distance = sample(1000:100000, n_cpg, replace = TRUE),
entrez = c(entrez_signal, entrez_background),
stringsAsFactors = FALSE
)
eqtm_obj <- create_eQTM(eqtm_data)
# Run pathway voting with minimal settings
if (FALSE) {
results <- pathway_vote(
cpg_input = ewas,
eQTM = eqtm_obj,
databases = c("GO", "KEGG", "Reactome"),
readable = TRUE,
verbose = TRUE
)
head(results$GO)
head(results$KEGG)
head(results$Reactome)
# Export results to Excel (optional)
library(openxlsx)
write_enrich_results_xlsx(results, "pathway_vote_results.xlsx")
}
Run the code above in your browser using DataLab