hansenlab / minfi

Devel repository for minfi
58 stars 67 forks source link

Problem in qcReport #260

Open lilwo opened 6 months ago

lilwo commented 6 months ago

Hello,recently I found a problem in minfi with EPIC V2, when i run : a = qcReport(exp, sampNames = pd$Sample_Name, sampGroups = pd$Sample_Group, pdf = "2_Data_QC/QCReport.pdf",maxSamplesPerPage = nrow(pd)) the result was wrong with Green and Red ,The red and green labels are upside down,how to fix it ? 1704436198056 1704436198056

lilwo commented 6 months ago

sessionInfo() R version 4.2.2 (2022-10-31) Platform: x86_64-conda-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS/LAPACK: /data3/luolf/miniconda3/envs/R4.2/lib/libopenblasp-r0.3.21.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats4 parallel splines stats graphics grDevices utils
[8] datasets methods base

other attached packages: [1] IlluminaHumanMethylationEPICv2anno.20a1.hg38_0.99.0 [2] IlluminaHumanMethylationEPICv2manifest_0.99.1
[3] minfi_1.44.0
[4] bumphunter_1.40.0
[5] SummarizedExperiment_1.28.0
[6] MatrixGenerics_1.10.0
[7] matrixStats_1.0.0
[8] locfit_1.5-9.7
[9] iterators_1.0.14

biga94 commented 2 days ago

Hi, did you find the solution?

This is due to lack of factorization of Red and Green labels in controlStripPlot() function integrated qcReport() one. In order to solve the problem, you should rewrite the former function, adding factorization step. I'll share below a reproduction of the controlStripPlot() function with correct levels:

r <- getRed(RGset)
g <- getGreen(RGset)
controls <- c("BISULFITE CONVERSION I", "BISULFITE CONVERSION II")
for (controlType in controls) {
   ctrlAddress <- getControlAddress(RGset, controlType = controlType)
   ctlWide <- as.matrix(log2(r[ctrlAddress, , drop = FALSE]))
   ctlR <- reshape2::melt(ctlWide, varnames = c("address", "sample"))
   ctlWide <- as.matrix(log2(g[ctrlAddress, , drop = FALSE]))
   ctlG <- reshape2::melt(ctlWide, varnames = c("address", "sample"))
   ctl <- rbind(cbind(channel = "Red", ctlR), cbind(channel = "Green", 
                                                    ctlG))
   #factorization step
   ctl$channel <- factor(ctl$channel, levels = c("Red", "Green"))

   xlim <- c(5,17)
   fig <- lattice::xyplot(x = sample ~ value | channel, groups = channel, 
                 horizontal = TRUE, pch = 19, col = c("darkred", "darkgreen"), 
                 xlab = "Log2 Intensity", xlim = xlim, main = paste("Control:", 
                                                                    controlType), layout = c(2, 1), data = ctl, panel = function(x, 
                                                                                                                                 y, ...) {
                                                                       lattice::panel.stripplot(x, y, ...)
                                                                       lattice::panel.abline(h = (as.numeric(y) - 0.5), lty = 3, 
                                                                                    col = "grey70")
                                                                    })
   print(fig)
}