YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

add find.spt funtion #102

Closed xiangpin closed 1 year ago

xiangpin commented 1 year ago

Description

Related Issue

https://github.com/YuLab-SMU/ProjectYulab/issues/10

Example

library(treeio)                                                                                                                                                                                                    library(ggtree)
library(igraph)
library(ggplot2)

set.seed(123)
g <- sample_gnp(888, 3/200)

spt <- find.spt(g, 6, V(g))
Nnode(spt, internal.only = FALSE)

p <- ggtree(spt, layout = 'radial') +
    geom_nodepoint(color='orange', size=3) +
    geom_tippoint(color='orange', size=3) +
    ggtitle("spt")

g2 <- mst(g)
mst.tree <- as.phylo(g2)
p2 <- ggtree(mst.tree, layout = 'radial') +
      geom_nodepoint(color='orange', size=3) +
      geom_tippoint(color='orange', size=3) +
      ggtitle('mst')

p + p2

捕获

This is the first version, next, the weight of network edges might need to be considered as the branch.length of spt.