Flow and mass cytometry are important modern immunology tools for measuring expression levels of multiple proteins on single cells. The goal is to better understand the mechanisms of responses on a single cell basis by studying differential expression of proteins. Most current data analysis tools compare expressions across many computationally discovered cell types. Our goal is to focus on just one cell type. Differential analysis of marker expressions can be difficult due to marker correlations and inter-subject heterogeneity, particularly for studies of human immunology. We address these challenges with two multiple regression strategies: A bootstrapped generalized linear model (GLM) and a generalized linear mixed model (GLMM). Here, we illustrate the CytoGLMM
R package and workflow for simulated mass cytometry data.
We construct our simulated datasets by sampling from a Poisson GLM. We confirmed—with predictive posterior checks—that Poisson GLMs with mixed effects provide a good fit to mass cytometry data (Seiler et al. 2019). We consider one underlying data generating mechanisms described by a hierarchical model for the \(i\)th cell and \(j\)th donor:
\[ \begin{aligned} \boldsymbol{X}_{ij} & \sim \text{Poisson}(\boldsymbol{\lambda}_{ij}) \\ \log(\boldsymbol{\lambda}_{ij}) & = \boldsymbol{B}_{ij} + \boldsymbol{U}_j \\ \boldsymbol{B}_{ij} & \sim \begin{cases} \text{Normal}(\boldsymbol{\delta}^{(0)}, \boldsymbol{\Sigma}_B) & \text{if } Y_{ij} = 0, \text{ cell unstimulated} \\ \text{Normal}(\boldsymbol{\delta}^{(1)}, \boldsymbol{\Sigma}_B) & \text{if } Y_{ij} = 1, \text{ cell stimulated} \end{cases} \\ \boldsymbol{U}_j & \sim \text{Normal}(\boldsymbol{0}, \boldsymbol{\Sigma}_U). \end{aligned} \]
The following graphic shows a representation of the hierarchical model.
The stimulus activates proteins and induces a difference in marker expression. We define the effect size to be the difference between expected expression levels of stimulated versus unstimulated cells on the \(\log\)-scale. All markers that belong to the active set , have a non-zero effect size, whereas, all markers that are not, have a zero effect size:
\[ \begin{cases} \delta^{(1)}_p - \delta^{(0)}_p > 0 & \text{if protein } p \text{ is in activation set } p \in C \\ \delta^{(1)}_{p'} - \delta^{(0)}_{p'} = 0 & \text{if protein } p' \text{ is not in activation set } p' \notin C. \end{cases} \]
Both covariance matrices have an autoregressive structure,
\[ \begin{aligned} \Omega_{rs} & = \rho^{|r-s|} \\ \boldsymbol{\Sigma} & = \operatorname{diag}(\boldsymbol{\sigma}) \, \boldsymbol{\Omega} \, \operatorname{diag}(\boldsymbol{\sigma}), \end{aligned} \]
where \(\Omega_{rs}\) is the \(r\)th row and \(s\)th column of the correlation matrix \(\boldsymbol{\Omega}\). We regulate two separate correlation parameters: a cell-level \(\rho_B\) and a donor-level \(\rho_U\) coefficient. Non-zero \(\rho_B\) or \(\rho_U\) induce a correlation between condition and marker expression even for markers with a zero effect size.
library("CytoGLMM")
library("magrittr")
set.seed(23)
df = generate_data()
df[1:5,1:5]
## # A tibble: 5 × 5
## donor condition m01 m02 m03
## <int> <fct> <int> <int> <int>
## 1 1 treatment 2 127 116
## 2 1 treatment 0 96 54
## 3 1 treatment 1 14 52
## 4 1 treatment 6 20 34
## 5 1 treatment 18 30 15
We define the marker names that we will focus on in our analysis by extracting them from the simulated data frame.
protein_names = names(df)[3:12]
We recommend that marker expressions be corrected for batch effects (Nowicka et al. 2017; Chevrier et al. 2018; Schuyler et al. 2019; Van Gassen et al. 2020; Trussart et al. 2020) and transformed using variance stabilizing transformations to account for heteroskedasticity, for instance with an inverse hyperbolic sine transformation with the cofactor set to 150 for flow cytometry, and 5 for mass cytometry (Bendall et al. 2011). This transformation assumes a two-component model for the measurement error (Rocke and Lorenzato 1995; Huber et al. 2003) where small counts are less noisy than large counts. Intuitively, this corresponds to a noise model with additive and multiplicative noise depending on the magnitude of the marker expression; see (Holmes and Huber 2019) for details.
df %<>% dplyr::mutate_at(protein_names, function(x) asinh(x/5))
The goal of the CytoGLMM::cytoglm
function is to find protein expression patterns that are associated with the condition of interest, such as a response to a stimulus. We set up the GLM to predict the experimental condition (condition
) from protein marker expressions (protein_names
), thus our experimental conditions are response variables and marker expressions are explanatory variables.
glm_fit = CytoGLMM::cytoglm(df,
protein_names = protein_names,
condition = "condition",
group = "donor",
num_cores = 1,
num_boot = 1000)
glm_fit
##
## #######################
## ## paired analysis ####
## #######################
##
## number of bootstrap samples: 1000
##
## number of cells per group and condition:
## control treatment
## 1 1000 1000
## 2 1000 1000
## 3 1000 1000
## 4 1000 1000
## 5 1000 1000
## 6 1000 1000
## 7 1000 1000
## 8 1000 1000
##
## proteins included in the analysis:
## m01 m02 m03 m04 m05 m06 m07 m08 m09 m10
##
## condition compared: condition
## grouping variable: donor
We plot the maximum likelihood estimates with 95% confidence intervals for the fixed effects \(\boldsymbol{\beta}\). The estimates are on the \(\log\)-odds scale. We see that markers m1, m2, and m3 are strong predictors of the treatment. This means that one unit increase in the transformed marker expression makes it more likely to be a cell from the treatment group, while holding the other markers constant.
plot(glm_fit)
The summary
function returns a table about the model fit with unadjusted and Benjamini-Hochberg (BH) adjusted \(p\)-values.
summary(glm_fit)
## # A tibble: 10 × 3
## protein_name pvalues_unadj pvalues_adj
## <chr> <dbl> <dbl>
## 1 m03 0.004 0.04
## 2 m02 0.008 0.04
## 3 m01 0.022 0.0733
## 4 m06 0.358 0.877
## 5 m04 0.506 0.877
## 6 m08 0.526 0.877
## 7 m09 0.678 0.878
## 8 m05 0.702 0.878
## 9 m10 0.824 0.916
## 10 m07 0.916 0.916
We can extract the proteins below an False Discovery Rate (FDR) of 0.05 from the \(p\)-value table by filtering the table.
summary(glm_fit) %>% dplyr::filter(pvalues_adj < 0.05)
## # A tibble: 2 × 3
## protein_name pvalues_unadj pvalues_adj
## <chr> <dbl> <dbl>
## 1 m03 0.004 0.04
## 2 m02 0.008 0.04
In this simulated dataset, the markers m2 and m3 are below an FDR of 0.05.
In the CytoGLMM::cytoglmm
function, we make additional modeling assumptions by adding a random effect term in the standard logistic regression model to account for the subject effect (group
). In paired experimental design—when the same donor provides two samples, one for each condition—CytoGLMM::cytoglmm
is statistically more powerful.
glmm_fit = CytoGLMM::cytoglmm(df,
protein_names = protein_names,
condition = "condition",
group = "donor",
num_cores = 1)
glmm_fit
## number of cells per group and condition:
## control treatment
## 1 1000 1000
## 2 1000 1000
## 3 1000 1000
## 4 1000 1000
## 5 1000 1000
## 6 1000 1000
## 7 1000 1000
## 8 1000 1000
##
## proteins included in the analysis:
## m01 m02 m03 m04 m05 m06 m07 m08 m09 m10
##
## condition compared: condition
## grouping variable: donor
We plot the method of moments estimates with 95% confidence intervals for the fixed effects \(\boldsymbol{\beta}\).
plot(glmm_fit)
The summary
function returns a table about the model fit with unadjusted and BH adjusted \(p\)-values.
summary(glmm_fit)
## # A tibble: 10 × 3
## protein_name pvalues_unadj pvalues_adj
## <chr> <dbl> <dbl>
## 1 m03 0.0000682 0.000682
## 2 m02 0.000163 0.000813
## 3 m01 0.000681 0.00227
## 4 m06 0.155 0.388
## 5 m05 0.371 0.646
## 6 m08 0.388 0.646
## 7 m04 0.512 0.731
## 8 m09 0.859 0.954
## 9 m10 0.874 0.954
## 10 m07 0.954 0.954
We can extract the proteins below an FDR of 0.05 from the \(p\)-value table by filtering the table.
summary(glmm_fit) %>% dplyr::filter(pvalues_adj < 0.05)
## # A tibble: 3 × 3
## protein_name pvalues_unadj pvalues_adj
## <chr> <dbl> <dbl>
## 1 m03 0.0000682 0.000682
## 2 m02 0.000163 0.000813
## 3 m01 0.000681 0.00227
In this simulated dataset, the markers m1, m2 and m3 are below an FDR of 0.05. This illustrates the improved power for paired samples as CytoGLMM::cytoglmm
correctly detects all three differentially expressed proteins. We performed extensive power simulations and comparisons to other methods in Seiler et al. (2021).
sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_GB 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] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] magrittr_2.0.1 CytoGLMM_1.2.0 BiocStyle_2.22.0
##
## loaded via a namespace (and not attached):
## [1] nlme_3.1-153 lubridate_1.8.0 doParallel_1.0.16
## [4] RColorBrewer_1.1-2 tools_4.1.1 bslib_0.3.1
## [7] utf8_1.2.2 R6_2.5.1 rpart_4.1-15
## [10] DBI_1.1.1 colorspace_2.0-2 nnet_7.3-16
## [13] withr_2.4.2 tidyselect_1.1.1 compiler_4.1.1
## [16] cli_3.0.1 factoextra_1.0.7 logging_0.10-108
## [19] sandwich_3.0-1 labeling_0.4.2 bookdown_0.24
## [22] sass_0.4.0 scales_1.1.1 speedglm_0.3-3
## [25] stringr_1.4.0 digest_0.6.28 minqa_1.2.4
## [28] rmarkdown_2.11 pkgconfig_2.0.3 htmltools_0.5.2
## [31] parallelly_1.28.1 lme4_1.1-27.1 highr_0.9
## [34] fastmap_1.1.0 rlang_0.4.12 farver_2.1.0
## [37] jquerylib_0.1.4 generics_0.1.1 zoo_1.8-9
## [40] jsonlite_1.7.2 BiocParallel_1.28.0 dplyr_1.0.7
## [43] ModelMetrics_1.2.2.2 modeltools_0.2-23 mbest_0.6
## [46] Matrix_1.3-4 Rcpp_1.0.7 munsell_0.5.0
## [49] fansi_0.5.0 abind_1.4-5 lifecycle_1.0.1
## [52] stringi_1.7.5 pROC_1.18.0 yaml_2.2.1
## [55] MASS_7.3-54 flexmix_2.3-17 plyr_1.8.6
## [58] recipes_0.1.17 grid_4.1.1 strucchange_1.5-2
## [61] ggrepel_0.9.1 parallel_4.1.1 listenv_0.8.0
## [64] bigmemory.sri_0.1.3 crayon_1.4.1 lattice_0.20-45
## [67] cowplot_1.1.1 splines_4.1.1 magick_2.7.3
## [70] knitr_1.36 pillar_1.6.4 boot_1.3-28
## [73] future.apply_1.8.1 reshape2_1.4.4 codetools_0.2-18
## [76] stats4_4.1.1 glue_1.4.2 evaluate_0.14
## [79] data.table_1.14.2 BiocManager_1.30.16 vctrs_0.3.8
## [82] nloptr_1.2.2.2 foreach_1.5.1 tidyr_1.1.4
## [85] gtable_0.3.0 purrr_0.3.4 future_1.22.1
## [88] assertthat_0.2.1 ggplot2_3.3.5 xfun_0.27
## [91] gower_0.2.2 prodlim_2019.11.13 class_7.3-19
## [94] survival_3.2-13 timeDate_3043.102 pheatmap_1.0.12
## [97] tibble_3.1.5 iterators_1.0.13 lava_1.6.10
## [100] globals_0.14.0 bigmemory_4.5.36 ellipsis_0.3.2
## [103] caret_6.0-90 ipred_0.9-12
Bendall, Sean C, Erin F Simonds, Peng Qiu, D Amir El-ad, Peter O Krutzik, Rachel Finck, Robert V Bruggner, et al. 2011. “Single-Cell Mass Cytometry of Differential Immune and Drug Responses Across a Human Hematopoietic Continuum.” Science 332 (6030): 687–96.
Chevrier, Stéphane, Helena L Crowell, Vito RT Zanotelli, Stefanie Engler, Mark D Robinson, and Bernd Bodenmiller. 2018. “Compensation of Signal Spillover in Suspension and Imaging Mass Cytometry.” Cell Systems 6 (5): 612–20.
Holmes, Susan, and Wolfgang Huber. 2019. Modern Statistics for Modern Biology. Cambridge University Press.
Huber, Wolfgang, Anja von Heydebreck, Holger Sültmann, Annemarie Poustka, and Martin Vingron. 2003. “Parameter Estimation for the Calibration and Variance Stabilization of Microarray Data.” Statistical Applications in Genetics and Molecular Biology 2 (1).
Nowicka, M, C Krieg, LM Weber, FJ Hartmann, S Guglietta, B Becher, MP Levesque, and MD Robinson. 2017. “CyTOF Workflow: Differential Discovery in High-Throughput High-Dimensional Cytometry Datasets [Version 2; Referees: 2 Approved].” F1000Research 6 (748).
Rocke, David M, and Stefan Lorenzato. 1995. “A Two-Component Model for Measurement Error in Analytical Chemistry.” Technometrics 37 (2): 176–84.
Schuyler, Ronald P., Conner Jackson, Josselyn E. Garcia-Perez, Ryan M. Baxter, Sidney Ogolla, Rosemary Rochford, Debashis Ghosh, Pratyaydipta Rudra, and Elena W. Y. Hsieh. 2019. “Minimizing Batch Effects in Mass Cytometry Data.” Frontiers in Immunology 10: 2367.
Seiler, Christof, Anne-Maud Ferreira, Lisa M Kronstad, Laura J Simpson, Mathieu Le Gars, Elena Vendrame, Catherine A Blish, and Susan Holmes. 2021. “CytoGLMM: Conditional Differential Analysis for Flow and Mass Cytometry Experiments.” BMC Bioinformatics 22 (137): 1–14.
Seiler, Christof, Lisa M Kronstad, Laura J Simpson, Mathieu Le Gars, Elena Vendrame, Catherine A Blish, and Susan Holmes. 2019. “Uncertainty Quantification in Multivariate Mixed Models for Mass Cytometry Data.” arXiv:1903.07976.
Trussart, Marie, Charis E Teh, Tania Tan, Lawrence Leong, Daniel HD Gray, and Terence P Speed. 2020. “Removing Unwanted Variation with CytofRUV to Integrate Multiple CyTOF Datasets.” eLife 9 (September): e59630.
Van Gassen, Sofie, Brice Gaudilliere, Martin S Angst, Yvan Saeys, and Nima Aghaeepour. 2020. “CytoNorm: A Normalization Algorithm for Cytometry Data.” Cytometry Part A 97 (3): 268–78.