Source: TBA

Introduction

baseDir=getwd()
dataDir=paste(baseDir,"/him_chart_idats/HIM_idats",sep="")

suppressPackageStartupMessages({
  library("missMethyl")
  library("limma")
  library("minfi")
  library("IlluminaHumanMethylation450kanno.ilmn12.hg19")
  library("IlluminaHumanMethylationEPICanno.ilm10b2.hg19")
  library("ruv")
  library("RColorBrewer")
  library("matrixStats")
  library("gplots")
  library("FlowSorted.Blood.450k")
  library("reshape2")
  library("ggplot2")
  library("DMRcate")
  library("FlowSorted.Blood.EPIC")
  library("mitch")
  library("kableExtra")
  library("vioplot")
})

#source("meth_functions.R")

Load data

Load the annotation data and the Epic methylation data.

This analysis is to be conducted on Ubuntu with R4.

ann = getAnnotation(IlluminaHumanMethylationEPICanno.ilm10b2.hg19)

ann_sub = ann[,c("chr","pos","strand","Name","Islands_Name",
    "Relation_to_Island","UCSC_RefGene_Name","UCSC_RefGene_Group")]

targets_gen = read.metharray.sheet(dataDir, pattern = "HIM_EPIC_sampleSheet.csv")
## [read.metharray.sheet] Found the following CSV files:
## [1] "/analysis/him_chart_idats/HIM_idats/HIM_EPIC_sampleSheet.csv"
#targets$ID = paste(targets$Sample_Group,targets_gen$Sample_Name,sep=".")
rgSet = read.metharray.exp(targets = targets_gen)
## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls

## Warning in readChar(con, nchars = n): truncating string with embedded nuls
sampleNames(rgSet) = targets_gen$Sample_Name

rgSet$Slide <- as.numeric(rgSet$Slide)
rgSet$Gender <- as.character(rgSet$Gender)
rgSet$Sex <- as.character(rgSet$Gender)
rgSet$Sample_Name<- as.character(rgSet$Sample_Name)

Testing familial structure

snpBetas = getSnpBeta(rgSet)
## Loading required package: IlluminaHumanMethylationEPICmanifest
d = dist(t(snpBetas))
hr = hclust(d, method = "complete", members=NULL)
plot(hr)

Quality control

detP = detectionP(rgSet)
qcReport(rgSet, sampNames = targets_gen$Sample_Name,
  pdf="qc-report_him.pdf")
## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE
## Warning: BISULFITE CONVERSION I probes outside plot range
## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE
## Warning: SPECIFICITY I probes outside plot range
## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE
## Warning: SPECIFICITY I probes outside plot range
## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE
## Warning: SPECIFICITY I probes outside plot range
## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE

## Warning in type.convert.default(X[[i]], ...): 'as.is' should be specified by the
## caller; using TRUE
## png 
##   2
cols=brewer.pal(4,"Set1")

barplot(apply(detP,2,mean),
  col=as.numeric(factor(targets_gen$Sample_Name)),
  las=2,cex.names= 0.8, cex.axis=0.75,
  main="Mean detection p-values of probe signals",
  ylab="Mean detection p-value")

barplot(apply(detP,2,mean),
  col=as.numeric(factor(targets_gen$Sample_Name)),
  las=2,cex.names= 0.8, cex.axis=0.75,ylim=c(0,0.010),
  main="Mean detection p-values of probe signals",
  ylab="Mean detection p-value")

Preprocessing

mset.raw = preprocessRaw(rgSet)

Data exploration

Using Multi-dimensional scaling (MDS) plots before filtering.

mdsPlot(mset.raw, sampGroups = targets_gen$Sample_Name, 
  sampNames=targets_gen$Social_interaction_on_ADOS,legendPos="bottom")

mdsPlot(mset.raw, sampGroups = targets_gen$Sex, 
  sampNames=targets_gen$SampleID,legendPos="bottom")

Cell type composition analysis

Try estimatecellcounts2.

cells <- estimateCellCounts2(rgSet, referencePlatform= "IlluminaHumanMethylationEPIC", 
  returnAll = TRUE)
## snapshotDate(): 2021-10-19
## see ?FlowSorted.Blood.EPIC and browseVignettes('FlowSorted.Blood.EPIC') for documentation
## loading from cache
## [estimateCellCounts2] Combining user data with reference (flow sorted) data.
## [estimateCellCounts2] Processing user and reference data together.
## [estimateCellCounts2] Picking probes for composition estimation.
## [estimateCellCounts2] Estimating composition.
mset <- cells$normalizedData

