Introduction to the TBSignatureProfiler

Tuberculosis (TB) is the leading cause of infectious disease mortality worldwide, causing on average nearly 1.4 million deaths per year. A consistent issue faced in controlling TB outbreak is difficulty in diagnosing individuals with particular types of TB infections for which bacteria tests (e.g., via GeneXpert, sputum) prove inaccurate. As an alternative mechanism of diagnosis for these infections, researchers have discovered and published multiple gene expression signatures as blood-based disease biomarkers. In this context, gene signatures are defined as a combined group of genes with a uniquely characteristic pattern of gene expression that occurs as a result of a medical condition. To date, more than 75 signatures have been published by researchers, though most have relatively low cross-condition validation (e.g., testing TB in samples from diverse geographic and comorbidity backgrounds). Furthermore, these signatures have never been formally collected and made available as a single unified resource.

We aim to provide the scientific community with a resource to access these aggregated signatures and to create an efficient means for their visual and quantitative comparison via open source software. This necessitated the development of the TBSignatureProfiler, a novel R package which delivers a computational profiling platform for researchers to characterize the diagnostic ability of existing signatures in multiple comorbidity settings. This software allows for signature strength estimation via several enrichment methods and subsequent visualization of single- and multi-pathway results. Its signature evaluation functionalities include signature profiling, AUC bootstrapping, and leave-one-out cross-validation (LOOCV) of logistic regression to approximate TB samples’ status. Its plotting functionalities include sample-signature score heatmaps, bootstrap AUC and LOOCV boxplots, and tables for presenting results.

More recently, the TBSignatureProfiler has undertaken a new role in analyzing signatures across multiple chronic airway diseases, the most recent being COVID-19 (see the COVIDsignatures object). As we grow and expand the TBSignatureProfiler, we hope to add signatures from multiple diseases to improve the package's utility in the area of gene signature comparison.

Installation

In order to install the TBSignatureProfiler from Bioconductor, run the following code:

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

Compatibility with SummarizedExperiment objects

While the TBSignatureProfiler often allows for the form of a data.frame or matrix as input data, the most ideal form of input for this package is that of the SummarizedExperiment object. This is an amazing data structure that is being developed by the Bioconductor team as part of the r Biocpkg("SummarizedExperiment") package. It is able to store data matrices along with annotation information, metadata, and reduced dimensionality data (PCA, t-SNE, etc.). To learn more about proper usage and context of the SummarizedExperiment object, you may want to take a look at the package vignette. A basic understanding of the assay and colData properties of a SummarizedExperiment will be useful for the purposes of this vignette.

To install the SummarizedExperiment package, run the following code:

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

A Tutorial for the TBSignatureProfiler

Load packages

suppressPackageStartupMessages({
  library(SummarizedExperiment)
  library(TBSignatureProfiler)
})

Run Shiny App

This command is to start the TBSignatureProfiler shiny app. The Shiny app implements several functions described in this vignette.

```{R Run_shiny_app, eval = FALSE} TBSPapp()

The basic functions of the shiny app are also included in the command line version of the TBSignatureProfiler, which is the focus of the remainder of this vignette.


## Load dataset from a SummarizedExperiment object
In this tutorial, we will work with HIV and Tuberculosis (TB) gene expression data in a `SummarizedExperiment` format. This dataset is included in the TBSignatureProfiler package and can be loaded into the global environment with `data("TB_hiv")`. The 31 samples in the dataset are marked as either having both TB and HIV infection, or HIV infection only.

We begin by examining the dataset, which contains a matrix of counts information (an "assay" in SummarizedExperiment terms) and another matrix of meta data information on our samples (the "colData"). We will also generate a few additional assays; these are the log(counts), the counts per million (CPM) reads mapped, and the log(CPM) assays. 

```r
## HIV/TB gene expression data, included in the package
hivtb_data <- TB_hiv

### Note that we have 25,369 genes, 33 samples, and 1 assay of counts
dim(hivtb_data)

