I'm interested in getting the X and Y coordinates from a minimum spanning tree to use for some non-igraph plotting and export for merging with another data set. However, I'm having trouble understanding how to obtain the coordinates from the graph object. It seems that typically, the layout would contain the coordinates for plotting vertices, but plotting of mst graphs doesn't use a separate layout object that I can tell. I mean, you can specify a layout with vertex coords given, but it would defeat the purpose of allowing the tree to be drawn in a mst style, preventing edge overlaps etc.
None of the attributes functions (i.e. get.vertex.attributes) seem to return anything but empty lists. Looking at the mst function isn't terribly informative as it seems to call out to C code.
What am I missing? Here's what I'm doing to get the mst graph object. This data is coming from a matrix (mstmatrix below) where rows are cluster IDs from a clustering operation, columns are mean feature values.
mydist <- dist(mstmatrix, method = 'euclidean', diag =TRUE, upper = TRUE) #generate distance matrix object
distmat <- as.matrix(mydist) #convert to matrix object
g <- graph.adjacency(distmat, weighted = TRUE) #create adjacency matrix
mymst <- mst(g)
plot(mymst)
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RColorBrewer_1.1-2 igraph_1.1.2 pastecs_1.3-18 boot_1.3-20 reshape2_1.4.2 stringr_1.2.0
[7] ggplot2_2.2.1 plyr_1.8.4 pheatmap_1.0.8 edgeR_3.16.5 limma_3.30.13 Matrix_1.2-11
loaded via a namespace (and not attached):
[1] locfit_1.5-9.1 Rcpp_0.12.13 lattice_0.20-35 grid_3.3.3 gtable_0.2.0 magrittr_1.5
[7] scales_0.5.0 stringi_1.1.5 rlang_0.1.2 lazyeval_0.2.0 tools_3.3.3 munsell_0.4.3
[13] pkgconfig_2.0.1 colorspace_1.3-2 tibble_1.3.4