cellCounts_new <- cells[[1]]
#plot cell type composition by sample group
a = cellCounts_new[targets_gen$Diagnosis == "0",]
b = cellCounts_new[targets_gen$Diagnosis == "1",]
c = cellCounts_new[targets_gen$Diagnosis == "2",]
age.pal <- brewer.pal(8,"Set1")

cellCounts_long <- melt(cellCounts_new, id = "celltype")

Filtering

detP <- detectionP(rgSet)

# exclude bad samples
sample_failed_probes <- apply(detP,2, function(x) { length(which(x>0.01)) / length(x) } )
barplot(sample_failed_probes[order(sample_failed_probes)])

bad_samples <- sample_failed_probes[sample_failed_probes>0.01]
bad_samples <- names(bad_samples)
good_samples <- setdiff(names(sample_failed_probes),bad_samples)
detP <- detP[,good_samples]
mset <- mset[,good_samples]
targets_gen <- targets_gen[which(targets_gen$Sample_Name %in% good_samples),]


# exclude bad probes
failed_prope_frac <- apply(detP,1, function(x) { length(which(x>0.01)) / length(x) } )
probes_to_keep <- names(which(failed_prope_frac<0.05))
detP <- detP[probes_to_keep,]
mset <- mset[which(rownames(mset) %in% probes_to_keep),]

dim(mset)
## [1] 864567     90
gmset <- mapToGenome(mset)

#remove SNPs
gmset_flt = dropLociWithSnps(gmset, snps = c("CpG", "SBE"))

#Removing cross-reactive probes
XURL="https://raw.githubusercontent.com/sirselim/illumina450k_filtering/master/EPIC/13059_2016_1066_MOESM1_ESM.csv"
Xreact <- read.csv(XURL)

#Xreact = read.csv(file="/group/canc2/puumba/Data/InfiniumData/NamithaData/Rprojects/Autism/Analysis_Sept11/EPIC_850k_crossreactiveProbes.csv", stringsAsFactors=FALSE)
#Xreact = read.csv(file="~/48639-non-specific-probes-Illumina450k.csv", stringsAsFactors=FALSE)
noXreact <-  !(featureNames(gmset) %in% Xreact$X)

gmset <- gmset[noXreact,]

#Removing probes on X and Y chromosomes
autosomes <- !(featureNames(gmset) %in% ann$Name[ann$chr %in% c("chrX","chrY")])
gmset_flt <- gmset[autosomes,]

#Relative log expression (RLE plot)
mvals = getM(gmset_flt)
medSq = apply(mvals, 1, median)
YSq = mvals - medSq

boxplot(YSq,outline=FALSE,ylim=c(-1.5,1.5), 
  ylab="Relative Log Methylation Value", 
  cols=as.character(factor(targets_gen$Social_interaction_on_ADOS,)) )

MDS plots generation after filtering

pal = brewer.pal(8, "Dark2")
mds1Sq = plotMDS(mvals, top=1000, gene.selection="common",dim.plot=c(1,2))

mds2Sq = plotMDS(mvals, top=1000, gene.selection="common",dim.plot=c(1,3))

mds3Sq = plotMDS(mvals, top=1000, gene.selection="common",dim.plot=c(2,3))

mds4Sq = plotMDS(mvals, top=1000, gene.selection="common",dim.plot=c(3,4))

plotMDS(mds1Sq, xlab="Dimension 1", ylab="Dimension 2",
  col=pal[as.factor(targets_gen$Diagnosis)],
  dim=c(1,2), labels=targets_gen$Sample_Name)
legend("bottomright",bg="white",col=pal,cex=.7,pch=1,legend=0:1)

plotMDS(mds2Sq, xlab="Dimension 1", ylab="Dimension 3",
  col=pal[as.factor(targets_gen$Diagnosis)],dim=c(1,3),
  labels=targets_gen$Sample_Name)
legend("bottomright",bg="white",col=pal,cex=.7,pch=1,legend=0:1)

plotMDS(mds3Sq, xlab="Dimension 2", ylab="Dimension 3",
  col=pal[as.factor(targets_gen$Diagnosis)],dim=c(2,3),
  labels=targets_gen$Sample_Name)
