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 3.6.2 (2019-12-12)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.3 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.10-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.10-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.22.0                         MafDb.1Kgenomes.phase3.hs37d5_3.10.0
#>  [3] GenomicScores_1.10.0                 BSgenome.Hsapiens.UCSC.hg19_1.4.0   
#>  [5] BSgenome_1.54.0                      rtracklayer_1.46.0                  
#>  [7] Biostrings_2.54.0                    XVector_0.26.0                      
#>  [9] methrix_1.0.05                       SummarizedExperiment_1.16.1         
#> [11] DelayedArray_0.12.2                  BiocParallel_1.20.1                 
#> [13] matrixStats_0.55.0                   Biobase_2.46.0                      
#> [15] GenomicRanges_1.38.0                 GenomeInfoDb_1.22.0                 
#> [17] IRanges_2.20.1                       S4Vectors_0.24.1                    
#> [19] BiocGenerics_0.32.0                  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_3.6.2                   backports_1.1.5              
#>  [7] R6_2.4.1                      HDF5Array_1.14.1             
#>  [9] DBI_1.1.0                     lazyeval_0.2.2               
#> [11] colorspace_1.4-1              permute_0.9-5                
#> [13] tidyselect_0.2.5              bit_1.1-14                   
#> [15] curl_4.3                      compiler_3.6.2               
#> [17] labeling_0.3                  scales_1.1.0                 
#> [19] rappdirs_0.3.1                stringr_1.4.0                
#> [21] digest_0.6.23                 Rsamtools_2.2.1              
#> [23] rmarkdown_2.0                 R.utils_2.9.2                
#> [25] pkgconfig_2.0.3               htmltools_0.4.0              
#> [27] limma_3.42.0                  dbplyr_1.4.2                 
#> [29] fastmap_1.0.1                 rlang_0.4.2                  
#> [31] RSQLite_2.2.0                 shiny_1.4.0                  
#> [33] DelayedMatrixStats_1.8.0      farver_2.0.1                 
#> [35] gtools_3.8.1                  dplyr_0.8.3                  
#> [37] R.oo_1.23.0                   RCurl_1.95-4.12              
#> [39] magrittr_1.5                  GenomeInfoDbData_1.2.2       
#> [41] Matrix_1.2-18                 Rcpp_1.0.3                   
#> [43] munsell_0.5.0                 Rhdf5lib_1.8.0               
#> [45] lifecycle_0.1.0               R.methodsS3_1.7.1            
#> [47] stringi_1.4.3                 yaml_2.2.0                   
#> [49] zlibbioc_1.32.0               rhdf5_2.30.1                 
#> [51] BiocFileCache_1.10.2          AnnotationHub_2.18.0         
#> [53] grid_3.6.2                    blob_1.2.0                   
#> [55] promises_1.1.0                crayon_1.3.4                 
#> [57] lattice_0.20-38               locfit_1.5-9.1               
#> [59] zeallot_0.1.0                 knitr_1.26                   
#> [61] pillar_1.4.3                  rjson_0.2.20                 
#> [63] XML_3.98-1.20                 glue_1.3.1                   
#> [65] BiocVersion_3.10.1            evaluate_0.14                
#> [67] BiocManager_1.30.10           vctrs_0.2.1                  
#> [69] httpuv_1.5.2                  gtable_0.3.0                 
#> [71] purrr_0.3.3                   assertthat_0.2.1             
#> [73] ggplot2_3.2.1                 xfun_0.11                    
#> [75] mime_0.8                      xtable_1.8-4                 
#> [77] later_1.0.0                   tibble_2.1.3                 
#> [79] GenomicAlignments_1.22.1      AnnotationDbi_1.48.0         
#> [81] memoise_1.1.0                 interactiveDisplayBase_1.24.0