biocLite(“ggtree”,type=“source”)
library(“ggplot2”)
library(ggtree)
tree <- read.tree("tree.tre")
ggtree(tree)
fasta<-readDNAStringSet("aligned.fas",format="fasta")
msaplot(ggtree(tree),fasta)
When I set the parameter branch.length="none", it looks like a normal tree again.
2. In my second step, to visualize the tree with multiple sequence alignment, every time I run msaplot(ggtree(tree),fasta), I get this:
Error in msaplot(ggtree(tree), fasta) : multiple sequence alignment is not available... -> check the parameter 'fasta'...
but when I check "fasta" by itself, it looks like a fasta file:
> fasta A DNAStringSet instance of length 4 width seq names [1] 9003 GCGCCCGAACAGGGACTTGAAAG...CAATAAAGCTTGCCTTGAGTGC 1 9003 bp [2] 9003 GCGCCCGAACAGGGACCTGAAAA...CAATAAAGCTTGCCTTGAGTGC 4 9003 bp [3] 9003 A----------------------...CAATAAAGCTTGCCTTGAGTGC 2 9003 bp [4] 9003 GCGCCCGAACAGGGACTTGAAAG...CAATAAAGCTTGCCTTGAGTGC 3 9003 bp
Any help would be appreciated!
Thanks,
Radwa
--
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
Homepage: https://guangchuangyu.github.io/ggtree
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/0cf6bff8-465f-43a4-a54c-932e6fb65976%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
ggtree did plotting your tree correctly as you can check:
> x = read.tree("four.tre")
> x$edge.length
[1] -0.00267 0.00361 -0.00230 0.00471 0.00287
that your tree contains negative branch length. You can plot the tree topology without branch length using ggtree(x, branch.length='none').
For the msaplot issue, it is due to the taxa name in your tree not matched with fasta sequences.
> x$tip.label
[1] "1" "4" "2" "3"
> readDNAStringSet("Four.txt") -> s
> names(s)
[1] "1 9003 bp" "4 9003 bp" "2 9003 bp" "3 9003 bp"
If you modify the taxa name, you can align the sequence with the tree.
names(s) = sub("(\\d).*", "\\1", names(s))
msaplot(ggtree(x), BStringSet(s)) -> p1
msaplot(ggtree(x, branch.length='none'), BStringSet(s)) -> p2
p1 + ggtitle("msaplot(ggtree(x), BStringSet(s))") -> p1
p2 + ggtitle("msaplot(ggtree(x, branch.length='none'), BStringSet(s))") -> p2
multiplot(p1, p2, ncol=2)

Hello Guangchuang,thanks for your reply. I attached a sample tree here, only four sequences. The original aligned four sequences are also attached.Best,Radwa
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree...@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/0cf6bff8-465f-43a4-a54c-932e6fb65976%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----~--~---------~--~----~------------~-------~--~----~Guangchuang Yu, PhD Candidate
State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong KongHong Kong SAR, China-~----------~----~----~----~------~----~------~--~---