## ----message=FALSE, warning=FALSE, include=FALSE------------------------------
options(rmarkdown.html_vignette.check_title = FALSE)

## ----message=FALSE, warning=FALSE---------------------------------------------
library(sesame)

## -----------------------------------------------------------------------------
## As sesame and sesameData are under active development, this documentation is
## specific to the following version of R, sesame, sesameData and ExperimentHub:
sesame_checkVersion()

## ----message=FALSE------------------------------------------------------------
sesameDataCache()

## -----------------------------------------------------------------------------
tools::R_user_dir("ExperimentHub", which="cache")

## ----base1, eval=FALSE--------------------------------------------------------
#  ## The following use the idat_dir in system.file,
#  ## Replace it with your actual IDAT path
#  idat_dir = system.file("extdata/", package = "sesameData")
#  betas = openSesame(idat_dir, BPPARAM = BiocParallel::MulticoreParam(2))

## ----base2, eval=FALSE--------------------------------------------------------
#  ##  The above openSesame call is equivalent to:
#  betas = do.call(cbind, BiocParallel::bplapply(
#      searchIDATprefixes(idat_dir), function(pfx) {
#          getBetas(prepSesame(readIDATpair(pfx), "QCDPB"))
#  }, BPPARAM = BiocParallel::MulticoreParam(2)))
#  
#  ## or even more explicitly (if one needs to control argument passed
#  ## to a specific preprocessing function)
#  betas = do.call(cbind, BiocParallel::bplapply(
#      searchIDATprefixes(idat_dir), function(pfx) {
#          getBetas(noob(pOOBAH(dyeBiasNL(inferInfiniumIChannel(qualityMask(
#              readIDATpair(pfx)))))))
#  }, BPPARAM = BiocParallel::MulticoreParam(2)))

## ----base12, eval=FALSE-------------------------------------------------------
#  betas = openSesame(idat_dir, func = getBetas) # getBetas is the default
#  sdfs = openSesame(idat_dir, func = NULL) # return SigDF list
#  allele_freqs = openSesame(idat_dir, func = getAFs) # SNP allele frequencies
#  sdfs = openSesame(sdfs, prep = "Q", func = NULL)   # take and return SigDFs

## ----base14, eval=FALSE-------------------------------------------------------
#  pvals = openSesame(idat_dir, func = pOOBAH, return.pval=TRUE)

## ----base9--------------------------------------------------------------------
sdf = sesameDataGet('EPIC.1.SigDF')
sdf_preped = openSesame(sdf, prep="DB", func=NULL)

## ----base10, echo=FALSE, result="asis"----------------------------------------
library(knitr)
df <- data.frame(rbind(
    c("EPICv2/EPIC/HM450", "human", "QCDPB"),
    c("EPICv2/EPIC/HM450", "non-human organism", "SQCDPB"),
    c("MM285", "mouse", "TQCDPB"),
    c("MM285", "non-mouse organism", "SQCDPB"),
    c("Mammal40", "human", "HCDPB"),
    c("Mammal40", "non-human organism", "SHCDPB")))
colnames(df) <- c("Platform", "Sample Organism", "Prep Code")
kable(df, caption="Recommended Preprocessing")

## ----base11-------------------------------------------------------------------
prepSesameList()

## -----------------------------------------------------------------------------
sessionInfo()

