graph - Subgraph extraction based on starting and terminal node -
i must inquire question not sure if hard or easy. i'd extract subgraph in igraph next bindings: starting viridiplantae-3
proteobacteria-2
(see image)
i can find path shortest.path() not sure how extract subgraph based on list of nodes. because shortest.path not include proteobacteria-1
, proteobacteria-2
. don't want include 100.2
:viridiplantae-1
,viridiplantae-2
, 68.1
:stramenopiles-1
,rhodophyta-1
.
in short, given viridiplantae-3
, proteobacteria-2
, want extract in red.
reproducible instructions:
library(ape) library(igraph) cat("(((viridiplantae_1:1.22123006e-06,viridiplantae_2:1.22123006e-06)100.2:0.9709833387,viridiplantae_3:1.217705775)100.1:1.394125713,((proteobacteria_1:0.2479324862,proteobacteria_2:0.4385740351)100.3:0.696357212,(rhodophyta_1:1.675875775,stramenopiles_1:1.869948709)68.1:0.48853466)52.1:0.2231628399,proteobacteria_3:0.8491431473);", file = "testtree.tre", sep = "\n") cur_tree <- read.tree("testtree.tre") cur_tree$node.label[1] <- "root" cur_grph <- as.igraph(cur_tree)
cur_grph graph in image
graph igraph
No comments:
Post a Comment