# A Vignette for DeMixT

#### Zeya Wang and Fan Gao

#### 2019-08-16

# 1. Introduction

Transcriptomic deconvolution in cancer and other heterogeneous tissues remains challenging. Available methods lack the ability to estimate both component-specific proportions and expression profiles for individual samples. We develop a three-component deconvolution model, DeMixT, for expression data from a mixture of cancerous tissues, infiltrating immune cells and tumor microenvironment. DeMixT is a software package that performs deconvolution on transcriptome data from a mixture of two or three components.

DeMixT is a frequentist-based method and fast in yielding accurate estimates of cell proportions and compart-ment-specific expression profiles for two-component three-component deconvolution problem. Our method promises to provide deeper insight into cancer biomarkers and assist in the development of novel prognostic markers and therapeutic strategies.

The function DeMixT is designed to finish the whole pipeline of deconvolution for two or three components. DeMixT.S1 function is designed to estimate the proportions of all mixed samples for each mixing component. DeMixT.S2 function is designed to estimate the component-specific deconvolved expressions of individual mixed samples for a given set of genes.

# 2 Feature Description

The DeMixT R-package builds the transcriptomic deconvolution with a couple of novel features into R-based standard analysis pipeline through Bioconductor. DeMixT showed high accuracy and efficiency from our designed experiment. Hence, DeMixT can be considered as an important step towards linking tumor transcriptomic data with clinical outcomes.

Different from most previous computational deconvolution methods, DeMixT has integrated new features for the deconvolution with more than 2 components.

Joint estimation: jointly estimate component proportions and expression profiles for individual samples by requiring reference samples instead of reference genes; For the three-component deconvolution considering immune infiltration, it provides a comprehensive view of tumor-stroma-immune transcriptional dynamics, as compared to methods that address only immune subtypes within the immune component, in each tumor sample.

Efficient estimation: DeMixT adopts an approach of iterated conditional modes (ICM) to guarantee a rapid convergence to a local maximum. We also design a novel gene-set-based component merging approach to reduce the bias of proportion estimation for three-component deconvolutionthe.

parallel computing: OpenMP enables parallel computing on single computer by taking advantage of the multiple cores shipped on modern CPUs. The ICM framework further enables parallel computing, which helps compensate for the expensive computing time used in the repeated numerical double integrations.

# 3. Installation

## 3.1 Source file

DeMixT source files are compatible with Windows, Linux and macOS.

DeMixT_0.99.0 is the latest version, which is for a computer that has OpenMP. To install DeMixT_0.99.0, start R and enter:

    # devtools::install_github("wwylab/DeMixT")

For more information, please visit: http://bioinformatics.mdanderson.org/main/DeMixT

## 3.2 Functions

The following table shows the functions included in DeMixT.

Table Header | Second Header
--- | ---
DeMixT | Deconvolution of tumor samples with two or three components
DeMixT_S1 | Estimates the proportions of mixed samples for each mixing component
DeMixT_S2 | Deconvolves expressions of each sample for unknown component
Optimum_KernelC | Call the C function used for parameter estimation in DeMixT

# 4. Methods

## 4.1 Model

Let \(Y_{ig}\) be the observed expression levels of the raw measured data from clinically derived malignant tumor samples for gene \(g, g = 1, \cdots, G\) and sample \(i, i = 1, \cdots, S\). \(G\) denotes the total number of probes/genes and \(S\) denotes the number of samples. The observed expression levels for solid tumors can be modeled as a linear combination of raw expression levels from three components: \[ {Y_{ig}} = \pi _{1,i}N_{1,ig} + \pi _{2,i}N_{2,ig} + (1 - \pi_{1,i} - \pi _{2,i}){T_{ig}} \label{eq:1} \]

Here \(N_{1,ig}\), \(N_{2,ig}\) and \({T_{ig}}\) are the unobserved raw expression levels from each of the three components. We call the two components for which we require reference samples the \(N_1\)-component and the \(N_2\)-component. We call the unknown component the T-component. We let \(\pi_{1,i}\) denote the proportion of the \(N_1\)-component, \(\pi_{2,i}\) denote the proportion of the \(N_2\)-component, and \(1 - \pi_{1,i}-\pi_{2,i}\) denote the proportion of the T-component. We assume that the mixing proportions of one specific sample remain the same across all genes.

