Hi Alex, you can use the induced.subgraph() function with symbolic names. E.g. here is an example with a random graph where we pick out the subgraph including the top 10 nodes according to their page rank:
g <- erdos.renyi.game(26, 5/26) V(g)$name <- letters pr <- page.rank(g)$vector top10 <- pr[order(pr, decreasing=TRUE)[1:10]] subnet <- induced.subgraph(g, names(top10)) subnet # IGRAPH UN-- 10 14 -- Erdos renyi (gnp) graph # + attr: name (g/c), type (g/c), loops (g/l), p (g/n), name (v/c) I hope this helps, Gabor On Thu, Mar 7, 2013 at 6:03 PM, Alex Upton <[email protected]> wrote: > > Hello all, > > I have a query I hope that you could help me with. After creating my > network, and calculating a number of metrics, I would then like to > automatically extract the subnets of the nodes with the 10 lowest ranks for > each ( I have ranked the nodes with the highest scores 1, so would like > those nodes from 1 to 10). This has been done as such: > > > wdrank1 <- rank(-wd1s) > brank1 <- rank(-wb1s) > crank1 <- rank(-c1s) > hrank1 <- rank(-h1s) > erank1 <- rank(-e1s) > lrank1 <- rank(-l1s) > drank1 <- rank(-d1s) > > > The names for these nodes are gene symbols, and the output of each of > these objects is the list of all the genes with their ranks for that > category. > > Previously I have used a crude approach to extract the subnets; seeing > which gene symbols are the top ten, and then doing a bit of trial and error > to find the node numerical ID that matches the gene symbol. What I would > like is to take the top 10 gene symbols for each category, and then create > the subnets for these 10 gene symbols automatically. Then, it would be > helpful to output this to an edgelist with the nodes as gene symbols and > not node numerical IDs, so that these lists can then be fed to a program > for gene set enrichment analysis. Is there a way then that I can do this? > Any help would be greatly appreciated. > > Kind regards, > > Alex > > > -------------------------------------------------------------------------------------------- > Alex Upton, BEng, MRes, PG Cert Business Administration > > PhD Researcher Biomedical Informatics, Signals and Systems > School of Electronic, Electrical and Computer Engineering, > College of Engineering and Physical Sciences, University of Birmingham > Edgbaston, Birmingham, B15 2TT, United Kingdom > > Fax: +44 121 4144291 (school general office) > Email: [email protected] > > Personal Web: http://postgrad.eee.bham.ac.uk/uptona/ > > -------------------------------------------------------------------------------------------- > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > -- Gabor Csardi <[email protected]> MTA KFKI RMKI
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
