phylogeny

Different color for different cluster in a tree using adegenet R package

我的未来我决定 提交于 2021-02-11 08:35:10
问题 I am using the R package adegenet to plot the neighbor-joining tree. In my file I have 20,000 columns and 500 rows. Rows correspond to individuals. My first column is Population ID and second column is Individual ID. Columns contain values 0,1 & 2. I am able to plot a tree in one color, but depending upon the population I want every cluster to be a different color. This is what I did, If "dat" is my data file,then D<-dist(as.matrix(dat)) tre<-nj(D) plot(tre, type = "unr", show.tip.lab = TRUE,

How to colour the branches of an unrooted tree using a variable in R

我只是一个虾纸丫 提交于 2021-01-27 20:50:59
问题 I would like to generated unrooted neighbour joining trees from input haplotype data, and then colour the branches of the trees based on a variable. I am using the packages Ape and ggtree. The haplotypes and co-variables (metadata) are on two separate files with matching sample names. I have been able to produce trees and colour the tips of the trees by variables, but not the tree branches. Using mock data - # Packages library('ggplot2') library('ape') library('phangorn') library('dplyr')

Phylogenetics in R: collapsing descendant tips of an internal node

旧街凉风 提交于 2020-01-13 21:04:06
问题 I have several thousand gene trees that I am trying to ready for analysis with codeml. The tree below is a typical example. What I want to do is automate the collapsing of tips or nodes that appear to be duplicates. For instance, descendants of node 56 are tips 26, 27, 28 etc all the way to 36. Now all of these other than tip 26 appear to be duplicates. How can I collapse them all into a single tip, leaving just tips 28 and one representative of the other tips as the descendants of node 56? I

Link tip labels to phylogenetic tree using dots

▼魔方 西西 提交于 2020-01-13 05:50:13
问题 I'm trying to produce a non-ultrametric tree using the ape package in R and the function plot.phylo(). I'm struggling to find any documentation on how to keep the tip label vertically aligned on their left edge and with a series of dots (variable length) linking the species' name to the tip of the node. Any help would be much appreciated as well as links to other packages within R that may be able to achieve this. An example of the newick tree I don't have any tree examples of what i want,

Phylogenetic tree

时光毁灭记忆、已成空白 提交于 2020-01-06 18:11:08
问题 I am working to have a phylogenetic tree based on pairwise-data of genes.Below is my subset of the data(test.txt).The tree does not has to be constructed on the basis of any DNA sequences,but just treating it as words. ID gene1 gene2 1 ADRA1D ADK 2 ADRA1B ADK 3 ADRA1A ADK 4 ADRB1 ASIC1 5 ADRB1 ADK 6 ADRB2 ASIC1 7 ADRB2 ADK 8 AGTR1 ACHE 9 AGTR1 ADK 10 ALOX5 ADRB1 11 ALOX5 ADRB2 12 ALPPL2 ADRB1 13 ALPPL2 ADRB2 14 AMY2A AGTR1 15 AR ADORA1 16 AR ADRA1D 17 AR ADRA1B 18 AR ADRA1A 19 AR ADRA2A 20 AR

Draw on a phylogeny edge with R

时光总嘲笑我的痴心妄想 提交于 2019-12-25 05:15:32
问题 I want to draw a symbol (cross) anywhere along an edge of a phylogeny with R. Let us take that tree: tree.mod (((((hg19:0.0295977,macFas5:0.0351997)hg19-macFas5:0.0796862,otoGar3:0.153768)hg19-otoGar3:0.0189364,(((speTri2:0.136745,(mm10:0.0836004,rn5:0.0894755)mm10-rn5:0.221692)speTri2-mm10:0.009583,cavPor3:0.230585)speTri2-cavPor3:0.0279417,oryCun2:0.212423)speTri2-oryCun2:0.0141334)hg19-speTri2:0.0224427,((susScr3:0.127502,(camFer1:0.111428((HLbalAcu1:0.0196864,(HLphyCat1:0.0216245,

Coloured lines for tangelgram - package ape function cophyloplot

旧街凉风 提交于 2019-12-24 06:58:08
问题 I am trying to do a phylogenetic comparison of two trees which contain the same taxa. I want to colour the connections based on isolation site. I had thought I had performed this successfully but there is error in my work flow i.e. the coloured lines are not corresponding to isolation site accurately . I was wondering if you have any insights, please find my reproducible example below. site <- structure(list(name = structure(c(1L, 3L, 4L, 5L, 6L, 7L, 8L,9L, 10L, 2L), .Label = c("t1", "t10",

All possible Regression in R: Saving coefficients in a matrix

随声附和 提交于 2019-12-18 09:34:37
问题 I am running code for all possible models of a phylogenetic generalised linear model. The issue I am having is extracting and saving the beta coefficients for each model. I want to save the coefficients into a matrix, where the columns correspond to a specific variable and the rows correspond to a formula.The issue arises because the variables are different for every model. So one cannot simply row bind the coefficients to the matrix. The example below shows where I am up to in the problem: y

Changing tip labels for a multiphylo object

被刻印的时光 ゝ 提交于 2019-12-11 16:22:47
问题 The answer and question is related to this post: Change tip labels in phylogeny in R. I have old tip labels I want to replace with new tip labels because of taxonomic changes. How would I do this with a multiPhylo object in R? I have a random distribution of trees from the posterior I would like to update with new taxonomic names. 回答1: multiPhylo objects are simply lists of phylo objects so the best way to modify them is to use lapply . First you should define the function allowing to rename

R: How to update model frame after reducing model formula

旧时模样 提交于 2019-12-11 11:37:12
问题 I am working a phylogenetic multiple regression using the caper package on Windows 7, and am receiving a Model frame / formula mismatch error consistently when ever I try to graph a residual leverage plot after generating a reduced model. Here is the minimal code needed to reproduce the error: g <- Response ~ (Name1 + Name2 + Name3 + Name4 + Name5 + Name6 + Name7)^2 + Name1Sqd + Name2Sqd + Name3Sqd + Name4Sqd + Name5Sqd + Name6Sqd + Name7Sqd crunchMod <- crunch(g, data = contrasts) plot