legend("bottomright",bg="white",col=pal,cex=.7,pch=1,legend=0:1)

plotMDS(mds4Sq, xlab="Dimension 3", ylab="Dimension 4",
  col=pal[as.factor(targets_gen$Diagnosis)],dim=c(3,4),
  labels=targets_gen$Sample_Name)
legend("bottomright",bg="white",col=pal,cex=.7,pch=1,legend=0:1)

Principal Component Analysis (PCA)

fit <- prcomp(t(mvals),center = TRUE, scale = TRUE,retx=TRUE)
loadings = fit$x
plot(fit,type="lines")

nGenes = nrow(mvals)
nSamples = ncol(mvals)

Limma analysis looking for slide effects

Make a random variable for constrast.

set.seed(42) ; rand <- sample(targets_gen$Sample_Name,45) 
targets_gen$rand <- targets_gen$Sample_Name %in% rand
rand <- targets_gen$rand
design <- model.matrix(~ rand )
fit <- lmFit(mvals, design)
fit2 <- eBayes(fit)
summary(decideTests(fit2))
##        (Intercept) randTRUE
## Down        264320        0
## NotSig        9869   803248
## Up          529059        0
top <- topTable(fit2,coef=ncol(design),num=Inf, sort.by = "P")


nsig <- sum(top$adj.P.Val < 0.05)
sum(top$P.Value< 0.05)
## [1] 18876
output <-merge(ann_sub,top,by.x="Name",by.y="row.names")
output <- output[order(output$P.Value),]
write.csv(output, file="limma_HIM_rand.csv",row.names=FALSE)
output <- subset(output,P.Value<1e-4)
head(output,30) %>% kbl() %>% kable_paper("hover", full_width = F)
Name chr pos strand Islands_Name Relation_to_Island UCSC_RefGene_Name UCSC_RefGene_Group logFC AveExpr t P.Value adj.P.Val B
cg00495515 chr3 169490965
chr3:169490834-169491206 Island MYNN;MYNN 1stExon;5’UTR -0.1588581 -6.4567111 -4.483926 2.12e-05 0.9999965 1.9100172
cg26205981 chr8 24856821
chr8:24857509-24858427 N_Shore 0.3246547 -0.8836489 4.478816 2.16e-05 0.9999965 1.8951307
cg23705847 chr14 74253388
chr14:74253387-74254188 Island C14orf43 5’UTR 0.2072571 -4.2504548 4.469801 2.23e-05 0.9999965 1.8688953
cg19648783 chr5 159609112
OpenSea -1.4045869 1.8359066 -4.382671 3.12e-05 0.9999965 1.6168743
cg17819017 chr17 79485996
chr17:79485599-79486913 Island -0.2383429 -5.6347059 -4.299328 4.27e-05 0.9999965 1.3785052
cg22589745 chr3 33138276
chr3:33138083-33138769 Island TMPPE;TMPPE;TMPPE;GLB1;GLB1;GLB1;TMPPE;GLB1 1stExon;5’UTR;1stExon;1stExon;Body;5’UTR;5’UTR;Body -0.2796602 -4.8228677 -4.266887 4.82e-05 0.9999965 1.2864530
cg23601030 chr20 52276760
chr20:52276744-52277051 Island -0.8751365 -4.6939495 -4.216938 5.80e-05 0.9999965 1.1455396
cg11281961 chr2 97498902
OpenSea CNNM3;CNNM3 3’UTR;3’UTR 0.1654572 3.6433027 4.209321 5.97e-05 0.9999965 1.1241384
cg05733633 chr15 88842568
OpenSea 0.1694499 0.8456066 4.180966 6.63e-05 0.9999965 1.0446801
cg08364767 chr15 40212176
chr15:40211961-40213444 Island GPR176 1stExon -0.3550213 -5.3537204 -4.156340 7.26e-05 0.9999965 0.9759380
cg01125659 chr6 123378318
OpenSea CLVS2 Body 0.2885730 3.2861617 4.151452 7.39e-05 0.9999965 0.9623227
cg14864852 chr22 39102110
chr22:39101825-39102668 Island GTPBP1 1stExon -0.3336965 -5.9674043 -4.131284 7.96e-05 0.9999965 0.9062530
cg07050917 chr18 3221492
OpenSea MYOM1;MYOM1 TSS1500;TSS1500 0.1189092 3.7612223 4.131214 7.96e-05 0.9999965 0.9060600
cg02021606 chr21 44845925
OpenSea SIK1 Body -0.1835027 -4.2342564 -4.110474 8.59e-05 0.9999965 0.8485747
cg01281140 chr7 150065678
chr7:150065169-150066351 Island REPIN1;REPIN1;REPIN1 TSS200;TSS200;TSS200 -0.1627095 -3.2723833 -4.080305 9.58e-05 0.9999965 0.7652825
saveRDS(design, "HIM_rand_des.rds")
saveRDS(mvals, "HIM_rand_mvals.rds")

