igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] combine 2 plots - one network and one phylogenetic tree wit


From: Augusto Ribas
Subject: Re: [igraph] combine 2 plots - one network and one phylogenetic tree with R
Date: Wed, 20 Jun 2012 14:41:36 -0400

#Data
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


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)

library(ape)
host.tree<-rtree(6,rooted=TRUE,tip.label=paste("H",1:6,sep=""))

ordem<-as.numeric(as.factor(host.tree$tip.label))

#Plot
par(mfrow=c(2,1),mar=c(0,9.5,0,9.5))
plot(host.tree,use.edge.length=F,direction="downwards",show.tip.label=F)
par(mar=c(0,0,0,0))
plot(dados.igraph,layout=matrix(c(1:6,ordem,rep(c(1,2),each=6)),ncol=2,nrow=12),
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'll work better the lower part of the network, it dont really
need to be flat, just for now, rescale, and other things to make
pretty look.
But i think i understand now the ideia. As i dont have a computer
background, so i think sometimes a stuck on simple things.
Thank you very much for the attention :)

Best wishes


2012/6/20 Gábor Csárdi <address@hidden>:
> Hi,
>
> On Wed, Jun 20, 2012 at 11:21 AM, Augusto Ribas <address@hidden> wrote:
> [...]
>> #but i would like to make this:
>> #something like this draw:
>> http://oi47.tinypic.com/2j2szcy.jpg
>>
>> so instead the plotweb for the network plot, i would like to use
>> plot.igraph()
>> But is there some simple way, like a layout that would make it?
>> Hope i'm not confuseing everything.
>
> First of all, you can make use of the 'rescale' argument of
> plot.igraph, to make sure that the layout that you supply is not
> scaled.
>
> To get the layout itself, you'll need to fix some x and y coordinates
> for the vertices. This can be done with layout.fruchterman.reingold,
> and the 'minx', 'miny', 'maxx', etc. arguments. Basically you'll need
> to fix all the 'y' coordinates and the 'x' coordinates of the top row,
> right?
>
> If the automatic layout is not good enough, you can update it by hand,
> e.g. by plotting it via tkplot() first, adjusting it, and then calling
> tkplot.getcoords() to get the coordinates.
>
> This'll require some experimenting, but it should be possible.
>
> Best,
> G.
>
> [...]



-- 
Grato
Augusto C. A. Ribas

Site Pessoal: http://augustoribas.heliohost.org
Lattes: http://lattes.cnpq.br/7355685961127056



reply via email to

[Prev in Thread] Current Thread [Next in Thread]