Our model allows for one component to be unknown, and therefore does not require reference profiles from all components. A set of samples for \(N_{1,ig}\) and \(N_{2,ig}\), respectively, needs to be provided as input data. This three-component deconvolution model is applicable to the linear combination of any three components in any type of material. It can also be simplified to a two-component model, assuming there is just one \(N\)-component. For application in this paper, we consider tumor (\(T\)), stromal (\(N_1\)) and immune components (\(N_2\)) in an admixed sample (\(Y\)).

Following the convention that \(\log_2\)-transformed microarray gene expression data follow a normal distribution, we assume that the raw measures \(N_{1,ig} \sim LN({\mu _{{N_1}g}},\sigma _{{N_1}g}^2)\), \(N_{2,ig} \sim LN({\mu _{{N_2}g}},\sigma _{{N_2}g}^2)\) and \({T_{ig}} \sim LN({\mu _{Tg}}, \sigma _{Tg}^2)\), where LN denotes a \(\log_2\)-normal distribution and \(\sigma _{{N_1}g}^2\),\(\sigma _{{N_2}g}^2\), \(\sigma _{Tg}^2\) reflect the variations under \(\log_2\)-transformed data. Consequently, our model can be expressed as the convolution of the density function for three \(\log_2\)-normal distributions. Because there is no closed form of this convolution, we use numerical integration to evaluate the complete likelihood function (see the full likelihood in the Supplementary Materials).

## 4.2 The DeMixT algorithm for deconvolution

DeMixT estimates all distribution parameters and cellular proportions and reconstitutes the expression profiles for all three components for each gene and each sample. The estimation procedure (summarized in Figure 1b) has two main steps as follows.

1. Obtain a set of parameters \(\{\pi_{1,i}, \pi_{2,i}\}_{i=1}^S\), \(\{\mu_T, \sigma_T\}_{g=1}^G\) to maximize the complete likelihood function, for which \(\{\mu_{N_{1,g}}, \sigma_{N_{1,g}}, \mu_{N_{2,g}}, \sigma_{N_{2,g}}\}_{g=1}^G\) were already estimated from the available unmatched samples of the \(N_1\) and \(N_2\) component tissues. (See further details in our paper.)

2. Reconstitute the expression profiles by searching each set of \(\{n_{1,ig}, n_{2,ig}\}\) that maximizes the joint density of \(N_{1,ig}\), \(N_{2,ig}\) and \(T_{ig}\). The value of \(t_{ig}\) is solved as \({y_{ig}} - {{\hat \pi }_{1,i}}{n_{1,ig}} - {{\hat \pi }_{2,i}}{n_{2,ig}}\).

These two steps can be separately implemented using the function DeMixT.S1 and DeMixT.S2, which are combined in the function DeMixT.

# 5. Examples

