---
title: "signifinder vignette"
author:
- name: Stefania Pirrotta
affiliation:
- &id Biology Department, University of Padova, Italy
email: stefania.pirrotta@phd.unipd.it
- name: Enrica Calura
affiliation: *id
email: enrica.calura@unipd.it
package: signifinder
abstract: >
signifinder is an R package for computing and exploring a compendium of tumor signatures. It allows to compute a variety of signature scores based on gene expression values. Further, it supports the exploration of the scores proving functions to visualize single or multiple signatures. Currently, signifinder contains 46 distinct signatures collected from the literature relating to multiple tumors and multiple cancer processes.
output:
BiocStyle::html_document:
toc: true
toc_float:
collapsed: true
vignette: >
%\VignetteIndexEntry{signifinder vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.wide=TRUE)
```
# Introduction
In cancer studies, transcriptional signatures are studied as good indicators of cancer phenotypes, for their potential to show cancer ongoing activities and can be used for patient stratification. For these reasons, they are considered potentially useful to guide therapeutic decisions and monitoring interventions. Moreover, transcriptional signatures of RNA-seq experiments are also used to assess the complex relations between the tumor and its microenvironment. In recent years, the new technologies for transcriptome detection (single-cell RNA-seq and spatial transcriptomics) highlighted the highly heterogeneous behaviour of this disease and, as a result, the need to dissect its complexity. To better achieve this result, the combined analysis of multiple signatures may reveal possible correlations between different tumor processes and allow patients (or cells or spots) to be stratified at a broader level of information.
Transcriptional signatures are based upon a specific gene set - and eventually a set of coefficients to differently weight the gene contributions - whose expression levels are combined in a score designed to provide a single-sample (-cell, -spot) prediction. Hence, signatures consist not only of a list of genes but also of an algorithm that defines the computation of the single-sample prediction score. Despite much evidence that computational implementations are useful to improve data reproducibility, applicability and dissemination, the vast majority of signatures are not published along with their computational code and only few of them have been implemented in a software, virtuous examples are: the R package `consensusOV`, dedicated to the TCGA ovarian cancer signature; and the R package `genefu` which hosts some of the most popular signatures of breast cancer.
`signifinder` has been developed to provide an easy and fast computation of several published signatures. Thanks to the compatibility with the Bioconductor data structures and procedures, `signifinder` can easily integrate the most popular expression data analysis packages to complement the results and improve data interpretations.
Also, several visualization functions are implemented to visualize the scores obtained from signatures. These can help in the result interpretations: users can not only browse single signatures independently but also compare them with each other.
# Installation
To install this package:
```{r eval=FALSE}
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("signifinder")
```
# Criteria for signature inclusion
Stringent criteria for the inclusion of the signatures were established: (i) signatures should rely on cancer topics, and be developed and used on cancer samples; (ii) signatures should exclusively use transcriptomic data, though exceptions have been made in case of combination of gene expression and signature-related gene weights; (iii) signatures must release a clear gene list used for the signature definition, where all genes have an official gene symbol (Hugo consortium) or an unambiguous translation (genes without an official gene symbol are removed); (iv) the method to calculate expression-based scores should be unambiguously described; (v) additional clarity about the type of expression in the input (e.g., counts, log counts, FPKM, or others) may also be required.
In the current release of `signifinder`, all the included signatures rely on bulk tumor expression experiments, even if the package infrastructure could potentially store and manage signatures derived by single-cell and spatial transcriptomics. Further, while it may not ever be possible to include all cancer signatures proposed in the literature, our package makes easy the addition of new signatures (by us or by others via “pull requests”, see [Adding new signatures](#adding-new-signatures)).
# How to use signifinder
## Input expression data
The input expression dataset must be normalized RNA-Seq counts (or normalized data matrix from microarrays) of bulk transcriptomics data, single-cell transcriptomics data or spatial transcriptomics data. They should be provided in the form of a matrix, a data frame or a SummarizedExperiment (and respectively SingleCellExperiment/SpatialExperiment). In the last case, the name of the assay containing the normalized values must be "norm_expr". Regardless of the input type, the output data is a SummarizedExperiment (SingleCellExperiment/SpatialExperiment) where the scores computed are put in the `colData` section.
Gene lists of signatures reported in literature are typically in symbol IDs, but `signifinder` can either use gene symbols, NCBI entrez or ensembl gene IDs. Users can say which of the three identifiers they use (SYMBOL, ENTREZID or ENSEMBL) to let the package convert the signature gene lists for the matching of gene data (`nametype` argument inside the signature functions).
When a signature is computed a message is shown that says the percentage of genes used for the calculation of the signature compared to the original list. There is no minimum threshold of genes for signatures to be computed, but a `warning` will be given if there are less than the 30% of signature genes. After a signature has been calculated it is possible to visually inspect signature gene expressions using `geneHeatmapSignPlot` (see [Gene Expression Heatmap](#gene-expression-heatmap)).
Furthermore, the original works, that provide the signatures, also specify the type of expression value (e.g. normalized value, TPM (transcript per million), log(TPM), etc…) that should be used to compute the signature. Therefore, during signature computation, data type should be eventually converted as reported in the original work. When using `signifinder`, users must supply the input data in the form of *normalised counts* (or *normalised arrays*) and, for the signatures which require this, a data transformation step will be automatically performed. The transformed data matrix will be included in the output as an additional assay and the name of the assay will be the name of the conversion (i.e. “TPM”, “CPM” or “FPKM”). Alternatively, if the input data is a `SummarizedExperiment` object that already contains (in addition to the normalized count) also an assay of the transformed data, this will be used directly. Note that in order to be used they must be called “TPM”, “CPM” or “FPKM”. Finally, included signatures have been developed both from array and RNA-seq data, therefore it is crucially important for users to specify the type of data used: “microarray” or “rnaseq” (`inputType` argument inside the signature functions). In `signifinder`, signatures for microarray can be applied to RNA-seq data but not vice versa due to input type conversions.
## Computation of scores
In the following section, we use an example bulk expression dataset of ovarian cancer to show how to use `signifinder` with a standard workflow.
```{r, message=FALSE}
# loading packages
library(SummarizedExperiment)
library(signifinder)
library(dplyr)
data(ovse)
ovse
```
We can check all the signatures available in the package with the function `availableSignatures`.
```{r}
availSigns <- availableSignatures()
```
The function returns a data frame with all the signatures included in the package and for each signature the following information:
* signature: name of the signature
* scoreLabel: label of the signature when computed and inserted inside results
* functionName: name of the function to use to compute the signature
* topic: general cancer topic
* tumor: tumor type for which the signature was developed
* tissue: tumor tissue for which the signature was developed
* requiredInput: tumor data with which the signature was developed
* transformationStep: data transformation step performed inside the function starting from the user's 'normArray' or 'normCounts' data
* author: first author of the work in which the signature is described
* reference: reference of the work
* description: brief description of the signature and how to evaluate its score
```{r echo=FALSE}
knitr::kable(t(availSigns[1,]))
```
We can also interrogate the table asking which signatures are available for a specific tissue (e.g. ovary).
```{r}
ovary_signatures <- availableSignatures(tissue = "ovary",
description = FALSE)
```
```{r echo=FALSE}
knitr::kable(
ovary_signatures,
caption = 'Signatures developed for ovary collected in signifinder.') %>%
kableExtra::kable_paper() %>%
kableExtra::scroll_box(width = "81%", height = "870px")
```
Once we have found a signature of interest, we can compute it by using the corresponding function (indicated in the `functionName` field of `availableSignatures` table). All the signature functions require the expression data and to indicate the type of input data (`inputType` equal to “rnaseq” or “microarray”). Data are supposed to be the normalized expression values in the form of a data frame or a matrix with genes in rows and samples in columns. Alternatively, a `SummarizedExperiment` object containing an assay called 'norm_expr' where rows correspond to genes and columns correspond to samples.
```{r}
ovse <- ferroptosisSign(dataset = ovse,
inputType = "rnaseq")
```
Signatures are often grouped in the same function by cancer topic even if they deal with different cancer types and computation approaches. We can unequivocally choose the one we are interested in by stating the first author of the signature (indicated in the `author` field of `availableSignatures` table). E.g., currently, there are three different epithelial-to-mesenchymal transition (EMT) signatures implemented inside the `EMTSign` function ("Miow", "Mak" or "Cheng"). We can choose which one to compute stating the `author` argument:
```{r}
ovse <- EMTSign(dataset = ovse,
inputType = "rnaseq",
author = "Miow")
```
In this way, "EMT_Miow" is computed. Regardless of the expression input type, the output data of all the signature functions is a `SummarizedExperiment` with the original expression data in the `assay` and the computed signature scores in the `colData`. Thus, the returned object can be resubmitted as input data to another signature function and will be returned as well with the addition of the new signature in the `colData`.
We can also compute multiple signatures at once with the function `multipleSign`. Supplying the expression dataset and the input type without any other argument, all the signatures will be computed. Otherwise, we can specify a sub-group of signatures through the use of the arguments `tissue`, `tumor` and/or `topic` to define signature attributes that will additionally narrow the signature list. Alternatively, we can state exactly the signatures using the `whichSign` argument. E.g. here below we computed all the available signature for ovary and pan-tissue:
```{r}
ovse <- multipleSign(dataset = ovse,
inputType = "rnaseq",
tissue = c("ovary", "pan-tissue"))
```
## Visualization
### Evaluation plot
As a first step, we can visualize some signature's technical parameters to evaluate their reliability for our analysis. Thus, the `evaluationSignPlot` function returns a multipanel plot that shows for each signature: (i) the percentage of genes from the signature gene list that are actually available in the dataset; (ii) the log2 average expressions of these genes (iii) the percentage of zero values in them; (iv) the correlation between scores and total read counts; (v) the correlation between scores and the percentage of total zero values.
```{r fig.width=12}
evaluationSignPlot(data = ovse)
```
### Score distribution plot
Each signature computed can be explored using the `oneSignPlot` function to visualize both the score and the density distribution.
```{r fig.wide=FALSE}
oneSignPlot(data = ovse,
whichSign = "Hypoxia_Buffa")
```
### Gene expression heatmap
Users may be also interested in visually exploring the expression values of the genes involved in a signature. In this case, we can use `geneHeatmapSignPlot` to visualize them. It generates a heatmap of the expression values with genes on the rows and samples on the columns. Further, the function is not restricted to the visualization of only one signature, and we can also plot the expression values of genes from multiple signatures, also evaluating the gene list intersections.
```{r fig.height=3, fig.wide=FALSE}
geneHeatmapSignPlot(data = ovse,
whichSign = "LipidMetabolism_Zheng",
logCount = TRUE)
```
```{r}
geneHeatmapSignPlot(data = ovse,
whichSign = c("IFN_Ayers", "Tinflam_Ayers"),
logCount = TRUE)
```
### Score correlation plot
To easily investigate the relation across multiple signatures, `signifinder` provides the function to easily show the pairwise correlations of the signatures (`correlationSignPlot`). The `whichSign` argument could be set to specify which signatures should be plotted. When it is not stated all signatures inside the `SummarizedExperiment` data are used. Green-blue colors represent anticorrelations while orange-red scale is for positive correlations. Then, signatures are clustered to group together higher related ones.
```{r}
sign_cor <- correlationSignPlot(data = ovse)
highest_correlated <- unique(unlist(
sign_cor$data[(sign_cor$data$cor>0.95 & sign_cor$data$cor<1),c(1,2)]
))
```
### Score heatmap
We can compare scores across different signatures with the `hetmapSignPlot` function. Scores are scaled between zero and one to be comparable to each other. The `whichSign` argument could be set to specify which signatures should be plotted. When it is not stated all signatures inside the `SummarizedExperiment` data are used.
```{r fig.height=9, fig.wide=FALSE}
heatmapSignPlot(data = ovse)
```
```{r fig.height=2.5, fig.wide=FALSE}
heatmapSignPlot(data = ovse,
whichSign = highest_correlated)
```
Users may also be interested in seeing how signatures are sorted in relation to only one or few of them. In this case, we can pass one or few signatures to the `clusterBySign` argument that will be used to cluster samples.
Furthermore, users can add to the plot external sample annotations or plot the internal signature annotations ("signature", "topic", "tumor" or "tissue").
```{r fig.height=10}
heatmapSignPlot(data = ovse,
clusterBySign = paste0("ConsensusOV_Chen_", c("IMR","DIF","PRO","MES")),
sampleAnnot = ovse$OV_subtype, signAnnot = "topic")
```
### Survival plot
Using the function `survivalSignPlot` we can test the association with survival of a signature. The function needs the `summarizedExperiment` with the signature values in the `colData` and the patient survival time data. `survivalSignPlot` uses a Kaplan-Meier curve to test if patients with high or low values of the signature have differences in survival time. Different cut points of the signature score can be indicated through the argument `cutpoint` to define the two patient groups.
```{r}
mysurvData <- cbind(ovse$os, ovse$status)
rownames(mysurvData) <- rownames(colData(ovse))
head(mysurvData)
```
```{r}
survivalSignPlot(data = ovse,
survData = mysurvData,
whichSign = "Pyroptosis_Ye",
cutpoint = "optimal")
```
### Score ridgeline plot
Finally, we can plot ridge lines with one or multiple signatures, also grouping samples by external annotations if needed.
```{r}
ridgelineSignPlot(data = ovse,
whichSign = highest_correlated)
ridgelineSignPlot(data = ovse,
whichSign = highest_correlated,
groupByAnnot = ovse$OV_subtype)
```
## Other examples
Here, we present the results obtained with other two example datasets; one for single-cell transcriptomics and one for spatial transcriptomics.
### Single-cell transcriptomics
We report here the results obtained using the single-cell transcriptomics dataset coming from a glioblastoma tissue of Darmanis et al. (GEO ID: GSE84465, Darmanis, S. et al. Single-Cell RNA-Seq Analysis of Infiltrating Neoplastic Cells at the Migrating Front of Human Glioblastoma. Cell Rep 21, 1399–1410 (2017)). We focused on the cells coming from the BT_S2 patient, that were labeled as immune cells, neoplastic or oligodendrocyte precursor cells (OPC) and that come from both the core and the periphery of the tumor.
We computed all the signatures for “brain” and “pan-tissue” that are available in signifinder running the command `multipleSign` setting `inputType = "rnaseq"` and `tissue = c("brain", "pan-tissue")`. Then, we performed a t-SNE and plotted the signature scores. Here, we can see the ridge plot and the t-SNE colored by some of the signatures computed, all cells or separately for different cell types.
```{r, echo=FALSE, out.width = "100%"}
knitr::include_graphics("figures/vignette_sc.png")
#
```
### Spatial transcriptomics
We used the spatial transcriptomic dataset “Human Breast Cancer: Ductal Carcinoma In Situ, Invasive Carcinoma (FFPE)”, included in the 10x Genomics Visium Spatial Gene Expression data, from the 10x website (https://www.10xgenomics.com). A manual annotation of the tissue area was performed and used to annotate the spots. We computed all the signatures for “breast” and “pan-tissue” cancers available in signifinder running the command `multipleSign` setting `inputType = "rnaseq"` and `tissue = c("breast", "pan-tissue")`. Here, we show the ridge plot and the spatial distribution of scores obtained for the Hipoxia_Buffa signature.
```{r, echo=FALSE, fig.wide=FALSE}
knitr::include_graphics("figures/vignette_st.png")
#
```
# Adding new signatures
Please contact us if you have a gene expression cancer signature that you would like to see added to this package. The only requirement is that the signature has publicly available gene list and method to compute it. The more difficult/custom the implementation, the better, as its inclusion in this package will provide more value for other users in the R/Bioconductor community.
# Session info
Here is the output of sessionInfo() on the system on which this document was compiled.
```{r}
sessionInfo()
```