Batch correction using control probes in EPIC array data
1
0
Entering edit mode
Jitendra ▴ 10
@nabiyogesh-11718
Last seen 4 months ago
United Kingdom

Hi all,

I am trying to use below script for batch correction for epic array data, but not sure what R packages need for controlVariation() function? or is there another way to correct for batch effect using control probes

Load the required libraries:

library(RnBeads)
library(minfi)
library(IlluminaHumanMethylationEPICanno.ilm10b2.hg19)

Import the methylation data and sample information:

samples <- read.table("sample_table.txt", header=TRUE)
methylation_data <- read.metharray.exp("methylation_data.txt")
methylation_data <- as.matrix(methylation_data[, -1]) # Remove the first column (IDs)
colnames(methylation_data) <- samples$ID # Rename the columns with sample IDs

Preprocess the methylation data:

methylation_data <- preprocessMethylationSet(methylation_data)

Extract the control probes:

control_probes <- getEpicControlProbeIDs()
methylation_data_control <- methylation_data[control_probes, ]

Normalize the control data:
methylation_data_control <- preprocessRaw(methylation_data_control, bg.correct=TRUE, normalize="controls")

Estimate the technical variation:

control_stats <- controlVariation(methylation_data_control)

Correct for batch effects in the methylation data:

methylation_data_corrected <- preprocessRaw(methylation_data, bg.correct=TRUE, normalize="controls", control.stats=control_stats)

Many thanks, bioinfo

RnBeads minfiData minfi EPICarray • 1.3k views
ADD COMMENT
0
Entering edit mode

Where does this code come from? I am not aware of any package containing controlVariation according to a quick google search. It might come from a custom code used by the creator of this script.

ADD REPLY
0
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

Where are you getting those arguments? The function you are using has only one argument, and it's the name of the RGChannelSet that you are supposed to pass in. In fact, the code you present doesn't work at all!

> preprocessRaw(RGsetEx, bg.correct = TRUE, normalize = "controls")
Error in preprocessRaw(RGsetEx, bg.correct = TRUE, normalize = "controls") : 
  unused arguments (bg.correct = TRUE, normalize = "controls")

Which should be an indication to you that you need to read the help page first!

A better way to proceed is to read the help pages and the vignettes and the workflow

Having done so, you might come across preprocessFunnorm, which has this in the description.

preprocessFunnorm            package:minfi             R Documentation

Functional normalization for Illumina 450k arrays

Description:

     Functional normalization (FunNorm) is a between-array
     normalization method for the Illumina Infinium HumanMethylation450
     platform. It removes unwanted variation by regressing out
     variability explained by the control probes present on the array.

Usage:

     preprocessFunnorm(rgSet, nPCs=2, sex = NULL, bgCorr = TRUE,
                       dyeCorr = TRUE, keepCN = TRUE, ratioConvert = TRUE,
                       verbose = TRUE)

Which is, I believe, what you are looking for.

ADD COMMENT
0
Entering edit mode

100% agree, this code is full of custom functions, with some of them being aliases of functions already existing in minfi, which is dangerous

ADD REPLY

Login before adding your answer.

Traffic: 619 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6