##################################### ### Processing of methylomic data ### ##################################### #load the methylomic data from the 450k beadchip library(minfi) path<-"G:/Méthylomique/Fichiers IDAT" list.files(path) targets<-read.table("G:/Méthylomique/Fichiers IDAT/targets.txt",sep="\t",dec=",",header=TRUE) rgset<-read.450k.exp(targets=targets) rgset$Sample_Name<-as.character(rgset$Nom) rgset$Basename<-as.character(rgset$Basename) #Preprocessing MSet<-preprocessRaw(rgset) #Quality control qc<-getQC(MSet) plotQC(qc) densityPlot(MSet,sampGroups=phenoData$Sample_Group) densityBeanPlot(MSet, sampGroups = phenoData$Sample_Group) qcReport(rgset, pdf= "H:/Data AN/qcReport.pdf") #Correction for cell count require(FlowSorted.Blood.450k) cellcounts<-estimateCellCounts(rgset) #Detection of batch effect library(sva) mod=model.matrix(~as.factor(Sample_Group), data=phenoData) mod #return no batch effect #Normalization (funnorm) gset.funnorm<-preprocessFunnorm(rgset) data<-getBeta(gset.funnorm) #load the phenotype (converter/non converter) PHENO<-read.table("phenotype.txt", header=T, sep="\t") ###################################### ## Detection of private epimutation ## ###################################### # Compute the variance: Example for the converter group (="C") list<-subset(PHENO,Statut=="C") myvars<-list$code.sample myvars<-as.character(myvars) newdata<-data[myvars] Var_Conv<-newdata Var_Conv$variance<-Var_Conv[,1] mdata<-data.matrix(newdata) for (i in 1:nrow(newdata)) { Var_Conv$variance[i]<-var(mdata[i,]) } v = cbind(data[,1],Var_Conv$variance) write.table(v,"variance_converters.txt") #Redo for non-converter group (="NC") #F-test for the variance Clist<-subset(PHENO,Statut=="C") NClist<-subset(PHENO,Statut=="NC") myvarsC<-Clist$code.sample myvarsC<-as.character(myvarsC) myvarsNC<-NClist$code.sample myvarsNC<-as.character(myvarsNC) newdata1<-data[myvarsC] newdata2<-data[myvarsNC] nom=as.character(data[,1]) Ftest= matrix(data = NA, nrow = nrow(data), ncol = 1, byrow = FALSE, dimnames = list(nom)) for ( i in 1: nrow(newdata1)){ x=unlist(newdata1[i,]) y=unlist(newdata2[i,]) ftest=var.test(x,y,alternative="two.sided") Ftest[i]=ftest$p.value Ftest$fdr_adjust[i]<-p.adjust(ftest$p.value[i], method = "fdr", n = list(nom)) } write.table(Ftest,"Ftest_C_vs_NC.txt") ################################# ####### Detection of VMPs ####### ################################# # Compute the median: Example for the converter group (="C") mymed<-Clist$code.sample mymed<-as.character(mymed) newdata<-data[mymed] Med_Conv<-newdata Med_Conv$variance<-Med_Conv[,1] mdata<-data.matrix(newdata) for (i in 1:nrow(newdata)) { Med_Conv$median[i]<-median(mdata[i,]) } m = cbind(data[,1],Med_Conv$median) write.table(m,"VMP_converters.txt")