Evaluation of Bioinformatics Metrics with evaluomeR"

BiocStyle::markdown()
library(kableExtra)
library(magrittr)
library(SummarizedExperiment)

Introduction

The evaluomeR package permits to evaluate the reliability of bioinformatic metrics by analysing the stability and goodness of the classifications of such metrics. The method takes the measurements of the metrics for the dataset and evaluates the reliability of the metrics according to the following analyses: Correlations, Stability and Goodness of classifications.

Installation

The installation of evaluomeR package is performed via Bioconductor:

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

Prerequisites

The package evaluomeR depends on the following CRAN packages for the calculus: cluster [@cluster2018], corrplot [@corrplot2017]. Moreover, this package also depends on grDevices, graphics, stats and utils from R Core [@rcore] for plotting and on the Bioconductor packages SummarizedExperiment [@summarizedExperiment], MultiAssayExperiment [@multiAssayExperiment] for input/output data.

Using evaluomeR

Creating an input SummarizedExperiment

The input is a SummarizedExperiment object. The assay contained in SummarizedExperiment must follow a certain structure, see Table \@ref(tab:table): A valid header must be specified. The first column of the header is the ID or name of the instance of the dataset (e.g., ontology, pathway, etc.) on which the metrics are measured. The other columns of the header contains the names of the metrics. The rows contains the measurements of the metrics for each instance in the dataset.

ID | MetricNameA | MetricNameB | MetricNameC | ... | --------- | ----------- | ----------- | ----------- | --- | instance1 | 1.2 | 6.4 | 0.5 | ... | instance2 | 2.4 | 5.4 | 0.8 | ... | instance3 | 1.9 | 8.9 | 1.1 | ... |

: (#tab:table) Example of an input assay from a SummarizedExperiment for the evaluomeR package.

Using input sample data from evaluomeR

In our package we provide three different sample input data:

The user shall run the data built-in method to load evaluomeR sample input data. This requires to provide the descriptor of the desired dataset. The datasets availables can take the following values: "ontMetrics", "rnaMetrics" or "bioMetrics".

library(evaluomeR)
data("ontMetrics")
data("rnaMetrics")
data("bioMetrics")

Correlations

We provide the metricsCorrelations function to evaluate the correlations among the metrics defined in the SummarizedExperiment:

library(evaluomeR)
data("rnaMetrics")
correlationSE <- metricsCorrelations(rnaMetrics, margins =  c(4,4,12,10))
# Access the correlation matrix via its first assay:
# assay(correlationSE,1)

Stability analysis

The calculation of the stability indices is performed by stability and stabilityRange functions.

Stability

The stability index analysis is performed by the stability function. For instance, running a stability analysis for the metrics of rnaMetrics with a number of 100 bootstrap replicates with a k-means cluster whose k is 2 (note that k must be inside [2,15] range):

stabilityData <- stability(rnaMetrics, k=2, bs = 100)

The stability function returns the stabilityData object, a ExperimentList that contains the several assays such as the stability mean or the mean, betweenss, totss, tot.swithinss and anova values from the kmeans clustering:

stabilityData

The stability indices plots shown when getImages = TRUE are generated with the values of the stability mean:

assay(stabilityData, "stability_mean")
data <- assay(stabilityData, "stability_mean")
kable(data) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))

The plot represents the stability mean from each metric for a given k value. This mean is calculated by performing the average of every stability index from kranges [1,k] for each metric.

Stability range ### {#sec:stabilityrange}

The stabilityRange function is an iterative method of stability function. It performs a stability analysis for a range of k values (k.range).

For instance, analyzing the stability of rnaMetrics in range [2,4], with bs=100:

stabilityRangeData = stabilityRange(rnaMetrics, k.range=c(2,4), bs = 100)

Two kind of graphs are plotted in stabilityRange function. The first type (titled as "St. Indices for k=X across metrics") shows, for every k value, the stability indices across the metrics. The second kind (titled as St. Indices for metric 'X' in range [x,y]), shows a plot of the behaviour of each metric across the k range.

Goodness of classifications

There are two methods to calculate the goodness of classifications: quality and qualityRange.

Quality

This method plots how the metrics behave for the current k value, according to the average silhouette width. Also, it will plot how the clusters are grouped for each metric (one plot per metric). For instance, running a quality analysis for the two metrics of rnaMetrics dataset, being k=4:

qualityData = quality(rnaMetrics, k = 4)

The data of the first plot titled as "Qual. Indices for k=4 across metrics" according to Silhouette avg. width, is stored in Avg_Silhouette_Width column from the first assay of the SummarizedExperiment, qualityData. The other three plots titled by their metric name display the input rows grouped by colours for each cluster, along with their Silhouette width scores.

The variable qualityData contains information about the clusters of each metric: The average silhouette width per cluster, the overall average sihouette width (taking into account all the clusters) and the number of individuals per cluster:

