LuxGLM: a probabilistic covariate model for quantification of DNA methylation modifications with complex experimental designs

October 21, 2024 · View on GitHub

Overview

LuxGLM is a method for quantifying oxi-mC species with arbitrary covariate structures from bisulphite based sequencing data. LuxGLM's probabilistic modeling framework combines a previously proposed hierarchical generative model of Lux for oxi-mC-seq data and a general linear model component to account for confounding effects.

Features

  • Model-based integration and analysis of BS-seq/oxBS-seq/TAB-seq/fCAB-seq/CAB-seq/redBS-seq/MAB-seq/etc. data from whole genome, reduced representation or targeted experiments
  • Accounts for confounding effects through general linear model component
  • Considers nonideal experimental parameters through modeling, including e.g. bisulphite conversion and oxidation efficiencies, various chemical labeling and protection steps etc.
  • Model-based integration of biological replicates
  • Detects differential methylation using Bayes factors (DMRs)
  • Full Bayesian inference using NumPyro

Quick introduction

An usual LuxGLM pipeline has the following steps

  1. Alignment of BS-seq and oxBS-seq data (e.g., Bismark or BSmooth)

  2. Extraction of converted and unconverted counts (e.g., Bismark or BSmooth)

  3. Integrative methylation analysis

  4. Analysis of obtained methylation estimates, e.g., using Bayes factors

This documentation focuses on the third and fourth points.

Installation

PyPI

$ pip install luxglm

GitHub

Install the version from the main branch as follows

$ pip install git+https://github.com/tare/LuxGLM.git

Usage

Metadata

Count data and covariates are defined in the metadata file.

namebasal/tgf-betavitcratimepointcount_filecontrol_count_filecontrol_definition_file
TGFb_1_24h10024wildtype/TGFb_1_24h.tsvcontrol/TGFb_1_24h_control.tsvcontrol_definitions.tsv
TGFb_1_38h10038wildtype/TGFb_1_38h.tsvcontrol/TGFb_1_38h_control.tsvcontrol_definitions.tsv
TGFb_1_48h10048wildtype/TGFb_1_48h.tsvcontrol/TGFb_1_48h_control.tsvcontrol_definitions.tsv

The following columns are mandatory: name, count_file, control_count_file, and control_definition. Additionally, there has to be at least one covariate. In the above example, we have four covariates: basal/tgf-beta, vitc, ra, and timepoint.

Control cytosines

The control cytosine data are supplied in the control count files. Each experiment will have its own file. The files contain location information (chromosome and position) and control type information (control_cytosine) for the control cytosines. Additionally, we have the number of Cs and and total number of read-outs from BS-seq and oxBS-seq experiments (bs_c, bs_total, oxbs_c, and oxbs_total).

chromosomepositioncontrol_typebs_cbs_totaloxbs_coxbs_total
Lambda_ctrl22924C23431562
Lambda_ctrl22928C23411561
Lambda_ctrl473595mC3770385747674877
Lambda_ctrl473675mC3895396248554979
Lambda_ctrl237895hmC3792396479865
Lambda_ctrl237945hmC3901411562934

The prior knowledge on the control cytosines is supplied in the control definition file. Note that control_type is used to link the control count data and control definitions.

control_typeC_pseudocount5mC_pseudocount5hmC_pseudocount
C99811
5mC19981
5hmC6272

Noncontrol cytosines

The non-control cytosine data are supplied in the count files. Each experiment will have its own file. The files contain location information (chromosome and position) for the non-control cytosines. Additionally, we have the number of Cs and and total number of read-outs from BS-seq and oxBS-seq experiments (bs_c, bs_total, oxbs_c, and oxbs_total).

chromosomepositionbs_cbs_totaloxbs_coxbs_total
chrX7159069108315638502736
chrX71591861341153421192719
chrX71592224949557538864639
chrX71592354831558843544641

LuxGLM analysis

The following lines are sufficient to run LuxGLM

import numpyro
from jax import random
from luxglm.inference import run_nuts
from luxglm.utils import get_input_data

numpyro.enable_x64()

# read input data
lux_input_data = get_input_data("metadata.tsv")

key = random.PRNGKey(0)
key, key_ = random.split(key)

# run LuxGLM
lux_result = run_nuts(
    key,
    lux_input_data,
    ["basal/tgf-beta"],
    num_warmup=1_000,
    num_samples=1_000,
    num_chains=4,
)

# ensure convergence
lux_result.inference_metrics["summary"].query("r_hat > 1.05")

To get the posterior samples of methylation levels of control and non-control cytosines one can call lux_result.methylation_controls() and lux_result.methylation(), respectively.

The posterior samples of experimental parameters can be obtained by calling lux_result.experimental_parameters().

To study the effects of the covariates, one can get the posterior samples of coefficients of covariates using lux_result.coefficients().

Examples

Please see the examples directory for the tutorial notebooks.

References

[1] T. Äijö, X. Yue, A. Rao and H. Lähdesmäki, “LuxGLM: a probabilistic covariate model for quantification of DNA methylation modifications with complex experimental designs.,” Bioinformatics, 32.17:i511-i519, Sep 2016.

[2] T. Äijö, Y. Huang, H. Mannerström, L. Chavez, A. Tsagaratou, A. Rao and H. Lähdesmäki, “A probabilistic generative model for quantification of DNA modifications enables analysis of demethylation pathways.,” Genome Biol, 17.1:1, Mar 2016.

[3] F. Krueger and S. R. Andrews, “Bismark: a flexible aligner and methylation caller for Bisulfite-Seq applications.,” Bioinformatics, 27.11:1571-1572, Jun 2011.

[4] K. D. Hansen, B. Langmead and R. A. Irizarry, “BSmooth: from whole genome bisulfite sequencing reads to differentially methylated regions.,” Genome Biol, 13.10:1, Oct 2012.

[5] D. Phan, N. Pradhan and M. Jankowiak, “Composable Effects for Flexible and Accelerated Probabilistic Programming in NumPyro.,” arXiv preprint 1912.11554, Dec 2019.