Skip to content

Hierarchical Clustering with an Ensemble of Principle Component Trees for Interpretable Patient Stratification

License

Notifications You must be signed in to change notification settings

markusloecher/TAPIO

 
 

Repository files navigation

TAPIO

Required packages

TAPIO depends on the packages NbClust, fastcluster, and FactoMineR.

library(NbClust)
library(fastcluster)
library(FactoMineR)

Clustering using TAPIO

source("~/GitHub/TAPIO/TAPIO.R")

data(iris)
D = iris[,1:4]

# custom function to implement min max scaling
minMax <- function(x) {
  (x - min(x, na.rm=TRUE)) / (max(x, na.rm=TRUE) - min(x, na.rm=TRUE))
}

D_norm = as.data.frame(lapply(D, minMax))
D_norm = as.matrix(D_norm)

outcome = iris[,5]

res = TAPIO(D_norm, k=3, n_trees=1000, levels=3)

# Check the performance of clustering
library(aricode)

ARI(res$cl, outcome)

Feature importance

source("~/GitHub/TAPIO/importance.R")

fimp = importance(res)

rownames(fimp) = unique(outcome)
colnames(fimp) = colnames(iris)[1:4]

fimp

Clustering longitudinal data using TAPIO

source("~/GitHub/TAPIO/longTAPIO.R")
source("~/GitHub/TAPIO/TAPIO.R")

data(iris)
D = iris[,1:4]

# custom function to implement min max scaling
minMax <- function(x) {
  (x - min(x, na.rm=TRUE)) / (max(x, na.rm=TRUE) - min(x, na.rm=TRUE))
}

D_norm = as.data.frame(lapply(D, minMax))
D_norm = as.matrix(D_norm)

outcome = iris[,5]

## define the repeated measures (toy example with iris)
# Ten measures per sample
rownames(D_norm) = sort(rep(1:10, 15))

res = longTAPIO(D_norm, k=3, n_trees=1000, levels=3)

res$cl

About

Hierarchical Clustering with an Ensemble of Principle Component Trees for Interpretable Patient Stratification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 99.1%
  • R 0.9%