assay(qualityData,1)
data <- assay(qualityData,1)
kable(data) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
  scroll_box(width = "100%")

Quality range

The qualityRange function is an iterative method that uses the same functionality of quality for a range of values (k.range), instead for one unique k value. This methods allows to analyse the goodness of the classifications of the metric for different values of the range.

In the next example we will keep using the rnaMetrics dataset, and a k.range set to [4,6].

k.range = c(4,6)
qualityRangeData = qualityRange(rnaMetrics, k.range)

The qualityRange function also returns two kind of plots, as seen in Stability range section. One for each k in the k.range, showing the quality indices (goodness of the classification) across the metrics, and a second type of plot to show each metric with its respective quality index in each k value.

The qualityRangeData object returned by qualityRange is a ExperimentList from MultiAssayExperiment, which is a list of SummarizedExperiment objects whose size is diff(k.range)+1. In the example shown above, the size of qualityRangeData is 3, since the array length would contain the dataframes from k=4 to k=6.

diff(k.range)+1
length(qualityRangeData)

The user can access a specific dataframe for a given k value in three different ways: by dollar notation, brackets notation or using our wrapper method getDataQualityRange. For instance, if the user wishes to retrieve the dataframe which contains information of k=5, being the k.range [4,6]:

k5Data = qualityRangeData$k_5
k5Data = qualityRangeData[["k_5"]]
k5Data = getDataQualityRange(qualityRangeData, 5)
assay(k5Data, 1)
data <- assay(qualityRangeData$k_5, 1)
kable(data) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
  scroll_box(width = "100%", height = "150px")

Once the user believes to have found a proper k value, then the user can run the quality function to see further silhouette information on the plots.

General functionality

In this section we describe a series of parameters that are shared among our analysis functions: metricsCorrelations, stability, stabilityRange, quality and qualityRange.

Disabling plotting

The generation of the images can be disabled by setting to FALSE the parameter getImages:

stabilityData <- stability(rnaMetrics, k=5, bs = 50, getImages = FALSE)

This prevents from generating any graph, performing only the calculus. By default getImages is set to TRUE.

Selecting the optimal value of k

evaluomeR analyzes the behavior of the metrics in terms of stability and goodness of the clusters for a range of values of $k$. In case of wishing to select the optimal value for $k$ for a metric in a given dataset we have implemented the getOptimalKValue function, which returns a table stating which is the optimal value of k for each metric.

The algorithm works as follows: The highest stability and the highest goodness are obtained for the same value of $k$. In such case, that value would be the optimal one. On the other hand, the highest stability and the highest goodness are obtained for different values of $k$. In this case, additional criteria are needed. \textit{evaluomeR} does not currently aim at providing those criteria, but to provide the data that could permit the user to make decisions. In the use cases described in this paper, we will apply the following criteria for the latter case:

stabilityData <- stabilityRange(data=ontMetrics, k.range=c(2,4), 
                                bs=20, getImages = FALSE, seed=100)
qualityData <- qualityRange(data=ontMetrics, k.range=c(2,4),
                            getImages = FALSE, seed=100)

kOptTable <- getOptimalKValue(stabilityData, qualityData)
data <- kOptTable
kable(data) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
  scroll_box(width = "100%", height = "150px")

Additionally, you can select another subset of k.range to delimit the range of the optimal k.

kOptTable <- getOptimalKValue(stabilityData, qualityData, k.range=c(3,4))
data <- kOptTable
kable(data) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
  scroll_box(width = "100%", height = "150px")

Metric analysis

We provide a series of methods for a further analysis on the metrics. These methods are: plotMetricsMinMax, plotMetricsBoxplot, plotMetricsCluster and plotMetricsViolin.

The plotMetricsMinMax function plots the minimum, maximum and standard deviation of min/max points of the values of each metric:

plotMetricsMinMax(ontMetrics)

The plotMetricsBoxplot method boxplots the value of each metric:

plotMetricsBoxplot(rnaMetrics)

Next, the plotMetricsCluster function clusters the values of the metrics by using the euclidean distance and the method ward.D2 from hclust:

plotMetricsCluster(ontMetrics)

And finally the plotMetricsViolin function:

plotMetricsViolin(rnaMetrics)

Information

Contact

The source code is available at github. For bug/error reports please refer to evaluomeR github issues https://github.com/neobernad/evaluomeR/issues.

License

The package 'evaluomeR' is licensed under GPL-3.

How to cite

Currently there is no literature for evaluomeR. Please cite the R package, the github or the website. This package will be updated as soon as a citation is available.

Additional information

The evaluomeR functionality can also be access through a web interface^[Evaluome web ] an API REST^[API documentation].

Session information

sessionInfo()

Bibliography ##



Try the evaluomeR package in your browser

Any scripts or data that you put into this service are public.

evaluomeR documentation built on March 15, 2021, 6 p.m.