Biostar Beta. Not for public use.
Adding branch lengths to a topology
0
Entering edit mode
16 months 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).

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).

2
Entering edit mode
15 months ago
Klaus S • 100

You can do it in R

>library(phangorn)

>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")

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.

1
Entering edit mode
15 months ago
Shicheng Guo ♦ 7.5k

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)