# We start with only one assay
assays(hivtb_data)

We now make a log counts, CPM and log CPM assay.

## Make a log counts, CPM and log CPM assay
hivtb_data <- mkAssay(hivtb_data, log = TRUE, counts_to_CPM = TRUE)

### Check to see that we now have 4 assays
assays(hivtb_data)

Profile the data {.tabset}

The TBSignatureProfiler enables comparison of multiple Tuberculosis gene signatures. The package currently contains information on 79 signatures for comparison. The default signature list object for most functions here is TBsignatures, although a list with publication-given signature names is also available in the TBcommon object. Data frames of annotation information for these signatures, including information on associated disease and tissue type, can be accessed as sigAnnotData and common_sigAnnotData respectively.

With the runTBSigProfiler function, we are able to score these signatures with a selection of algorithms, including gene set variation analysis (GSVA) (Hänzelmann et al, 2013), single-sample GSEA (ssGSEA) (Barbie et al, 2009), and the ASSIGN pathway profiling toolkit (Shen et al, 2015). For a complete list of included scoring methods, run ?runTBsigProfiler in the terminal.

Here, we evaluate all signatures included in the package with ssGSEA. Paraphrasing from the ssGSEA documentation, for each pairing of one of the 31 samples and its gene set, ssGSEA calculates a separate enrichment score independent of the phenotypic labeling (in this case, whether a sample has HIV/TB, or HIV only). The single sample's gene expression profile is then transformed to a gene set enrichment profile. A score from the set profile represents the activity level of the biological process in which the gene set's members are coordinately up- or down-regulated.

## List all signatures in the profiler
data("TBsignatures")
names(TBsignatures)

## We can use all of these signatures for further analysis
siglist_hivtb <- names(TBsignatures)
## Run the TBSignatureProfiler to score the signatures in the data
out <- capture.output(ssgsea_result <- runTBsigProfiler(input = hivtb_data,
                                                 useAssay = "log_counts_cpm",
                                                 signatures = TBsignatures,
                                                 algorithm = "ssGSEA",
                                                 combineSigAndAlgorithm = TRUE,
                                                 parallel.sz = 1))

## Remove any signatures that were not scored
TBsignatures <- subset(TBsignatures, !(names(TBsignatures) %in% c("Chendi_HIV_2")))

When a SummarizedExperiment is the format of the input data for runTBsigprofiler, the returned object is also of the SummarizedExperiment. The scores will be returned as a part of the colData.

Below, we subset the data to compare the enrichment scores for the Anderson_42, Anderson_OD_51, and Zak_RISK_16 signatures.

Signature Scores

## New colData entries from the Profiler
sigs <- c("Anderson_42", "Anderson_OD_51", "Zak_RISK_16")
ssgsea_print_results <- as.data.frame(colData(ssgsea_result))[, c("Disease", sigs)]
ssgsea_print_results[, 2:4] <- round(ssgsea_print_results[, 2:4], 4)

DT::datatable(ssgsea_print_results)

Visualization with TBSignatureProfiler Plots{.tabset}

Heatmap with all Signatures

Commonly, enrichment scores are compared across signatures by means of a heatmap combined with clustering methods to group samples and/or scores. The signatureHeatmap function uses the information from the score data to visualize changes in gene expression across samples and signatures (or genes, if only one signature is selected).

Here, the columns of the heatmap represent samples, and rows represent signatures. Rows are split according to annotation data with associated signature disease type. As we move across the columns, we see different patterns of gene expression as indicated by the varying color and intensity of individual rectangles. In the top bar, the solid red represents a sample is HIV infected only, and solid blue indicates that the sample is both HIV and TB infected. In the gradient area of the heatmap, the scaled scores are associated with either up-regulated or down-regulated genes.

# Colors for gradient
colors <- RColorBrewer::brewer.pal(6, "Spectral")
col.me <- circlize::colorRamp2(seq(from = -2, to = 2,
                                   length.out = 6), colors)

