Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch correction using control probe #246

Open
bioinfonext opened this issue May 15, 2023 · 0 comments
Open

batch correction using control probe #246

bioinfonext opened this issue May 15, 2023 · 0 comments

Comments

@bioinfonext
Copy link

bioinfonext commented May 15, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant