The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

MLML2R package User’s Guide

Samara F. Kiihl and Maria Tellez-Plaza

2019-10-17

Abstract

We present a guide to the R package MLML2R. The package provides computationally efficient maximum likelihood estimates of DNA methylation and hydroxymethylation proportions when single nucleotide resolution data from the DNA processing methods bisulfite conversion (BS), oxidative bisulfite conversion (ox-BS), and Tet-assisted bisulfite conversion (TAB) are available. Estimates can be obtained by combining any two of the methods, or all the three methods (if available). The package does not depend on other R packages, allowing the user to read and preprocess the data with any given software, to import the results into R in matrix format, to obtain the maximum likelihood estimates for methylation and hydroxymethylation proportions and use them as input for other packages traditionally used in genomic data analysis, such as minfi, sva and limma.

Introduction

In a given CpG site from a single cell we will either have a C or a T after bisulfite-based DNA conversion methods. We asume a Binomial model and maximum likelihood estimation to obtain consistent hydroxymethylation and methylation proportions with single nucleotide resolution. MLML2R package allows the user to jointly estimate hydroxymethylation and methylation consistently and efficiently.

T reads are referred to as converted cytosine and C reads are referred to as unconverted cytosine. In case of Infinium Methylation arrays, we have intensities representing the unconverted (M) and converted (U) channels. The most used summary from these experiments is the proportion \(\beta=\frac{M}{M+U}\), commonly referred to as . Naively using the difference between betas from BS and oxBS as an estimate of 5-hmC (hydroxymethylated cytosine), and the difference between betas from BS and TAB as an estimate of 5-mC (methylated cytosine) can many times provide negative proportions and instances where the sum of uC (unmodified cytosine), 5-mC and 5-hmC proportions is greater than one due.

The function MLML takes as input the data from the different bisulfite-based methods and returns the estimated proportion of methylation, hydroxymethylation and unmethylation for a given CpG site. Table 1 presents the arguments of the MLML and Table 2 lists the results returned by the function.

The function assumes that the order of the samples by rows and columns in the input matrices is consistent. In addition, all the input matrices must have the same dimension. In the provided examples, rows represent CpG loci and columns represent samples. Nonetheless transposed matrices can also be supplied.

MLML function and random variable notation.
Arguments Description
U.matrix Converted cytosines (T counts or U channel) from standard BS-conversion (reflecting True 5-C).
T.matrix Unconverted cytosines (C counts or M channel) from standard BS-conversion (reflecting 5-mC+5-hmC).
G.matrix Converted cytosines (T counts or U channel) from TAB-conversion (reflecting 5-C + 5-mC).
H.matrix Unconverted cytosines (C counts or M channel) from TAB-conversion (reflecting True 5-hmC).
L.matrix Converted cytosines (T counts or U channel) from oxBS-conversion (reflecting 5-C + 5-hmC).
M.matrix Unconverted cytosines (C counts or M channel) from oxBS-conversion (reflecting True 5-mC).
Results returned from the MLML function
Value Description
mC maximum likelihood estimate for the proportion of methylation
hmC maximum likelihood estimate for the proportion of hydroxymethylation
C maximum likelihood estimate for the proportion of unmethylation
methods the conversion methods used to produce the MLE

Worked examples

Publicly available array data: oxBS and BS methods

We will use the dataset from Field (2015), which consists of eight DNA samples from the same DNA source treated with oxBS and BS and hybridized to the Infinium 450K array.

When data is obtained through Infinium Methylation arrays, we recommend the use of the minfi package (Aryee et al. 2014), a well-established tool for reading, preprocessing and analysing DNA methylation data from these platforms. Although our example relies on minfi and other Bioconductor tools, MLML2R does not depend on any packages. Thus, the user is free to read and preprocess the data using any software of preference and then import into R in matrix format the intensities from the M and U channels (or C and T counts from sequencing) reflecting unconverted and converted cytosines, respectively.

To start this example we will need the following packages:

It is usually best practice to start the analysis from the raw data, which in the case of the 450K array is a file.

The raw files are deposited in GEO and can be downloaded by using the getGEOSuppFiles. There are two files for each replicate, since the 450k array is a two-color array. The files are downloaded in compressed format and need to be uncompressed before they are read by the read.metharray.exp function.

The files can now be read:

To access phenotype data we use the pData function. The phenotype data is not yet available from the rgSet.

In this example the phenotype is not really relevant, since we have only one sample: male, 25 years old. What we do need is the information about the conversion method used in each replicate: BS or oxBS. We will access this information automatically from GEO:

This phenotype data needs to be merged into the methylation data. The following commands guarantee we have the same replicate identifier in both datasets before merging.

The rgSet is an object from RGChannelSet class used for two color data (green and red channels). The input in the MLML function are matrices with methylated and unmethylated information from each conversion method. We can use the MethylSet class, which contains the methylated and unmethylated signals. The most basic way to construct a MethylSet is using the function preprocessRaw.

Here we chose the function preprocessNoob (Triche et al. 2013) for background correction, dye bias normalization and construction of the MethylSet. We encourage the user to consider other normalization methods such as SWAN (Maksimovic, Gordon, and Oshlack 2012), BMIQ (Teschendorff et al. 2012), RCP (Niu, Xu, and Taylor 2016), Funnorm (Fortin et al. 2014), and others, as well as combination of some of these methods, as suggested by Liu and Siegmund (2016).

The BS replicates are in columns 1, 3, 5, and 6 (information from pD$title). The remaining columns are from the oxBS treated replicates.

After the preprocessing steps we can use MLML from the MLML2R package.

When only two methods are available, the default option of MLML function returns the exact constrained maximum likelihood estimates using the the pool-adjacent-violators algorithm (PAVA) (Ayer et al. 1955).

Maximum likelihood estimate via EM-algorithm approach (Qu et al. 2013) is obtained with the option . In this case, the default (or user specified) is considered in the iterative method.

The estimates are very similar for both methods:

Estimated proportions of 5-hmC, 5-mC and uC for the CpGs in the dataset from Field (2015) using the MLML function with default (PAVA) options (top row) and the naïve (subtraction) method (bottom row).

Publicly available array data: TAB and BS methods

We will use the dataset from Thienpont et al. (2016), which consists of 24 DNA samples treated with TAB-BS and hybridized to the Infinium 450K array from newly diagnosed and untreated non-small-cell lung cancer patients (12 normoxic and 12 hypoxic tumours). The dataset is deposited under GEO accession number GSE71398.

We will need the following packages:

Obtaining the data:

Reading the files:

The phenotype data is not yet available from the rgSet.

We need to correctly identify the 24 DNA samples: 12 normoxic and 12 hypoxic non-small-cell lung cancer. We also need the information about the conversion method used in each replicate: BS or TAB. We will access this information automatically from GEO:

This phenotype data needs to be merged into the methylation data. The following commands guarantee we have the same replicate identifier in both datasets before merging.

The following command produces a quality control report, which helps to identify failed samples:

After looking at the quality control report, we notice a problematic sample: GSM1833667. This sample and its corresponding pair in the TAB experiment, GSM1833691, were removed from subsequent analysis.

The input in the MLML function accepts as input a MethylSet, which contains the methylated and unmethylated signals. We used the function preprocessNoob (Triche et al. 2013) for background correction, dye bias normalization and construction of the MethylSet.

We can now use MLML from the MLML2R package.

One needs to carefully check if the columns across the different input matrices represent the same sample. In this example, all matrices have the samples consistently represented in the columns: sample 1 in the first column, sample 2 in the second, and so forth.

When any two of the methods are available, the default option of MLML function returns the exact constrained maximum likelihood estimates using the the pool-adjacent-violators algorithm (PAVA) (Ayer et al. 1955).

Maximum likelihood estimate via EM-algorithm approach (Qu et al. 2013) is obtained with the option . In this case, the default (or user specified) is considered in the iterative method.

The estimates for 5-hmC proportions are very similar for both methods:

The estimates for 5-mC proportions are very similar for both methods:

Estimated proportions of 5-hmC, 5-mC and uC for the CpGs in the dataset from Thienpont et al (2016), using the MLML function with default (PAVA) options (top row) and the naïve (subtraction) method (bottom row).

Publicly available sequencing data: oxBS and BS methods

We will use the dataset from Li et al. (2016), which consists of three human lung normal-tumor pairs (six samples). Each sample was divided into two replicates: one treated with BS and the other with oxBS, which were then sequenced using the Illumina HiSeq 2000 (Homo sapiens) platform. The preprocessed dataset is available at GEO accession GSE70090. The details of the preprocessing procedures are described in Li et al. (2016).

Obtaining the data:

Decompressing the files:

We need to identify the different samples from different methods (BS-conversion, oxBS-conversion), we will use the file names do extract this information.

Selecting only the three human lung normal-tumor pairs:

Preparing the data for input in the MLML function:

Only CpGs with coverage of at least 10 across all samples and all conversion procedures (BS and oxBS) were considered in the following results (\(7685557\) CpGs).

We can now use MLML from the MLML2R package.

Comparing the estimates for 5-hmC proportions from iterative and non iterative option from MLML function:

The estimates for 5-mC proportions are also very similar for both methods:

Estimated proportions of 5-hmC, 5-mC and uC for the CpGs in the dataset from Li et al (2016) using the MLML function with default options (top row) and the naïve method (bottom row).

Simulated data

To illustrate the package when all the three methods are available or when any combination of only two of them are available, we will simulate a dataset.

We will use a sample of the estimates of 5-mC, 5-hmC and uC of the previous oxBS+BS array example shown in Section 2.1 as the true proportions, as shown in Figure 4.

Two replicate samples with 1000 CpGs will be simulated. For CpG \(i\) in sample \(j\):

\[T_{i,j} \sim Binomial(n=c_{i,j},p=p_m+p_h)\] \[M_{i,j} \sim Binomial(n=c_{i,j}, p=p_m)\] \[H_{i,j} \sim Binomial(n=c_{i,j},p=p_h)\] \[U_{i,j}=c_{i,j}-T_{i,j}\] \[L_{i,j}=c_{i,j}-M_{i,j}\] \[G_{i,j}=c_{i,j}-H_{i,j}\] where the random variables are defined in Table 1, and \(c_{i,j}\) represents the coverage for CpG \(i\) in sample \(j\).

The following code produce the simulated data:

True proportions of hydroxymethylation, methylation and unmethylation for the CpGs used to generate the datasets.

BS and oxBS methods

When only two methods are available, the default option returns the exact constrained maximum likelihood estimates using the the pool-adjacent-violators algorithm (PAVA) (Ayer et al. 1955).

Maximum likelihood estimate via EM-algorithm approach (Qu et al. 2013) is obtained with the option . In this case, the default (or user specified) is considered in the iterative method.

When only two methods are available, we highly recommend the default option iterative=FALSE since the difference in the estimates obtained via EM and exact constrained is very small, but the former requires more computational effort:

## [1] "Mean absolute difference: 0.0001259144"
## Unit: microseconds
##   expr      min        lq       mean    median        uq       max neval
##  EXACT   326.82   330.812   355.7758   362.071   376.021   383.094    10
##     EM 11344.99 11380.829 15047.9919 14060.733 18036.976 22099.924    10

Comparison between approximate exact constrained and true hydroxymethylation proportion used in simulation:

## [1] "Mean absolute difference: 0.005980957"

Comparison between EM-algorithm and true hydroxymethylation proportion used in simulation:

## [1] "Mean absolute difference: 0.005396121"

BS and TAB methods

Using PAVA:

Using EM-algorithm:

Comparison between PAVA and EM:

## [1] "Mean absolute difference: 3.196297e-07"
## Unit: microseconds
##   expr      min       lq       mean   median        uq       max neval
##  EXACT  273.728  304.580   329.9849  326.352   339.855   417.075    10
##     EM 7725.195 8041.412 10168.5659 8118.890 13444.838 17243.782    10

Comparison between approximate exact constrained and true hydroxymethylation proportion used in simulation:

## [1] "Mean absolute difference: 0.0030728"

Comparison between EM-algorithm and true hydroxymethylation proportion used in simulation:

## [1] "Mean absolute difference: 0.002319746"

oxBS and TAB methods

Using PAVA:

Using EM-algorithm:

Comparison between PAVA and EM:

## [1] "Mean absolute difference: 1.435988e-07"
## Unit: microseconds
##   expr      min       lq      mean    median      uq      max neval
##  EXACT  284.974  286.627  322.4396  317.0385  327.63  438.802    10
##     EM 3787.138 4210.131 4905.9586 4335.6385 4914.47 9189.128    10

Comparison between approximate exact constrained and true 5-hmC proportion used in simulation:

## [1] "Mean absolute difference: 0.0030728"

Comparison between EM-algorithm and true 5-hmC proportion used in simulation:

## [1] "Mean absolute difference: 0.003072645"

BS, oxBS and TAB methods

When data from the three methods are available, the default otion in the MLML function returns the constrained maximum likelihood estimates using an approximated solution for Lagrange multipliers method.

Maximum likelihood estimate via EM-algorithm approach (Qu et al. 2013) is obtained with the option . In this case, the default (or user specified) is considered in the iterative method.

We recommend the default option iterative=FALSE since the difference in the estimates obtained via EM and the approximate exact constrained is very small, but the former requires more computational effort:

## [1] "Mean absolute difference: 6.665856e-07"
## Unit: microseconds
##   expr      min       lq      mean   median       uq      max neval
##  EXACT  774.052  831.928  837.5381  845.681  861.877  881.112    10
##     EM 2086.890 2173.113 2786.4026 2199.387 2238.607 8107.848    10

