Last data update: 2014.03.03

R: Fits 2 regression lines to data to estimate the knee (or...
kneepointDetectionR Documentation

Fits 2 regression lines to data to estimate the knee (or elbow) point.

Description

With an appropriate sigma value, the curve of eigenvalues has a knee point shape. The bending point is a good estimate for the number of informative spectral clusters because the eigenvalues above the corresponding threshold can reasonably be assumed to be close to 1. This function estimate the knee point by fitting 2 lines using linear regression.

Usage

  kneepointDetection(vect, PlotFlag=FALSE)

Arguments

vect

The vector of values on which the 2 regression lines will be fitted.

PlotFlag

If TRUE and in unix, an animation will be produced in tmpfigs folder that shows how the best selected model in gif format.

Details

The running time is in order of minutes for 100 points. This function was borrowed from flowMeans package and for application in SamSPECTRAL package, it was customized such that the first line is always horizontal.

Value

Returns a list where MinIndex is the index of the knee point and l1 and l2 the fitted lines.

Author(s)

Nima Aghaeepour

References

Aghaeepour N., Nikolic R., Hoos HH., Brinkman RR.: Rapid cell population identification in flow cytometry data. Cytometry A, 2011, 79:6.

See Also

changepointDetection

Examples

  ## Data
    values <- rep(1,times=10)
    values <- c(values,(10:0)/10)
    
  ## Looks like knee point:
  plot(values)

  ## Find the knee point:
  detected <- kneepointDetection(vect=values, PlotFlag=FALSE)
  print(detected$MinIndex)
  ##  Also, under unix, set PlotFlag=TRUE and look at animation.gif.

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(SamSPECTRAL)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/SamSPECTRAL/kneepointDetection.Rd_%03d_medium.png", width=480, height=480)
> ### Name: kneepointDetection
> ### Title: Fits 2 regression lines to data to estimate the knee (or elbow)
> ###   point.
> ### Aliases: kneepointDetection
> ### Keywords: cluster
> 
> ### ** Examples
> 
>   ## Data
>     values <- rep(1,times=10)
>     values <- c(values,(10:0)/10)
>     
>   ## Looks like knee point:
>   plot(values)
> 
>   ## Find the knee point:
>   detected <- kneepointDetection(vect=values, PlotFlag=FALSE)
>   print(detected$MinIndex)
[1] 11
>   ##  Also, under unix, set PlotFlag=TRUE and look at animation.gif.
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>