## generate random data using normal distribution
## generate 20 features in 20 samples
object <- matrix(rnorm(400),20,20)
objt <- aperm(object, c(2,1))
## calculate the weight matrix
Wmat <- as.matrix(dist(objt, method = "euclidean", diag = TRUE, upper = TRUE, p = 2))
## create a weighted undirectional graph from the weight matrix
gr <- graph.adjacency(Wmat, weighted = TRUE, mode = "undirected")
## find the minimum spanning tree
mst <- minimum.spanning.tree(gr)
ranks <- HDP.ranking(mst)
plot(mst)
Run the code above in your browser using DataLab