getMST {DIAlignR} | R Documentation |
Builds a minimum spanning tree from the distance.
getMST(distMat)
distMat |
(dist) a pairwise distance matrix. |
(matrix) array of tree-edges.
Shubham Gupta, shubh.gupta@mail.utoronto.ca
ORCID: 0000-0003-3500-8152
License: (c) Author (2021) + GPL-3 Date: 2021-05-14
m <- matrix(c(0,13,21,22, 13,0,12,13, 21,12,0,13, 22,13,13,0), byrow = TRUE, ncol = 4, dimnames = list(c("run1", "run2", "run3", "run4"), c("run1", "run2", "run3", "run4"))) distMat <- as.dist(m, diag = FALSE, upper = FALSE) ## Not run: x <- as.data.frame(getMST(distMat)) weights <- reshape2::melt(as.matrix(distMat)) weights$Var <- paste(weights$Var1, weights$Var2, sep = "_") x$weight <- weights[match(paste(x[,1], x[,2], sep = "_"), weights$Var), "value"] g1 <- igraph::graph_from_data_frame(x, directed = FALSE) plot(g1, edge.label = igraph::E(g1)$weight) ## End(Not run)