# EnMCB

## Introduction

This package is designed to help you to create the methylation correlated blocks using methylation profiles. A stacked ensemble of machine learning models, which combined the Cox regression, support vector regression and elastic-net regression model, can be constructed using this package1. You also can choose one of them to build DNA methylation signatures associated with disease progression.

Note: This package is still under developing. Some of the functions may change.

Followings are brief insturctions for using this package:

You can install and test our package by downloading source package.

## Installation

    #if(!requireNamespace("BiocManager", quietly = TRUE))
    #    install.packages("BiocManager")
    #BiocManager::install("EnMCB")

## Useage

First, you need a methylation data set, currently only most common platform ‘Illumina Infinium Human Methylation 450K’ is supported.

You can use your own datasets,or use our demo data.

You can automatically run following:

    suppressPackageStartupMessages(library(EnMCB))

    methylation_dataset<-create_demo()

    res<-IdentifyMCB(methylation_dataset)

IdentfyMCB() function will calculated Pearson correlation coefficients between the any two CpGs. A value of Pearson correlation coefficients which under the threshold was used to identify boundaries between any two adjacent markers indicating uncorrelated methylation. Markers not separated by a boundary were combined into the MCB. You can extract the MCB information with,

    MCB<-res$MCBinformation

and select some of MCBs for further modeling.

    MCB<-MCB[MCB[,"CpGs_num"]>=5,]

In order to get differentially methylated blocks, one may run following:

    #simulation for the group data
    groups = c(rep("control",200),rep("dis",255))

    DiffMCB_resutls<-DiffMCB(methylation_dataset,
                             groups,
                             MCB)$tab

In order to build survival models, one may run following:

    # sample the dataset into training set and testing set
    trainingset<-colnames(methylation_dataset) %in% sample(colnames(methylation_dataset),0.6*length(colnames(methylation_dataset)))

    testingset<-!trainingset

    #build the models
    library(survival)
    data(demo_survival_data)

    models<-metricMCB(MCB,
                        training_set = methylation_dataset[,trainingset],
                        Surv = demo_survival_data[trainingset],
                        Method = "cox",ci = TRUE)

    #select the best
    onemodel<-models$best_cox_model$cox_model

Then, you can predict the risk by the model you build:

    newcgdata<-data.frame(t(methylation_dataset[,testingset]))

    prediction_results<-predict(onemodel, newcgdata)

In order to build ensemble model, one may run following:

    # You can choose one of MCBs:
    select_single_one=1

    em<-ensemble_model(t(MCB[select_single_one,]),
                        training_set=methylation_dataset[,trainingset],
                        Surv_training=demo_survival_data[trainingset])

Note that this function only can be used for single MCB only, otherwise the precessing time could be very long.

Then, you can predict the risk by the model you build:

    em_prediction_results<-ensemble_prediction(ensemble_model = em,
                        prediction_data = methylation_dataset[,testingset])

This function will return the single vector with risk scores predicted by ensemble model.

For detailed information, you can find at our references.

## Session Info

    sessionInfo()

    ## R version 4.5.2 (2025-10-31)
    ## Platform: x86_64-pc-linux-gnu
    ## Running under: Ubuntu 24.04.4 LTS
    ##
    ## 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.26.so;  LAPACK version 3.12.0
    ##
    ## 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
    ##
    ## time zone: Etc/UTC
    ## tzcode source: system (glibc)
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] survival_3.8-6 EnMCB_1.23.0   rmarkdown_2.30
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] tidyselect_1.2.1    libcoin_1.0-10      dplyr_1.2.0
    ##   [4] farver_2.1.2        blob_1.3.0          filelock_1.0.3
    ##   [7] S7_0.2.1            fastmap_1.2.0       TH.data_1.1-5
    ##  [10] BiocFileCache_3.1.0 pracma_2.4.6        digest_0.6.39
    ##  [13] rpart_4.1.24        lifecycle_1.0.5     cluster_2.1.8.2
    ##  [16] RSQLite_2.4.6       magrittr_2.0.4      kernlab_0.9-33
    ##  [19] compiler_4.5.2      rlang_1.1.7         Hmisc_5.2-5
    ##  [22] sass_0.4.10         tools_4.5.2         partykit_1.2-25
    ##  [25] yaml_2.3.12         data.table_1.18.2.1 knitr_1.51
    ##  [28] htmlwidgets_1.6.4   bit_4.6.0           curl_7.0.0
    ##  [31] RColorBrewer_1.1-3  multcomp_1.4-29     polspline_1.1.25
    ##  [34] foreign_0.8-91      sys_3.4.3           nnet_7.3-20
    ##  [37] grid_4.5.2          colorspace_2.1-2    ggplot2_4.0.2
    ##  [40] MASS_7.3-65         scales_1.4.0        iterators_1.0.14
    ##  [43] dichromat_2.0-0.1   cli_3.6.5           mvtnorm_1.3-3
    ##  [46] inum_1.0-5          rms_8.1-1           generics_0.1.4
    ##  [49] otel_0.2.0          rstudioapi_0.18.0   DBI_1.2.3
    ##  [52] cachem_1.1.0        stringr_1.6.0       splines_4.5.2
    ##  [55] nnls_1.6            parallel_4.5.2      base64enc_0.1-6
    ##  [58] vctrs_0.7.1         sandwich_3.1-1      boot_1.3-32
    ##  [61] glmnet_4.1-10       Matrix_1.7-4        SparseM_1.84-2
    ##  [64] jsonlite_2.0.0      survivalsvm_0.0.6   bit64_4.6.0-1
    ##  [67] Formula_1.2-5       htmlTable_2.4.3     maketools_1.3.2
    ##  [70] foreach_1.5.2       jquerylib_0.1.4     glue_1.8.0
    ##  [73] stabs_0.7-1         codetools_0.2-20    mboost_2.9-11
    ##  [76] stringi_1.8.7       shape_1.4.6.1       gtable_0.3.6
    ##  [79] quadprog_1.5-8      tibble_3.3.1        pillar_1.11.1
    ##  [82] quantreg_6.1        rappdirs_0.3.4      htmltools_0.5.9
    ##  [85] R6_2.6.1            dbplyr_2.5.2        httr2_1.2.2
    ##  [88] survivalROC_1.0.3.1 evaluate_1.0.5      lattice_0.22-9
    ##  [91] backports_1.5.0     memoise_2.0.1       bslib_0.10.0
    ##  [94] MatrixModels_0.5-4  Rcpp_1.1.1          nlme_3.1-168
    ##  [97] gridExtra_2.3       checkmate_2.3.4     xfun_0.56
    ## [100] zoo_1.8-15          buildtools_1.0.0    pkgconfig_2.0.3

## References

1. Xin Yu et al. 2019 Predicting disease progression in lung adenocarcinoma patients based on methylation correlated blocks using ensemble machine learning classifiers (under review)↩︎