knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

Loading the epimedtools library

library(epimedtools)

Creating a new study.

study = create_study()

The .CEL.gz files are stored into two directories the ctrl directory and the kc directory. When processing .CEL.gz files, the origin of each file (one of this two directories) is stored in a new column of the experimental grouping. This column is next used used to perform the Mann-Witney test, one orig vs. the otehr.

kc_cel_filedir = system.file(
  "extdata/trscr_raw_kc", 
  package = "epimeddata"
)
print(kc_cel_filedir)
ctrl_cel_filedir = system.file(
  "extdata/trscr_raw_ctrl", 
  package = "epimeddata"
)
print(ctrl_cel_filedir)
study$cel_filedirs = c(kc_cel_filedir, ctrl_cel_filedir)
print(study$cel_filedirs)

The RMA normalized data matrix is extract using the get_data method.

head(study$get_data())

The associated clinical data

print(study$get_exp_grp())

The Mann-Whitney analysis on 100 first probes.

# selecting intersting probes
probe_names = rownames(study$get_data())[1:100]
# subset dataset
ctrl_exp_grp_key = "orig"
case_exp_grp_key = "orig"
ctrl_factor_name = "trscr_raw_ctrl"
case_factor_name = "trscr_raw_kc"

mw_res = study$do_mw_test(probe_names, ctrl_exp_grp_key, case_exp_grp_key, ctrl_factor_name, case_factor_name)

thres = c(1,-1) * -log10(0.05)
fc_thres = c(-1.5, -1.2, 1.2, 1.5)
lr_thres = gtools::foldchange2logratio(fc_thres)

# Whitout FDR
plot(mw_res$trscr_raw_ctrl.trscr_raw_kc.logratio, -log10(mw_res$trscr_raw_ctrl.trscr_raw_kc.mw_pval_adj))


# Whit FDR 
# plot(mw_res$mean_fc, -log10(p.adjust(mw_res$mw_pval, "BH")))
abline(h=-log10(0.05), v = lr_thres, lty=3, col=2)
legend("bottomright", lty=3, col=2, legend=paste("fc thres (", paste(fc_thres, collapse=","), ")", sep=""))


fchuffar/epimedtools documentation built on Feb. 3, 2024, 2:21 a.m.