0

I must ask this question as I am not sure if it is difficult or easy. I'd like to extract a subgraph in igraph but with the following bindings: starting from Viridiplantae-3 to Proteobacteria-2 (see image)

I can find the path from shortest.path() but I am not sure how to extract a subgraph based on list of nodes. Because shortest.path will not include Proteobacteria-1 and Proteobacteria-2. I don't want to include 100.2:Viridiplantae-1,Viridiplantae-2 and 68.1:Stramenopiles-1,Rhodophyta-1.

In short, given Viridiplantae-3 and Proteobacteria-2, I want to extract everything that is in the red.

Plotted undirected graph of tree; there is no "root"

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 is the graph in the image

laemtao
  • 147
  • 11
  • Please in include a reproducible example, complete with data and code. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Gabor Csardi Jun 21 '14 at 00:41
  • Yup, I've added the code block which turns the tree into a graph. – laemtao Jun 21 '14 at 03:22
  • It is not actually clear to me how the circled part is defined. Can you define it properly? – Gabor Csardi Jun 21 '14 at 17:59
  • The circled part is a subgraph which contains the nodes in the shortest path between nodes Viridiplantae-3 and Proteobacteria-2, and the neighbors of the nodes within the shortest path. – laemtao Jun 21 '14 at 18:04
  • No, that is not a good definition. That would also include `100.2` and `68.1`. – Gabor Csardi Jun 21 '14 at 20:24

0 Answers0