Comparison between approximate exact constrained and true hydroxymethylation proportion used in simulation:

## [1] "Mean absolute difference: 0.002708598"

Comparison between EM-algorithm and true hydroxymethylation proportion used in simulation:

## [1] "Mean absolute difference: 0.002045009"

References

Aryee, Martin J., Andrew E. Jaffe, Hector Corrada-Bravo, Christine Ladd-Acosta, Andrew P. Feinberg, Kasper D. Hansen, and Rafael A. Irizarry. 2014. “Minfi: A flexible and comprehensive Bioconductor package for the analysis of Infinium DNA Methylation microarrays.” Bioinformatics 30 (10): 1363–9. https://doi.org/10.1093/bioinformatics/btu049.

Ayer, Miriam, H. D. Brunk, G. M. Ewing, W. T. Reid, and Edward Silverman. 1955. “An Empirical Distribution Function for Sampling with Incomplete Information.” Ann. Math. Statist. 26 (4). The Institute of Mathematical Statistics: 641–47. https://doi.org/10.1214/aoms/1177728423.

Field, Dario AND Bachman, Sarah F. AND Beraldi. 2015. “Accurate Measurement of 5-Methylcytosine and 5-Hydroxymethylcytosine in Human Cerebellum Dna by Oxidative Bisulfite on an Array (Oxbs-Array).” PLOS ONE 10 (2). Public Library of Science: 1–12. https://doi.org/10.1371/journal.pone.0118202.

Fortin, Jean-Philippe, Aurelie Labbe, Mathieu Lemire, Brent W. Zanke, Thomas J. Hudson, Elana J. Fertig, Celia M.T. Greenwood, and Kasper D. Hansen. 2014. “Functional Normalization of 450k Methylation Array Data Improves Replication in Large Cancer Studies.” Genome Biology 15 (12): 503. https://doi.org/10.1186/s13059-014-0503-2.

Li, Xin, Yun Liu, Tal Salz, Kasper D. Hansen, and Andrew Feinberg. 2016. “Whole-Genome Analysis of the Methylome and Hydroxymethylome in Normal and Malignant Lung and Liver.” Genome Research 26 (12). Cold Spring Harbor Laboratory: 1730–41. https://doi.org/10.1101/gr.211854.116.

Liu, Jie, and Kimberly D. Siegmund. 2016. “An Evaluation of Processing Methods for HumanMethylation450 BeadChip Data.” BMC Genomics 17 (1). Springer Nature. https://doi.org/10.1186/s12864-016-2819-7.

Maksimovic, Jovana, Lavinia Gordon, and Alicia Oshlack. 2012. “SWAN: Subset-Quantile Within Array Normalization for Illumina Infinium HumanMethylation450 BeadChips.” Genome Biology 13 (6). Springer Nature: R44. https://doi.org/10.1186/gb-2012-13-6-r44.

Niu, Liang, Zongli Xu, and Jack A. Taylor. 2016. “RCP: A Novel Probe Design Bias Correction Method for Illumina Methylation BeadChip.” Bioinformatics 32 (17). Oxford University Press (OUP): 2659–63. https://doi.org/10.1093/bioinformatics/btw285.

Qu, Jianghan, Meng Zhou, Qiang Song, Elizabeth E. Hong, and Andrew D. Smith. 2013. “MLML: Consistent Simultaneous Estimates of Dna Methylation and Hydroxymethylation.” Bioinformatics 29 (20): 2645–6. https://doi.org/10.1093/bioinformatics/btt459.

Teschendorff, Andrew E., Francesco Marabita, Matthias Lechner, Thomas Bartlett, Jesper Tegner, David Gomez-Cabrero, and Stephan Beck. 2012. “A Beta-Mixture Quantile Normalization Method for Correcting Probe Design Bias in Illumina Infinium 450 K DNA Methylation Data.” Bioinformatics 29 (2). Oxford University Press (OUP): 189–96. https://doi.org/10.1093/bioinformatics/bts680.

Thienpont, Bernard, Jessica Steinbacher, Hui Zhao, Flora D’Anna, Anna Kuchnio, Athanasios Ploumakis, Bart Ghesquière, et al. 2016. “Tumour Hypoxia Causes DNA Hypermethylation by Reducing TET Activity.” Nature 537 (7618). Springer Nature: 63–68. https://doi.org/10.1038/nature19081.

Triche, Timothy J., Daniel J. Weisenberger, David Van Den Berg, Peter W. Laird, and Kimberly D. Siegmund. 2013. “Low-Level Processing of Illumina Infinium DNA Methylation BeadArrays.” Nucleic Acids Research 41 (7): e90. https://doi.org/10.1093/nar/gkt090.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.