## 5.1 Simulated two-component data

    library(DeMixT)
    data(test.data1.y)
    data(test.data1.comp1)
    res <- DeMixT(data.Y = test.data1.y,
        data.comp1 = test.data1.comp1,
        if.filter = FALSE,
        output.more.info = TRUE)

    res$pi

    ##             1        2         3         4         5         6         7
    ## pi1 0.1070472 0.220727 0.2929528 0.3372991 0.4262478 0.5034399 0.6210297
    ##             8         9        10
    ## pi1 0.6618772 0.7457117 0.7707665

    head(res$ExprT, 3)

    ##          1         2         3        4        5        6        7
    ## 1 96.79601  83.41787  80.77196 80.60387 84.20051 83.03599 87.01642
    ## 2 77.09336 112.40688 136.32352 85.98076 81.23193 68.42828 87.29952
    ## 3 38.68590  35.17979  38.51000 37.91703 32.56498 74.14902 84.34139
    ##          8        9       10
    ## 1 86.21981 84.86446 85.45986
    ## 2 96.39947 92.02540 72.51449
    ## 3 46.25357 44.50515 56.71163

    head(res$ExprN1, 3)

    ##           1         2         3         4         5         6         7
    ## 1 129.54459 116.08959 107.12369 104.37677 116.49387 107.61863 172.50756
    ## 2  90.46188  96.29144 102.25963  92.28142  89.61648  76.85369  96.72322
    ## 3  53.12756  52.61833  52.91754  52.74163  50.77737  58.10972  62.69014
    ##           8         9        10
    ## 1 156.53101 126.00432 152.83344
    ## 2 117.71236 120.03568  65.79434
    ## 3  56.37108  56.72732  68.31616

    head(res$Mu, 3)

    ##       MuN1      MuT
    ## 1 6.940477 6.414442
    ## 2 6.582707 6.480815
    ## 3 5.767947 5.528960

    head(res$Sigma, 3)

    ##     SigmaN1    SigmaT
    ## 1 0.2675802 0.1329882
    ## 2 0.3201497 0.3694942
    ## 3 0.2231435 0.5203588

    res$pi.iter

    ## , , 1
    ##
    ##             [,1]      [,2]      [,3]      [,4]      [,5]      [,6]
    ##  [1,] 0.09043013 0.2139893 0.2937994 0.3356124 0.4489045 0.5187335
    ##  [2,] 0.09198396 0.2256721 0.3003950 0.3433463 0.4443040 0.5215801
    ##  [3,] 0.09218503 0.2259228 0.3000308 0.3437085 0.4438475 0.5214382
    ##  [4,] 0.10617874 0.2253017 0.3015517 0.3608654 0.4454549 0.5067351
    ##  [5,] 0.10977391 0.2275798 0.3089511 0.3611076 0.4456571 0.5040914
    ##  [6,] 0.11123294 0.2425127 0.3081758 0.3581118 0.4228654 0.5039276
    ##  [7,] 0.11158127 0.2421069 0.3059258 0.3530130 0.4238177 0.4875526
    ##  [8,] 0.11060261 0.2217009 0.3054204 0.3515637 0.4250676 0.4873618
    ##  [9,] 0.10694140 0.2195359 0.3066283 0.3536044 0.4290799 0.4865563
    ## [10,] 0.10670146 0.2225911 0.2923176 0.3508836 0.4274665 0.4871608
    ##            [,7]      [,8]      [,9]     [,10]
    ##  [1,] 0.6544423 0.7281499 0.8230019 0.8744931
    ##  [2,] 0.6532641 0.7273786 0.8232727 0.8754047
    ##  [3,] 0.6528566 0.7269844 0.8231059 0.8336147
    ##  [4,] 0.6526141 0.7277978 0.7440668 0.8335681
    ##  [5,] 0.5813990 0.6121463 0.7436625 0.7410676
    ##  [6,] 0.5811888 0.6119863 0.7448688 0.7415543
    ##  [7,] 0.5806086 0.6121581 0.7455201 0.7418580
    ##  [8,] 0.5808192 0.6130383 0.7457062 0.7715683
    ##  [9,] 0.5962885 0.6134058 0.7461216 0.7943108
    ## [10,] 0.6197479 0.6905266 0.7460174 0.7512265

    res$gene.name

    ##   [1] "1"   "2"   "3"   "4"   "5"   "6"   "7"   "8"   "9"   "10"  "11"
    ##  [12] "12"  "13"  "14"  "15"  "16"  "17"  "18"  "19"  "20"  "21"  "22"
    ##  [23] "23"  "24"  "25"  "26"  "27"  "28"  "29"  "30"  "31"  "32"  "33"
    ##  [34] "34"  "35"  "36"  "37"  "38"  "39"  "40"  "41"  "42"  "43"  "44"
    ##  [45] "45"  "46"  "47"  "48"  "49"  "50"  "51"  "52"  "53"  "54"  "55"
    ##  [56] "56"  "57"  "58"  "59"  "60"  "61"  "62"  "63"  "64"  "65"  "66"
    ##  [67] "67"  "68"  "69"  "70"  "71"  "72"  "73"  "74"  "75"  "76"  "77"
    ##  [78] "78"  "79"  "80"  "81"  "82"  "83"  "84"  "85"  "86"  "87"  "88"
    ##  [89] "89"  "90"  "91"  "92"  "93"  "94"  "95"  "96"  "97"  "98"  "99"
    ## [100] "100" "101" "102" "103" "104" "105" "106" "107" "108" "109" "110"
    ## [111] "111" "112" "113" "114" "115" "116" "117" "118" "119" "120"

