Adding branch lengths to a topology
2
0
Entering edit mode
5.6 years ago

Hi everyone,

I have a star-tree (a non-tree - it is just once central node with x number of tips) in .newick with no branch lengths, and a simulated DNA alignment in .fasta format that I would like to use to add branch lengths to the tree.

I do not want to test the fit of the alignment to the tree, or look for better trees, I just want to obtain branch lengths.

Does anyone know a simple way to do this?

Basically I have simulated DNA evolution over the star-tree to explore branch-attraction events. In making a figure to show what I have done, I want to add proper branch lengths to the star tree to show that they are not all uniform in length (gamma distribution was involved, so there should be a distribution of lengths).

Thank you for your help.

newick fasta phylogenetics • 3.2k views
ADD COMMENT
0
Entering edit mode

Easiest way I can thing off the top of my head would be either to use a regex to insert a list of branch lengths, or ‘unfold’ the tree and paste the values in. Treating them as plan text files is probably the quickest.

Otherwise you can probably do this with ETE or dendropy (don’t have any practical code examples for you though right now).

ADD REPLY
3
Entering edit mode
5.6 years ago
Klaus S ▴ 160

You can do it in R

>library(phangorn)

>dat <- read.phyDat("your_file.fas", format = "fasta") # read in data

>ntip <- length(dat)

>tree <- stree(ntip, tip.label = names(Laurasiatherian)) # create star tree

>tree$edge.length <- rep(.1, ntip) # add edge length

> fit <- pml(tree, dat)

> fit <- optim.pml(fit)  # optimise edge length (JC)

> plot(fit, "fan")
ADD COMMENT
0
Entering edit mode

Thank you Klaus, I'll give that a try - by the way, if you are who I think you are I did half of my PhD thesis with your package. Thank you for all of your hard work.

ADD REPLY
1
Entering edit mode
5.6 years ago
Shicheng Guo ★ 9.6k

Suppose newdata is a 0/1 matrix with row is sampleID and column is Mutation (Yes or No). Try the following script to prepare trees.

library(gplots)
library(VennDiagram)
newdata<-rbind(newdata,Germline=0)
input<-as.phyDat(newdata, type="USER", levels = c(0, 1))
pratchet <- pratchet(input)
treeRatchetBL<- acctran(pratchet,input)
write.tree(treeRatchetBL,file=paste(i,"pratchet.tree",sep="."))
plot(root(treeRatchetBL,outgroup="Germline"),cex=0.95)
ADD COMMENT

Login before adding your answer.

Traffic: 1688 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6