Question: Adding branch lengths to a topology
0
gravatar for treesandthings
18 months ago by
treesandthings20 wrote:

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 phylogenetics fasta • 857 views
ADD COMMENTlink modified 18 months ago by Shicheng Guo8.4k • written 18 months ago by treesandthings20

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 written 18 months ago by Joe18k
2
gravatar for Klaus S
18 months ago by
Klaus S140
Klaus S140 wrote:

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 modified 18 months ago by genomax91k • written 18 months ago by Klaus S140

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 written 18 months ago by treesandthings20
1
gravatar for Shicheng Guo
18 months ago by
Shicheng Guo8.4k
Shicheng Guo8.4k wrote:

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 modified 18 months ago • written 18 months ago by Shicheng Guo8.4k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1768 users visited in the last hour