signatureHeatmap(ssgsea_result, name = "Heatmap of Signatures,
                 ssGSEA Algorithm",
                 signatureColNames = names(TBsignatures),
                 annotationColNames = "Disease",
                 scale = TRUE,
                 showColumnNames = TRUE,
                 choose_color = col.me)

Boxplots of Scores, All Signatures

Another method of visualization for scores is that of boxplots. When multiple signatures in the input data are to be compared, the signatureBoxplot function takes the scores for each signature and produces an individual boxplot, with jittered points representing individual sample scores. For this specific example, it is clear that some signatures do a better job at differentiating the TB/HIV and HIV only samples than others, as seen by overlapping or separate spreads of the adjacent boxplots.

signatureBoxplot(inputData = ssgsea_result,
                 name = "Boxplots of Signatures, ssGSEA",
                 signatureColNames = names(TBsignatures),
                 annotationColName = "Disease", rotateLabels = FALSE)

Boxplots of Scores, Individual Signatures {.tabset}

If only one boxplot of a signature is desired, then that signature alone should be specified in signatureColNames. Otherwise, an array of plots for all signatures will be produced. Here we use the signatures Anderson_42, Anderson_OD_51, and Zak_RISK_16.

for (i in sigs){

  cat("####", i, "\n")

  print(signatureBoxplot(ssgsea_result, name = i, signatureColNames = i,
                 annotationColName = c("Disease")))

  cat("\n\n")
}

Heatmaps for Individual Signatures {.tabset}

The signatureGeneHeatmap function produces heatmaps that highlight a single selected signature. The resulting plots feature samples on the columns, and the genes in the signature on the rows. The annotation rows at the top are related to both the disease phenotype and to the signature score itself. The gradient of the heatmap is created using the gene expression values in the assay specified by the useAssay parameter. Here, we observe how the log(CPM) values for specific genes relate to the signature score for each sample using the signatures Anderson_42, Anderson_OD_51, and Zak_RISK_16.

for (i in sigs){

  cat("####", i, "\n")

  signatureGeneHeatmap(inputData = ssgsea_result, useAssay = "log_counts_cpm",
                       TBsignatures[sigs][[i]],
                       name = i, signatureColNames = i,
                       annotationColNames = c("Disease"),
                       showColumnNames = TRUE,
                       choose_color = col.me)

  cat("\n\n")
}

Compare scoring methods for a single signature

The compareAlgs function allows multiple scoring methods to be compared via a heatmap or boxplot with samples on the columns and methods on the rows. Here, we compare scoring methods for the "Tabone_RES_25" signature. It seems that singscore may be the best method here, as its sample scores most closely align with the information provided by the annotation data.

An examination of the boxplot and heatmap together determine that PLAGE and the comparing Z-score methods are least helpful in correctly identifying TB from LTBI subjects, although still quite good - average AUC scores are a little less than 0.8 and subjects in different groups are falsely assigned similar scores. According to the boxplot, we see that singscore has the highest predictive AUC next to ssGSEA.

# Heatmap
compareAlgs(hivtb_data, annotationColName = "Disease",
            scale = TRUE,
            algorithm = c("GSVA", "ssGSEA",
                          "singscore", "PLAGE", "Zscore"),
            useAssay = "log_counts",
            signatures = TBsignatures["Tabone_RES_25"],
            choose_color = col.me, show.pb = FALSE,
            parallel.sz = 1)

# Boxplot
compareAlgs(hivtb_data, annotationColName = "Disease",
            scale = TRUE,
            algorithm = c("GSVA", "ssGSEA",
                          "singscore", "PLAGE", "Zscore"),
            useAssay = "log_counts",
            signatures = TBsignatures["Tabone_RES_25"],
            choose_color = col.me, show.pb = FALSE,
            parallel.sz = 1, output = "boxplot")