## 5.2 Simulated three-component data

    # data(test.data2.y)
    # data(test.data2.comp1)
    # data(test.data2.comp2)
    # res <- DeMixT(data.Y = test.data2.y,
    #     data.comp1 = test.data2.comp1,
    #     data.comp2 = test.data2.comp2,
    #     if.filter = FALSE)

## 5.3 Laser-capture microdissection prostate cancer FFPE microarray dataset

This dataset was generated at the Dana Farber Cancer Institute (GSE97284). Radical prostatectomy specimens were annotated in detail by pathologists, and regions of interest were identified that corresponded to benign epithelium, prostatic intraepithelial neoplasia (abnormal tissue that is possibly precancerous), and tumor, each with its surrounding stroma. FFPE samples are known to generate overall lower quality expression data than those from fresh frozen samples. We observed a small proportion of probesets that presented large differences in mean expression levels between the dissected tissues: tumor (\(T\)) and stroma (\(N\)) in this dataset. Only 53 probesets presented a mean difference \((| \bar{T} - \bar{N} |) >1\), as compared to 10,397 probesets in GSE19830. We therefore chose the top 80 genes with the largest mean differences and ran DeMixT under two settings: tumor unknown and stroma unknown. DeMixT is able to obtain concordant estimates of the tumor proportions when the proportion of the stromal component was unknown and when the proportion of tumor tissue was unknown and also tended to provide accurate component-specific mean expression levels.

    library(DeMixT)
    data <- as.matrix(read.table("input.lcm.txt", header = FALSE))
    normal <- data[, 1:25]
    adm <- data[, 26:48]
    tumor <- data[, 49:73]

    nrows <- nrow(adm); ncols <- ncol(adm)
    lcm.data.adm <- matrix(2^adm, nrows)
    lcm.data.adm <- SummarizedExperiment(assays=list(counts=lcm.data.adm))

    nrows <- nrow(tumor); ncols <- ncol(tumor)
    lcm.data.tumor <- matrix(2^tumor, nrows)
    lcm.data.tumor <- SummarizedExperiment(assays=list(counts=lcm.data.tumor))

    nrows <- nrow(normal); ncols <- ncol(normal)
    lcm.data.normal <- matrix(2^normal, nrows)
    lcm.data.normal <- SummarizedExperiment(assays=list(counts=lcm.data.normal))

    testr.TA <- DeMixT(data.Y = lcm.data.adm, data.comp1 = lcm.data.tumor,
        niter = 20, nbin = 60, if.filter = FALSE, tol = 10^-6)
    testr.SA <- DeMixT(data.Y = lcm.data.adm, data.comp1 = lcm.data.normal,
        niter = 20, nbin = 60, if.filter = FALSE, tol = 10^-6)

    # plot A
    dt_purT <- 1- as.numeric(testr.SA$pi)
    dt_purS <- 1- as.numeric(testr.TA$pi)
    plot(1 - dt_purS, dt_purT,
        col = "blue", pch = 1, xlim = c(0, 1), ylim = c(0, 1),
        xlab = expression(1 - hat(pi)[S]), ylab = expression(hat(pi)[T]))
    abline(0, 1, col = "red", lwd = 2)

    # Plot - Mean expressions for Tumor
    OB_St <- log2(read.table("lcm_normal.txt", header = FALSE))
    OB_Tu <- log2(read.table("lcm_tumor.txt", header = FALSE))
    DT_Tu_mu <- as.numeric(testr.SA$Mu[, 1])
    DT_St_mu <- as.numeric(testr.TA$Mu[, 1])
    DT_Tu_sg <- as.numeric(testr.SA$Sigma[, 1])
    DT_St_sg <- as.numeric(testr.TA$Sigma[, 1])
    OB_St_m <- apply(OB_St, 1, mean)
    OB_Tu_m <- apply(OB_Tu, 1, mean)

    # filter out genes with large estimated standard deviations
    condSt <- (DT_St_sg < 0.99)
    condTu <- (DT_Tu_sg < 0.99)
    DT_Tu_m <- as.numeric(apply(log2(testr.SA$ExprT), 1, mean))
    DT_St_m <- as.numeric(apply(log2(testr.TA$ExprT), 1, mean))
    OB_St_m <- OB_St_m[condSt]
    OB_Tu_m <- OB_Tu_m[condTu]
    DT_St_m <- DT_St_m[condSt]
    DT_Tu_m <- DT_Tu_m[condTu]

    # Plot - Mean expressions for Tumor
    smoothScatter((DT_Tu_m + OB_Tu_m) / 2, DT_Tu_m - OB_Tu_m,
        ylab = "Estimate - Truth", xlab = "(Estimate + Truth)/2",
        xlim = c(2,16), ylim = c(-1.2,1.2),
        main = "Mean expressions for Tumor",
        pch = 1, nrpoints = 0, col = 'yellow',
        colramp=colorRampPalette(c("white","yellow",
        "yellow1","orange","orange1")))

    ## Warning in DT_Tu_m - OB_Tu_m: longer object length is not a multiple of
    ## shorter object length

    ## Warning in DT_Tu_m + OB_Tu_m: longer object length is not a multiple of
    ## shorter object length

    tmp01 <- lowess((DT_Tu_m - OB_Tu_m) ~ ((DT_Tu_m + OB_Tu_m) / 2))

    ## Warning in DT_Tu_m - OB_Tu_m: longer object length is not a multiple of
    ## shorter object length

    ## Warning in DT_Tu_m - OB_Tu_m: longer object length is not a multiple of
    ## shorter object length

    lines(tmp01$x, tmp01$y, col="blue", lwd = 5)
    abline(h = 0, col = 'red', lty = 2)

    # Plot - Mean expressions for Stroma
    smoothScatter((DT_St_m + OB_St_m) / 2, DT_St_m - OB_St_m,
        ylab = "Estimate - Truth", xlab = "(Estimate + Truth)/2",
        xlim = c(2,16), ylim = c(-1.2,1.2),
        main = "Mean expressions for Stroma", pch = 1, nrpoints = 0,
        col = 'yellow',
        colramp=colorRampPalette(c("white","yellow",
        "yellow1","orange","orange1")))

    tmp01 <- lowess((DT_St_m - OB_St_m) ~ ((DT_St_m + OB_St_m) / 2))
    lines(tmp01$x, tmp01$y, col="blue", lwd = 5)
    abline(h = 0, col = 'red', lty = 2)

