normalizatino of dna methylation EPIC data
1
0
Entering edit mode
@9ae4560e
Last seen 6 hours ago
France

Hello, i am working on DNA methylation data analysis in R on a server and performing QC but when i run the preprocessnoob function im getting this error Error in matrixStats::colMeans2(x, rows = rows, cols = cols, na.rm = na.rm, : Argument 'useNames' must be either TRUE or FALSE . How can i avoid it?

# This script will perform QC for DNA methylation data

# Upload necessary packages/libraries
packages <- c("minfi", "RColorBrewer", "illuminaio",
              "IlluminaHumanMethylationEPICmanifest",
              "IlluminaHumanMethylationEPICanno.ilm10b4.hg19", "ggplot2", "readr")

for (pkg in packages) {
  if (!require(pkg, character.only = TRUE)) {
    if (pkg %in% c("minfi", "illuminaio", "IlluminaHumanMethylationEPICmanifest", "IlluminaHumanMethylationEPICanno.ilm10b4.hg19")) {
      BiocManager::install(pkg, force = TRUE)
    } else {
      install.packages(pkg)
    }
  }
  library(pkg, character.only = TRUE)
}


# Seeting directory
setwd("~path1/idats")
data_directory <- "~path2/EPIC"
base_directory <- "~/path1/idats/"

# uploading and organizing the samplesheet that contains the methyation infos
samplesheet <- read.metharray.sheet(data_directory, pattern = "samplesheet.csv")

# Read IDAT files using minfi 
rgSet <- read.metharray.exp(targets = samplesheet)
pd <- pData(rgSet) # extract the data in rgSet as a Data frame, not necessary 
manifest <- getManifest(rgSet)
manifest
head(getProbeInfo(manifest))

# give tyhe samples descriptive names

# Pre-Normalization QC (Optional Visual Check)
densityPlot(rgSet, main = "Raw Intensities")
controlStripPlot(rgSet) # Control probes visualization: This plot is part of the quality control to check bisulfite conversion efficiency. 
qc_report_path <- file.path(data_directory, "qc_report_raw.pdf") 
qcReport(rgSet, pdf = qc_report_path) 
qcReport(rgSet, pdf = "qc_report_raw.pdf")


# QC after normalization
# Normalization using preprocessNoob so we can have 'MethylSet' Object for QC
mset_noob <- preprocessNoob(rgSet)

qc <- getQC(mset_noob)
plotQC(qc)
densityPlot(mset_noob, main = "Normalized Beta Values")



    sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 11 (bullseye)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.13.so

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

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

other attached packages:
 [1] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0 readr_2.1.5                                        
 [3] illuminaio_0.40.0                                   ggplot2_3.5.1                                      
 [5] RColorBrewer_1.1-3                                  IlluminaHumanMethylationEPICmanifest_0.3.0         
 [7] minfi_1.44.0                                        bumphunter_1.40.0                                  
 [9] locfit_1.5-9.11                                     iterators_1.0.14                                   
[11] foreach_1.5.2                                       Biostrings_2.66.0                                  
[13] XVector_0.38.0                                      SummarizedExperiment_1.28.0                        
[15] Biobase_2.58.0                                      MatrixGenerics_1.10.0                              
[17] matrixStats_1.5.0                                   GenomicRanges_1.50.2                               
[19] GenomeInfoDb_1.34.9                                 IRanges_2.32.0                                     
[21] S4Vectors_0.36.2                                    BiocGenerics_0.44.0                                
[23] BiocManager_1.30.25                                

loaded via a namespace (and not attached):
  [1] colorspace_2.1-1          rjson_0.2.23              siggenes_1.72.0           mclust_6.1.1             
  [5] base64_2.0.2              rstudioapi_0.17.1         bit64_4.6.0-1             AnnotationDbi_1.60.2     
  [9] xml2_1.3.6                codetools_0.2-19          splines_4.2.3             sparseMatrixStats_1.10.0 
 [13] cachem_1.1.0              scrime_1.3.5              knitr_1.49                Rsamtools_2.14.0         
 [17] gt_0.11.1                 annotate_1.76.0           dbplyr_2.5.0              png_0.1-8                
 [21] HDF5Array_1.26.0          compiler_4.2.3            httr_1.4.7                Matrix_1.5-3             
 [25] fastmap_1.2.0             limma_3.54.2              cli_3.6.4                 htmltools_0.5.8.1        
 [29] prettyunits_1.2.0         tools_4.2.3               gtable_0.3.6              glue_1.8.0               
 [33] GenomeInfoDbData_1.2.9    dplyr_1.1.4               rappdirs_0.3.3            doRNG_1.8.6.1            
 [37] Rcpp_1.0.14               cellranger_1.1.0          vctrs_0.6.5               rhdf5filters_1.10.1      
 [41] multtest_2.54.0           preprocessCore_1.60.2     nlme_3.1-162              rtracklayer_1.58.0       
 [45] DelayedMatrixStats_1.20.0 xfun_0.51                 stringr_1.5.1             lifecycle_1.0.4          
 [49] restfulr_0.0.15           rngtools_1.5.2            XML_3.99-0.18             beanplot_1.3.1           
 [53] zlibbioc_1.44.0           MASS_7.3-58.2             scales_1.3.0              ragg_1.3.3               
 [57] hms_1.1.3                 rhdf5_2.42.1              GEOquery_2.66.0           yaml_2.3.10              
 [61] curl_6.2.1                memoise_2.0.1             biomaRt_2.54.1            reshape_0.8.9            
 [65] stringi_1.8.4             RSQLite_2.3.9             genefilter_1.80.3         BiocIO_1.8.0             
 [69] GenomicFeatures_1.50.4    filelock_1.0.3            BiocParallel_1.32.6       systemfonts_1.2.1        
 [73] rlang_1.1.5               pkgconfig_2.0.3           bitops_1.0-9              nor1mix_1.3-3            
 [77] evaluate_1.0.3            lattice_0.20-45           purrr_1.0.4               Rhdf5lib_1.20.0          
 [81] GenomicAlignments_1.34.1  bit_4.5.0.1               tidyselect_1.2.1          plyr_1.8.9               
 [85] magrittr_2.0.3            R6_2.6.1                  generics_0.1.3            DelayedArray_0.24.0      
 [89] DBI_1.2.3                 withr_3.0.2               pillar_1.10.1             survival_3.5-3           
 [93] KEGGREST_1.38.0           RCurl_1.98-1.16           tibble_3.2.1              crayon_1.5.3             
 [97] BiocFileCache_2.6.1       rmarkdown_2.29            tzdb_0.4.0                progress_1.2.3           
[101] readxl_1.4.3              grid_4.2.3                data.table_1.16.4         blob_1.2.4               
[105] digest_0.6.37             xtable_1.8-4              tidyr_1.3.1               textshaping_1.0.0        
[109] munsell_0.5.1             openssl_2.3.2             sessioninfo_1.2.3         askpass_1.2.1            
[113] quadprog_1.5-8 
DNA minfiData minfiDataEPIC DNAMethylation minfi • 242 views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

Your code doesn't show the error?

Anyway, the default for colMeans2 is useNames = TRUE, and the call to colMeans2 in preprocessNoob doesn't have an ellipsis argument, so I don't see how the argument is getting set to anything but the default. Given that, you will probably have to run under the debugger and figure it out for yourself.

debug(minfi:::dyeCorrection)
mset_noob <- preprocessNoob(rgSet)

And then step through the debugger until you get to this part:

 # Dye bias normalization with the corrected Illumina control probes
    Green.avg <- colMeans2(x = internal.controls[["Green"]], rows = CG.controls)
    Red.avg <- colMeans2(x = internal.controls[["Red"]], rows = AT.controls)

and try to figure out how the useNames argument is being set.

0
Entering edit mode

yes actually that's why I did, and its all good! thank you for your response

ADD REPLY

Login before adding your answer.

Traffic: 860 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