Comparing scores via bootstrapped AUCs {.tabset}

Table with T-tests & AUC

The TableAUC function creates a table of useful information regarding the scored signatures. First, a 2-sample t-test is conducted on the scores with the TB/HIV status as the response variable. This is intended to give one metric of whether the signature is a valuable identifier of the disease phenotype. The log-scaled p-values are provided for easier means of comparison.

The table also gives the AUC values for the signature scores, along with confidence intervals derived from bootstrapping. Most AUC estimates are fairly high.

tableAUC(ssgsea_result,
         annotationColName = "Disease",
         signatureColNames = names(TBsignatures),
         num.boot = 100,
         pb.show = FALSE)

Boxplots for the bootstrapped AUCs

We can visualize the bootstrapped AUCs for the scored signatures by creating a collection of boxplots.

compareBoxplots(ssgsea_result, annotationColName = "Disease",
                signatureColNames = names(TBsignatures),
                pb.show = FALSE, rotateLabels = TRUE)

ROC plots for all signatures with 95% CI bands

The signatureROCplot_CI function plots the ROC curves for signature scores in separate plots, along with CI bands for the specified level of confidence. The signatureROCplot function is similar, but does not include confidence interval bands.

Note that, in some cases, signatures will be positive identifiers of TB whereas others are negative identifiers, hence some ROC curves will be below the chance line.

signatureROCplot_CI(inputData = ssgsea_result,
                   signatureColNames = names(TBsignatures),
                   annotationColName = "Disease", pb.show = FALSE)

Separate ROC plots, 95% CI bands {.tabset}

for (i in sigs){

  cat("####", i, "\n")

  print(signatureROCplot_CI(inputData = ssgsea_result,
                   signatureColNames = i,
                   annotationColName = "Disease",
                   name = paste("ROC plot,", i, sep = " "), pb.show = FALSE))
  cat("\n\n")
}

Signature Evaluation with Logistic Regression {.tabset}

Another method of signature evaluation featured in the TBSignatureProfiler package is available with the SignatureQuantitative function.

During the training process, we bootstrap the samples, cross-validate the logistic regression prediction of the TB HIV status of each sample, and calculate the validation set AUCs from each cross-validation iteration. In theory, if a signature is a useful predictor of status, it should have a higher average AUC from these logistic regression bootstraps.

### Make an additional binary indicator for signature evaluation
hivtb_data$BinaryTB <- as.numeric(hivtb_data$Disease) - 1

## We can normalize the data and evaluate the signatures
hivtb_norm <- deseq2_norm_rle(assay(hivtb_data, "counts"))

quantitative.result <- SignatureQuantitative(hivtb_norm,
                       targetVec.num = colData(hivtb_data)$BinaryTB,
                       signature.list = TBsignatures[sigs],
                       signature.name.vec = sigs,
                       num.boot = 3,
                       pb.show = FALSE)

We also create a boxplot of AUC for each signature, which provides a clear comparison between the signatures.

plotQuantitative(hivtb_norm, targetVec.num = colData(hivtb_data)$BinaryTB,
                       signature.list = TBsignatures[sigs],
                       signature.name.vec = sigs,
                       num.boot = 3, pb.show = FALSE, rotateLabels = TRUE)

Table of AUC Results

DT::datatable(round(quantitative.result$df.auc.ci, 4),
              options = list(scrollX = TRUE, pageLength = 10),
              rownames = FALSE)

Table of Sensitivity Results

DT::datatable(round(quantitative.result$df.sensitivity.ci, 4),
              options = list(scrollX = TRUE, pageLength = 10),
              rownames = FALSE)

Table of Specificity Results

DT::datatable(round(quantitative.result$df.specificity.ci, 4),
              options = list(scrollX = TRUE, pageLength = 10),
              rownames = FALSE)
sessionInfo()


compbiomed/TBSignatureProfiler documentation built on April 9, 2024, 10:46 p.m.