## ----setup, include = FALSE----------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----eval=FALSE----------------------------------------------------------
#  library(ExperimentHub)
#  
#  hub <- ExperimentHub()
#  
#  query(hub, "FlowSorted.Blood.EPIC")
#  
#  FlowSorted.Blood.EPIC <- hub[["EH1136"]]
#  
#  FlowSorted.Blood.EPIC

## ----eval=FALSE----------------------------------------------------------
#  head(IDOLOptimizedCpGs)

## ----eval=FALSE----------------------------------------------------------
#  head(IDOLOptimizedCpGs450klegacy)

## ----eval=FALSE----------------------------------------------------------
#  # Step 1: Load the reference library to extract the artificial mixtures
#  
#  library(ExperimentHub)
#  hub <- ExperimentHub()
#  query(hub, "FlowSorted.Blood.EPIC")
#  FlowSorted.Blood.EPIC <- hub[["EH1136"]]
#  FlowSorted.Blood.EPIC
#  
#  # Step 2 separate the reference from the testing dataset
#  
#  RGsetTargets <- FlowSorted.Blood.EPIC[,
#               FlowSorted.Blood.EPIC$CellType == "MIX"]
#  
#  sampleNames(RGsetTargets) <- paste(RGsetTargets$CellType,
#                              seq_len(dim(RGsetTargets)[2]), sep = "_")
#  RGsetTargets
#  
#  # Step 3: Deconvolute using the IDOL L-DMR
#  
#  head (IDOLOptimizedCpGs)
#  
#  # If you need to deconvolute a 450k legacy dataset use
#  # IDOLOptimizedCpGs450klegacy instead
#  
#  # Do not run with limited RAM the normalization step requires a big amount of
#  # memory resources
#  
#  if (memory.limit()>8000){
#   countsEPIC<-estimateCellCounts2(RGsetTargets, compositeCellType = "Blood",
#                                  processMethod = "preprocessNoob",
#                                  probeSelect = "IDOL",
#                                  cellTypes = c("CD8T", "CD4T", "NK", "Bcell",
#                                  "Mono", "Neu"),
#                                  referencePlatform =
#                                  "IlluminaHumanMethylationEPIC",
#                                  referenceset = NULL,
#                                  IDOLOptimizedCpGs =IDOLOptimizedCpGs,
#                                  returnAll = FALSE)
#  
#  head(countsEPIC$counts)
#  }