Session information

sessionInfo()
## R version 4.1.3 (2022-03-10)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.4 LTS
## 
## Matrix products: default
## BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] IlluminaHumanMethylationEPICmanifest_0.3.0         
##  [2] vioplot_0.4.0                                      
##  [3] zoo_1.8-11                                         
##  [4] sm_2.2-5.7.1                                       
##  [5] kableExtra_1.3.4                                   
##  [6] mitch_1.6.0                                        
##  [7] FlowSorted.Blood.EPIC_1.12.1                       
##  [8] ExperimentHub_2.2.1                                
##  [9] AnnotationHub_3.2.2                                
## [10] BiocFileCache_2.2.1                                
## [11] dbplyr_2.3.1                                       
## [12] nlme_3.1-155                                       
## [13] quadprog_1.5-8                                     
## [14] genefilter_1.76.0                                  
## [15] DMRcate_2.8.5                                      
## [16] ggplot2_3.4.1                                      
## [17] reshape2_1.4.4                                     
## [18] FlowSorted.Blood.450k_1.32.0                       
## [19] gplots_3.1.3                                       
## [20] RColorBrewer_1.1-3                                 
## [21] ruv_0.9.7.1                                        
## [22] IlluminaHumanMethylationEPICanno.ilm10b2.hg19_0.6.0
## [23] limma_3.50.3                                       
## [24] missMethyl_1.28.0                                  
## [25] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0
## [26] IlluminaHumanMethylation450kanno.ilmn12.hg19_0.6.0 
## [27] minfi_1.40.0                                       
## [28] bumphunter_1.36.0                                  
## [29] locfit_1.5-9.7                                     
## [30] iterators_1.0.14                                   
## [31] foreach_1.5.2                                      
## [32] Biostrings_2.62.0                                  
## [33] XVector_0.34.0                                     
## [34] SummarizedExperiment_1.24.0                        
## [35] Biobase_2.54.0                                     
## [36] MatrixGenerics_1.6.0                               
## [37] matrixStats_0.63.0                                 
## [38] GenomicRanges_1.46.1                               
## [39] GenomeInfoDb_1.30.1                                
## [40] IRanges_2.28.0                                     
## [41] S4Vectors_0.32.4                                   
## [42] BiocGenerics_0.40.0                                
## 
## loaded via a namespace (and not attached):
##   [1] rappdirs_0.3.3                rtracklayer_1.54.0           
##   [3] GGally_2.1.2                  R.methodsS3_1.8.2            
##   [5] tidyr_1.3.0                   bit64_4.0.5                  
##   [7] knitr_1.37                    DelayedArray_0.20.0          
##   [9] R.utils_2.12.2                data.table_1.14.8            
##  [11] rpart_4.1.16                  KEGGREST_1.34.0              
##  [13] RCurl_1.98-1.10               GEOquery_2.62.2              
##  [15] AnnotationFilter_1.18.0       generics_0.1.2               
##  [17] GenomicFeatures_1.46.5        preprocessCore_1.56.0        
##  [19] RSQLite_2.3.0                 bit_4.0.5                    
##  [21] tzdb_0.3.0                    webshot_0.5.4                
##  [23] xml2_1.3.3                    httpuv_1.6.9                 
##  [25] xfun_0.37                     hms_1.1.2                    
##  [27] jquerylib_0.1.4               evaluate_0.15                
##  [29] promises_1.2.0.1              fansi_1.0.2                  
##  [31] restfulr_0.0.15               scrime_1.3.5                 
##  [33] progress_1.2.2                caTools_1.18.2               
##  [35] DBI_1.1.3                     htmlwidgets_1.6.2            
##  [37] reshape_0.8.9                 purrr_1.0.1                  
##  [39] ellipsis_0.3.2                dplyr_1.1.0                  
##  [41] backports_1.4.1               permute_0.9-7                
##  [43] annotate_1.72.0               biomaRt_2.50.3               
##  [45] deldir_1.0-6                  sparseMatrixStats_1.6.0      
##  [47] vctrs_0.6.0                   ensembldb_2.18.4             
##  [49] cachem_1.0.6                  withr_2.5.0                  
##  [51] Gviz_1.38.4                   BSgenome_1.62.0              
##  [53] checkmate_2.1.0               GenomicAlignments_1.30.0     
##  [55] prettyunits_1.1.1             mclust_6.0.0                 
##  [57] svglite_2.1.1                 cluster_2.1.2                
##  [59] lazyeval_0.2.2                crayon_1.5.0                 
##  [61] edgeR_3.36.0                  pkgconfig_2.0.3              
##  [63] ProtGenerics_1.26.0           nnet_7.3-17                  
##  [65] rlang_1.1.0                   lifecycle_1.0.3              
##  [67] filelock_1.0.2                dichromat_2.0-0.1            
##  [69] rngtools_1.5.2                base64_2.0.1                 
##  [71] Matrix_1.4-0                  Rhdf5lib_1.16.0              
##  [73] base64enc_0.1-3               beeswarm_0.4.0               
##  [75] png_0.1-8                     viridisLite_0.4.1            
##  [77] rjson_0.2.21                  bitops_1.0-7                 
##  [79] R.oo_1.25.0                   KernSmooth_2.23-20           
##  [81] rhdf5filters_1.6.0            blob_1.2.4                   
##  [83] DelayedMatrixStats_1.16.0     doRNG_1.8.6                  
##  [85] stringr_1.5.0                 nor1mix_1.3-0                
##  [87] readr_2.1.4                   jpeg_0.1-10                  
##  [89] scales_1.2.1                  memoise_2.0.1                
##  [91] magrittr_2.0.2                plyr_1.8.8                   
##  [93] zlibbioc_1.40.0               compiler_4.1.3               
##  [95] BiocIO_1.4.0                  illuminaio_0.36.0            
##  [97] Rsamtools_2.10.0              cli_3.6.0                    
##  [99] DSS_2.42.0                    htmlTable_2.4.1              
## [101] Formula_1.2-5                 MASS_7.3-55                  
## [103] tidyselect_1.2.0              stringi_1.7.6                
## [105] highr_0.9                     yaml_2.3.5                   
## [107] askpass_1.1                   latticeExtra_0.6-30          
## [109] grid_4.1.3                    sass_0.4.5                   
## [111] VariantAnnotation_1.40.0      tools_4.1.3                  
## [113] rstudioapi_0.13               foreign_0.8-82               
## [115] bsseq_1.30.0                  gridExtra_2.3                
## [117] digest_0.6.29                 BiocManager_1.30.16          
## [119] shiny_1.7.4                   Rcpp_1.0.10                  
## [121] siggenes_1.68.0               BiocVersion_3.14.0           
## [123] later_1.3.0                   org.Hs.eg.db_3.14.0          
## [125] httr_1.4.2                    AnnotationDbi_1.56.2         
## [127] biovizBase_1.42.0             colorspace_2.1-0             
## [129] rvest_1.0.3                   XML_3.99-0.14                
## [131] splines_4.1.3                 statmod_1.5.0                
## [133] multtest_2.50.0               systemfonts_1.0.4            
## [135] xtable_1.8-4                  jsonlite_1.8.0               
## [137] R6_2.5.1                      echarts4r_0.4.4              
## [139] Hmisc_5.0-1                   pillar_1.7.0                 
## [141] htmltools_0.5.4               mime_0.12                    
## [143] glue_1.6.2                    fastmap_1.1.0                
## [145] BiocParallel_1.28.3           interactiveDisplayBase_1.32.0
## [147] beanplot_1.3.1                codetools_0.2-18             
## [149] utf8_1.2.2                    lattice_0.20-45              
## [151] bslib_0.4.2                   tibble_3.1.6                 
## [153] curl_4.3.2                    gtools_3.9.4                 
## [155] openssl_2.0.0                 interp_1.1-3                 
## [157] survival_3.3-1                rmarkdown_2.20               
## [159] munsell_0.5.0                 rhdf5_2.38.1                 
## [161] GenomeInfoDbData_1.2.7        HDF5Array_1.22.1             
## [163] gtable_0.3.2