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 the code:
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]
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 This however may not be compatible with your platform. Getting involved what is a periphery topic for me at the cutting edge is something I'd rather avoid to be honest.
My answer is a bit of a ramble but sure you'll get the gist.