Cell-type Hierarchy Informs COVID-19 Immunology
Source:vignettes/covid_immunology.Rmd
covid_immunology.RmdIn December 2020, while COVID-19 was still raging across the globe, Su et al. ( 2020) published their pioneering study examining the immune and metabolic landscapes of mild to severe COVID patients.
See the DIVAS project for a more comprehensive introduction to their study design and a more in-depth analysis of their multiomic data. Here we just took the immune cell type composition information to illustrate how phylobar enables us to visualise immune cell type composition changes from milder to severer COVID-19.
library(ape)
library(dplyr)
library(phylobar)
library(readr)
library(tibble)
library(tidyr)
library(seriation)First load the cell and patient metadata.
all_data <- read_url_rds("https://zenodo.org/records/17477876/files/su-2020.rds?download=1")
cell_counts <- all_data$cell_counts
metadata <- all_data$metadataCalculate cell type compositions.
x <- cell_counts |>
dplyr::count(patient_id, majority_voting) |>
pivot_wider(
names_from = majority_voting,
values_from = n,
values_fill = 0
) |>
column_to_rownames("patient_id")
x <- x / rowSums(x)Based on biological knowledge, we manually define a phylo object for the hierarchy of immune cell types.
edges_text <- "source,target
Hematopoietic stem cell,Common myeloid progenitor
Hematopoietic stem cell,Common lymphoid progenitor
Common myeloid progenitor,Megakaryocyte
Megakaryocyte,Platelet
Common myeloid progenitor,RBC
Common myeloid progenitor,Myeloblast
Myeloblast,Monocyte
Monocyte,CD14 Monocyte
Monocyte,CD16 Monocyte
Myeloblast,SC & Eosinophil
Myeloblast,DC
Myeloblast,pDC
Common lymphoid progenitor,NK
Common lymphoid progenitor,Small lymphocyte
Small lymphocyte,T lymphocyte
T lymphocyte,CD4 T lymphocyte
T lymphocyte,CD8 T lymphocyte
CD4 T lymphocyte,CD4 T
CD4 T lymphocyte,CD4m T
CD4 T lymphocyte,CD4n T
CD8 T lymphocyte,CD8m T
CD8 T lymphocyte,CD8eff T
T lymphocyte,gd T
Small lymphocyte,B lymphocyte
B lymphocyte,B
B lymphocyte,IgA PB
B lymphocyte,IgG PB"
edge <- read_csv(edges_text)
tips <- setdiff(edge$target, edge$source)
# preparation for phylo construction
internal_nodes <- setdiff(unlist(edge), tips)
node_order <- c(tips, internal_nodes)
ix <- setNames(seq_along(node_order), node_order)
# create phylo
tree <- list(
edge = matrix(c(ix[edge$source], ix[edge$target]), ncol = 2),
Nnode = length(internal_nodes),
tip.label = node_order[seq_along(tips)],
node.label = node_order[seq(length(tips) + 1, length(ix))]
)
class(tree) <- "phylo"Let’s order patients by COVID severity (mild, moderate and severe). Then, within each severity group, use a hierarchical clustering leaf order to place samples with similar cell type compositions closer.
md <- metadata |>
distinct(clinical_id, severity) |>
mutate(severity = factor(
severity, levels = c("mild", "moderate", "severe")
)) |>
arrange(severity)
patient_order <- md %>%
split(.$severity) |>
lapply(\(df) {
ids <- df$clinical_id
m <- x[ids, , drop = FALSE]
ids[hclust(dist(m))$order]
}) |>
unlist(use.names = FALSE)Now we can make a phylobar visualization. We can see that T cells and monocytes made up the majority of cellular populations in patient samples. We can observe an overall increase of monocytes and decrease of NK and T cells, especially CD8 T cells, in moderate and severe COVID patients. These changes were found statistically significant in Su et al. (2020), and where highlighted in their Fig 1.
Another feature that was not characterised in Su et al. (2020) was the presence of gd (γδ, i.e. gamma delta) T cells in milder COVID patients exclusively. This echos some more recent findings suggesting that gd T cells may play an important role in the immune response to the pathogenic SARS-Cov-2 virus (Massow et al., 2021; Terzoli et al., 2024).
phylobar(x[patient_order, ], tree)
sessionInfo()
#> R version 4.5.1 (2025-06-13)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS Tahoe 26.3
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
#>
#> locale:
#> [1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8
#>
#> time zone: America/Chicago
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] seriation_1.5.8 tidyr_1.3.2 tibble_3.3.1 readr_2.1.6
#> [5] phylobar_0.99.0 dplyr_1.2.0 ape_5.8-1 BiocStyle_2.36.0
#>
#> loaded via a namespace (and not attached):
#> [1] sass_0.4.10 generics_0.1.4 lattice_0.22-9
#> [4] hms_1.1.4 digest_0.6.39 magrittr_2.0.4
#> [7] evaluate_1.0.5 grid_4.5.1 iterators_1.0.14
#> [10] bookdown_0.46 fastmap_1.2.0 foreach_1.5.2
#> [13] jsonlite_2.0.0 Matrix_1.7-4 BiocManager_1.30.27
#> [16] purrr_1.2.1 codetools_0.2-20 textshaping_1.0.4
#> [19] jquerylib_0.1.4 registry_0.5-1 cli_3.6.5
#> [22] crayon_1.5.3 rlang_1.1.7 bit64_4.6.0-1
#> [25] withr_3.0.2 cachem_1.1.0 yaml_2.3.12
#> [28] otel_0.2.0 tools_4.5.1 parallel_4.5.1
#> [31] tzdb_0.5.0 fastmatch_1.1-8 ca_0.71.1
#> [34] TSP_1.2.6 vctrs_0.7.1 R6_2.6.1
#> [37] lifecycle_1.0.5 bit_4.6.0 fs_1.6.6
#> [40] htmlwidgets_1.6.4 vroom_1.7.0 ragg_1.5.0
#> [43] cluster_2.1.8.2 pkgconfig_2.0.3 desc_1.4.3
#> [46] pkgdown_2.2.0 pillar_1.11.1 bslib_0.10.0
#> [49] glue_1.8.0 phangorn_2.12.1 Rcpp_1.1.1
#> [52] systemfonts_1.3.1 xfun_0.56 tidyselect_1.2.1
#> [55] knitr_1.51 htmltools_0.5.9 nlme_3.1-168
#> [58] igraph_2.2.1 rmarkdown_2.30 compiler_4.5.1
#> [61] quadprog_1.5-8