nuno-agostinho / psichomics

Interactive R package to quantify, analyse and visualise alternative splicing
http://nuno-agostinho.github.io/psichomics/
Other
35 stars 11 forks source link

Create clusters in PCA plot and use those clusters as data groups #12

Open nuno-agostinho opened 8 years ago

nuno-agostinho commented 8 years ago

These clusters could then be used in survival curves and other analyses.

See also cluster analysis in R (1 and 2) and cluster validation using cIVALID

nuno-agostinho commented 7 years ago

Plot convex hulls from given k-means:

library(cluster)
X <- ruspini
pca <- prcomp(ruspini)
pca <- pca$x[ , 1:2]

# Cluster
pamx <- pam(pca, 5)
cluster <- pamx$cluster

# Plot
plot(pca)
for (each in unique(cluster)) {
    segment <- pca[cluster == each, ]
    hpts <- chull(segment)
    polygon(segment[hpts, ], border=each + 1)
}