Question: Adding branch lengths to a topology
0
Entering edit mode

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.

ADD COMMENTlink 9 months ago treesandthings • 10 • updated 9 months ago Shicheng Guo ♦ 7.5k
Entering edit mode
0

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 REPLYlink 9 months ago
jrj.healey
12k
2
Entering edit mode

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 COMMENTlink 9 months ago Klaus S • 100 • updated 9 months ago genomax 68k
Entering edit mode
0

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 REPLYlink 9 months ago
treesandthings
• 10
1
Entering edit mode

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 COMMENTlink 9 months ago Shicheng Guo ♦ 7.5k

Login before adding your answer.

Powered by the version 1.8