Closed xiangpin closed 1 year ago
spt
as.phylo.igraph
find.hclust.igraph
https://github.com/YuLab-SMU/ProjectYulab/issues/10
library(igraph) library(treeio) library(ggplot2) library(ggtree) set.seed(123) g <- igraph::sample_gnp(100, .1) %>% set_edge_attr(name='weight', value=abs(rnorm(E(.),3))) tr1 <- spt(g, from = 6, to=V(g), weights = 'weight') tr2 <- spt(g, from = 6, to = V(g), weights = NA) p1 <- ggtree(tr1,layout='circ') + geom_point(color='orange', size= 4) + geom_nodelab(node='all') p2 <- ggtree(tr2, layout='circ') + geom_point(color='orange', size= 4) + geom_nodelab(node='all') p1/p2
library(treeio) library(igraph) library(ggtree) set.seed(123) g <- igraph::sample_gnp(18, .3) %>% igraph::mst() %>% igraph::set_edge_attr(name='weight', value=abs(rnorm(length(igraph::E(.))))) tr1 <- as.phylo(g, branch.length = weight) tr2 <- as.phylo(g) p1 <- ggtree(tr1) + geom_point(color='orange', size= 4) + geom_nodelab(node='all') p2 <- ggtree(tr2) + geom_point(color='orange', size= 4) + geom_nodelab(node='all') p1/p2
tr3 <- find.hclust(g, weight='weight') tr4 <- find.hclust(g, weight=NA) p3 <- ggtree(tr3) + geom_tippoint(color='orange', size=4) + geom_tiplab() p4 <- ggtree(tr4) + geom_tippoint(color='orange', size=4) + geom_tiplab() p3/p4
@xiangpin 有conflict,解决一下。
ok, 已解决
Description
spt
andas.phylo.igraph
find.hclust.igraph
to find the hierarchical cluster analysis of a network with the length of all the shortest paths in the graph.Related Issue
https://github.com/YuLab-SMU/ProjectYulab/issues/10
Example
update
spt
with edge attributeupdate
as.phylo.igraph
with edge attributefind.hclust.igraph