[R] Question about combining foodwebs and phylogenetic trees

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Wed May 6 00:01:34 CEST 2020


I think it unlikely that you'll get such specific help here.
Try posting on:
R-SIG-phylo: R SIG on phylogenetic and comparative methods and analyses
instead.

(I also assume you are aware of:
https://CRAN.R-project.org/view=Phylogenetics  ,
but I have no idea whether it is helpful).


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Tue, May 5, 2020 at 2:12 PM Charles Lehnen <charleslehnen using gmail.com> wrote:
>
> I have trying to combine foodweb outputs like the bipartite package's
> plotweb() function of bipartiteD3’s bipartite_D3 function with phylogenetic
> trees, similar to a tanglegram. Because of the very large size and a high
> amount of variability in my dataset, standard tanglegrams turn out very
> convoluted, but the plotweb() outputs are still lovely.
>
> I was able to export tips to manually order the tips of the plotweb()
> output to match the order of the phylogenetic tree tips which allowed me to
> align tips manually in Inkscape, but this proved extremely time consuming
> whenever I made an addition to my dataset.
>
> require('ape')
>
> tree1<-read.tree(text="((A,(B,(C,D))),E);")
> tree1<-ladderize(tree1, right = FALSE)
>
> tree2<-read.tree(text="(F,(G,((H,I),(J,K))));")
>
> is_tip <- tree1$edge[,2] <= length(tree1$tip.label)
> ordered_tips <- tree1$edge[is_tip, 2]
> tree1tips<-tree1$tip.label[ordered_tips]
>
> is_tip <- tree2$edge[,2] <= length(tree2$tip.label)
> ordered_tips <- tree2$edge[is_tip, 2]
> tree2tips<-tree2$tip.label[ordered_tips]
>
>
> I tried to edit the plotweb() script to accept phylo class variables as an
> additional argument, but that was evidently beyond my abilities at this
> time.
>
> I also tried combing the outputs using the grid package, we were able to
> visually combine outputs next to one another and match the order of the
> tips. However, I have not been able to figure out how to actually line up
> the tips of the trees to the outputs of plotweb(). This becomes very
> evident with my actual, very large dataset
>
> require('ape')
> require('bipartite')
> require('ggplotify')
> require('cowplot')
> require('grid')
>
> tree1<-read.tree(text="((A,(B,(C,D))),E);")
> tree1<-ladderize(tree1, right = FALSE)
>
> tree2<-read.tree(text="(F,(G,((H,I),(J,K))));")
>
> bipartite<-cbind(c(0,2,3,2,0,0),c(2,0,2,4,8,0),c(4,3,0,0,5,0),c(0,2,0,0,0,1),c(0,7,2,2,0,0))
> colnames(bipartite)<-c("D","C","B","A","E")
> rownames(bipartite)<-c("K","J","I","H","G","F")
> bipartite<-as.data.frame(bipartite)
>
> p12 = as.grob(~cophyloplot(tree1, tree2))
> bipartite = as.data.frame(t(bipartite))
> p3 = as.grob(~plotweb(bipartite,
>         method = "normal",
>         empty = "false",
>         text.rot = "90"
>         ))
> grid.newpage()
> grid.draw(p12)
> vp = viewport(x = 0.53, y = 0.6, width = 0.6, height = 0.8, angle = -90)
> pushViewport(vp)
> grid.draw(p3)
>
>
> If anyone could direct me on how to proceed, I would greatly appreciate it!
> I have been coming back to this problem for many months now and have not
> been to solve it
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list