combine 2 plots - one network and one phylogenetic tree
Hi Augusto,
Which layout do you want to reproduce? The layout of the first network
you plot?
Do you know the "tkplot" function of igraph? You can plot the network
using tkplot and then you can read the coordinates of the nodes into a
variable. Like this:
tkplot(dados.igraph,layout=layout.fruchterman.reingold,vertex.color=c(rep("red",6),rep("green",6)),edge.arrow.size=0.2,vertex.size=20,vertex.label=c(paste("P",1:6,sep=""),paste("H",1:6,sep="")));
my_layout<-tkplot.getcoords(1);
So you can use the variable my_layout (a matrix of coordinates) in
other plots of network you want to:
plot(dados.igraph, layout=my_layout)
Sorry if it is not what you are looking for. Maybe if you write
directly to the igraph-help mailing list you can have more luck. They
use to answer the questions quickly:
https://groups.google.com/forum/?fromgroups#!forum/network-analysis-with-igraph
All the best,
Charles
On Wed, Jun 20, 2012 at 4:04 PM, Augusto Ribas <ribas.aca at gmail.com> wrote:
Hello.
I was using the package ipgraph to plot networks of parasites and hosts.
Then i though about plug a phylogeny tree on the plot. But I'm having some
difficulties to do so.
I'll give and CMR , hope someone can help.
#I have data that look like this, 6 parasites ("P") and six host species
("P")
dados<-matrix(c(1,1,1,1,0,0,
? ? ? ? ? ? ? ?0,1,1,1,0,0,
? ? ? ? ? ? ? ?0,0,1,1,0,0,
? ? ? ? ? ? ? ?0,0,0,0,1,0,
? ? ? ? ? ? ? ?0,0,0,0,0,1,
? ? ? ? ? ? ? ?0,0,0,0,0,1),byrow=T,ncol=6,nrow=6,
? ? ? ? ? ? ? ?dimnames=list(paste("P",1:6,sep=""),paste("H",1:6,sep="")))
dados
#Then i convert the data a way i can use with igraph packages
#Is there a more elegant way to change data like this anyway?
library(igraph)
dados.network<-cbind(expand.grid(rownames(dados),colnames(dados)),Presence=c(dados[,]))
dados.network<-dados.network[which(dados.network$Presence==1),1:2]
dados.igraph<-graph.data.frame(dados.network)
plot(dados.igraph,layout=layout.fruchterman.reingold,
vertex.color=c(rep("red",6),rep("green",6)),edge.arrow.size=0.2,vertex.size=20,
vertex.label=c(paste("P",1:6,sep=""),paste("H",1:6,sep="")))
#now i would like to combine 2 plots,
#one phylogenetic tree of the hosts:
library(ape)
host.tree<-rtree(6,rooted=TRUE,tip.label=paste("H",1:6,sep=""))
#with the netwrok, but the network would have to had ?a layout like in
package bipartite
library(bipartite)
#something like this
par(mfrow=c(2,1))
plot(host.tree,use.edge.length=F,direction="downwards")
plotweb(dados)
Althoguht plotweb() do what i would like, in a pretty beautiful graph, i
could not make it do equidistant representation ?for the host species, nor
reproduce this layout with igraph.
If i could reproduce the layout on plot.igraph(), i think it would be easy
to plug the tree on the network.
So anyone know if there is an easy way to do what i'm trying? I'm pretty
stuck here
Thanks for your attention.
Best wishes
Augusto Ribas
--
Grato
Augusto C. A. Ribas
Site Pessoal: http://augustoribas.heliohost.org
Lattes: http://lattes.cnpq.br/7355685961127056
? ? ? ?[[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Um ax?! :) -- Charles Novaes de Santana http://www.imedea.uib-csic.es/~charles PhD student - Global Change Laboratorio Internacional de Cambio Global Department of Global Change Research Instituto Mediterr?neo de Estudios Avanzados(CSIC/UIB) Calle Miquel Marques 21, 07190 Esporles - Islas Baleares - Espa?a Office phone - +34 971 610 896 Cell phone - +34 660 207 940