Okay I see. Basically there's a threshold for removing low intensity signal that can't be distinguished from background. That threshold seems tight at 1% of the mean of the normal distributio. Only the signal that is highly significantly above background signal is retained, i.e. subject to further analysis.
The way it works is that for a given CpG site there is a) methylated allele probe and b) unmethylated allele probe. The beta-value is a representation of those two intensities. What they want to do is filter out the background signal to avoid false positives.
Here's the manual https://bioconductor.org/packages/devel/bioc/vignettes/minfi/inst/doc/minfi.html#5_Quality_control
Here's a basic code (I stress the word basic) HOWEVER see the note on Noob in minfi below:
library(minfi)
myStuff <- read.metharray.exp("/Users/username/Desktop/myfile")
rgSet <- preprocessQuantile(myStuff)
M <- getM(rgSet)
U <- getU(rgSet)
beta <- M / (M + U)
filterProbesByZTest <- function(M, U, p.threshold = 0.01) {
n <- ncol(M)
filteredProbes <- rep(TRUE, ncol(M))
for (i in 1:ncol(M)) {
probeM <- M[, i]
probeU <- U[, i]
meanM <- mean(probeM, na.rm = TRUE)
meanU <- mean(probeU, na.rm = TRUE)
sdM <- sd(probeM, na.rm = TRUE)
sdU <- sd(probeU, na.rm = TRUE)
z_stat <- (meanM - meanU) / sqrt((sdM^2 / length(probeM)) + (sdU^2 / length(probeU)))
p_value <- 2 * pnorm(-abs(z_stat))
if (p_value > p.threshold) {
filteredProbes[i] <- FALSE
}
}
return(filteredProbes)
}
filteredProbes <- filterProbesByZTest(M, U, p.threshold = 0.01)
betaFiltered <- beta[, filteredProbes]
Note apart from being basic. the code isn't an exact replication of the authors method because they used Noob
ll data processing was performed in R (version 3.6.1; R Foundation for Statistical Computing, Vienna, Austria). Using the minfi library [26], raw IDAT files were imported; Noob normalization was performed [27]; and beta values were computed. Beta values whose corresponding intensities on probe-level failed a z-test with a P value threshold of 0.01 against background signal were masked.
preprocessNoob
by Triche et al (2013)
My suspicion is that preprocessNoob
comprises the above function. I'd need to read the paper in detail.
preprocessQuantile
was used above and was part of the original minfi package
Note A key minfi paper describing the implementation is:
https://genomebiology.biomedcentral.com/articles/10.1186/s13059-014-0503-2
The most advanced method I'm aware of is Heiss and Just (2019)
There guys have developed a different tool set ewastools ... if its compatible.
Getting involved what is a periphery topic for me at the cutting edge of the field is something I'd rather avoid, admittedly I'm heavily into cancer stuff.