Introduction

This vignette describes basic usage of the package intended to process several large bedgraph files in R. Methrix provides set of function which allows easy importing of various flavors of bedgraphs generated by methylation callers, and many downstream analysis to be performed on large matrices.

Overview and usage functions of the package

Reading bedgraph files

read_bedgraphs function is a versatile bedgraph reader intended to import bedgraph files generated virtually by any sort of methylation calling program. It requires user to provide indices for chromosome names, start position and other required fields. There are also presets available to import bedgraphs from most common programs such as Bismark, MethylDackel, and MethylcTools.

We can import bedgraph files with the function read_bedgraphs which reads in the bedgraphs, adds CpGs missing from the reference set, and creates a methylation/coverage matrices. Once the process is complete - it returns an object of class methrix which in turn inherits SummarizedExperiment class. methrix object contains ‘methylation’ and ‘coverage’ matrices (either in-memory or as on-disk HDF5 arrays) along with pheno-data and other basic info. This object can be passed to all downstream functions for various analysis.

Note: Use the argument pipeline if your bedgraphs are generated with “Bismark”, “MethylDeckal”, or “MethylcTools”. This will automatically figure out the file formats for you, and you dont have to use the arguments chr_idx start_idx and so..

HTML QC report

Get basic summary statistics of the methrix object with methrix_report function which produces an interactive html report

Basic operations

Extract methylation/coverage matrices

SessionInfo

sessionInfo()
#> R version 4.0.0 (2020-04-24)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.11-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
#>  [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] parallel  stats4    stats     graphics  grDevices utils     datasets 
#> [8] methods   base     
#> 
#> other attached packages:
#>  [1] bsseq_1.24.1                         MafDb.1Kgenomes.phase3.hs37d5_3.10.0
#>  [3] GenomicScores_2.0.0                  BSgenome.Hsapiens.UCSC.hg19_1.4.3   
#>  [5] BSgenome_1.56.0                      rtracklayer_1.48.0                  
#>  [7] Biostrings_2.56.0                    XVector_0.28.0                      
#>  [9] methrix_1.2.06                       SummarizedExperiment_1.18.1         
#> [11] DelayedArray_0.14.0                  matrixStats_0.56.0                  
#> [13] Biobase_2.48.0                       GenomicRanges_1.40.0                
#> [15] GenomeInfoDb_1.24.0                  IRanges_2.22.2                      
#> [17] S4Vectors_0.26.1                     BiocGenerics_0.34.0                 
#> [19] data.table_1.12.8                   
#> 
#> loaded via a namespace (and not attached):
#>  [1] bitops_1.0-6                  bit64_0.9-7                  
#>  [3] RColorBrewer_1.1-2            httr_1.4.1                   
#>  [5] tools_4.0.0                   R6_2.4.1                     
#>  [7] HDF5Array_1.16.0              DBI_1.1.0                    
#>  [9] colorspace_1.4-1              permute_0.9-5                
#> [11] tidyselect_1.1.0              bit_1.1-15.2                 
#> [13] curl_4.3                      compiler_4.0.0               
#> [15] labeling_0.3                  scales_1.1.1                 
#> [17] rappdirs_0.3.1                stringr_1.4.0                
#> [19] digest_0.6.25                 Rsamtools_2.4.0              
#> [21] rmarkdown_2.1                 R.utils_2.9.2                
#> [23] pkgconfig_2.0.3               htmltools_0.4.0              
#> [25] limma_3.44.1                  dbplyr_1.4.4                 
#> [27] fastmap_1.0.1                 rlang_0.4.6                  
#> [29] RSQLite_2.2.0                 shiny_1.4.0.2                
#> [31] DelayedMatrixStats_1.10.0     generics_0.0.2               
#> [33] farver_2.0.3                  gtools_3.8.2                 
#> [35] BiocParallel_1.22.0           dplyr_1.0.0                  
#> [37] R.oo_1.23.0                   RCurl_1.98-1.2               
#> [39] magrittr_1.5                  GenomeInfoDbData_1.2.3       
#> [41] Matrix_1.2-18                 Rcpp_1.0.4.6                 
#> [43] munsell_0.5.0                 Rhdf5lib_1.10.0              
#> [45] lifecycle_0.2.0               R.methodsS3_1.8.0            
#> [47] stringi_1.4.6                 yaml_2.2.1                   
#> [49] zlibbioc_1.34.0               rhdf5_2.32.0                 
#> [51] BiocFileCache_1.12.0          AnnotationHub_2.20.0         
#> [53] grid_4.0.0                    blob_1.2.1                   
#> [55] promises_1.1.0                crayon_1.3.4                 
#> [57] lattice_0.20-41               locfit_1.5-9.4               
#> [59] knitr_1.28                    pillar_1.4.4                 
#> [61] rjson_0.2.20                  XML_3.99-0.3                 
#> [63] glue_1.4.1                    BiocVersion_3.11.1           
#> [65] evaluate_0.14                 BiocManager_1.30.10          
#> [67] vctrs_0.3.0                   httpuv_1.5.3.1               
#> [69] gtable_0.3.0                  purrr_0.3.4                  
#> [71] assertthat_0.2.1              ggplot2_3.3.1                
#> [73] xfun_0.14                     mime_0.9                     
#> [75] xtable_1.8-4                  later_1.0.0                  
#> [77] tibble_3.0.1                  GenomicAlignments_1.24.0     
#> [79] AnnotationDbi_1.50.0          memoise_1.1.0                
#> [81] ellipsis_0.3.1                interactiveDisplayBase_1.26.2