# 6. Session Info

    sessionInfo(package = "DeMixT")

    ## R version 3.6.1 (2019-07-05)
    ## Platform: x86_64-w64-mingw32/x64 (64-bit)
    ## Running under: Windows Server 2012 R2 x64 (build 9600)
    ##
    ## Matrix products: default
    ##
    ## locale:
    ## [1] LC_COLLATE=C
    ## [2] LC_CTYPE=English_United States.1252
    ## [3] LC_MONETARY=English_United States.1252
    ## [4] LC_NUMERIC=C
    ## [5] LC_TIME=English_United States.1252
    ##
    ## attached base packages:
    ## character(0)
    ##
    ## other attached packages:
    ## [1] DeMixT_1.0.4
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] Rcpp_1.0.2                  knitr_1.24
    ##  [3] XVector_0.24.0              magrittr_1.5
    ##  [5] GenomicRanges_1.36.0        BiocGenerics_0.30.0
    ##  [7] zlibbioc_1.30.0             IRanges_2.18.1
    ##  [9] grDevices_3.6.1             BiocParallel_1.18.1
    ## [11] lattice_0.20-38             stringr_1.4.0
    ## [13] GenomeInfoDb_1.20.0         tools_3.6.1
    ## [15] utils_3.6.1                 SummarizedExperiment_1.14.1
    ## [17] grid_3.6.1                  parallel_3.6.1
    ## [19] Biobase_2.44.0              xfun_0.8
    ## [21] KernSmooth_2.23-15          htmltools_0.3.6
    ## [23] stats_3.6.1                 datasets_3.6.1
    ## [25] matrixStats_0.54.0          yaml_2.2.0
    ## [27] digest_0.6.20               base_3.6.1
    ## [29] Matrix_1.2-17               GenomeInfoDbData_1.2.1
    ## [31] graphics_3.6.1              S4Vectors_0.22.0
    ## [33] bitops_1.0-6                RCurl_1.95-4.12
    ## [35] evaluate_0.14               rmarkdown_1.14
    ## [37] DelayedArray_0.10.0         stringi_1.4.3
    ## [39] compiler_3.6.1              methods_3.6.1
    ## [41] stats4_3.6.1