% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ShinyFunctions.R
\name{calculate_stability}
\alias{calculate_stability}
\title{Calculate the stability index of the obtained clusters when changing k}
\usage{
calculate_stability(consensus, k)
}
\arguments{
\item{consensus}{consensus item of the sc3 slot of an object of 'SingleCellExperiment' class}

\item{k}{number of clusters k}
}
\value{
a numeric vector containing a stability index of each cluster
}
\description{
Stability index shows how stable each cluster is accross the selected range of k. 
The stability index varies between 0 and 1, where 
1 means that the same cluster appears in every solution for different k.
}
\details{
Formula (imagine a given cluster with is split into N clusters when k is changed, and
in each of the new clusters there are given_cells of the given cluster and also some extra_cells from other clusters):
SI = sum_over_ks(sum_over_clusters_N(given_cells/(given_cells + extra_cells)))/N(corrects for stability of each cluster)/N(corrects for the number of clusters)/length(ks)
}
