2
$\begingroup$

I would like to visualize tree with multiple sequence alignment. My din.newick file is shown below,

(org1:0.49999997,org2:0.47298786,org3:28.37858179);

My din.fasta alignment file shown below,

>org1
ATGCTA
>org2
TAGCAT
>org3
AGTAGT

I have tried the following code,

library(tidyverse)
library(ggtree) 
library(seqinr)
tree = read.tree("din.newick") 
msaplot(p=ggtree(tree), fasta = "din.fasta")
msaplot(p=ggtree(tree) + geom_tiplab(align=TRUE), fasta = "din.fasta")

The above mentioned code is generating tree with the alignment matrix, but the tree root tip labels are not visible. It is either overlapped with matrix or it is not at all visible. msaplot(p=ggtree(tree) + geom_tiplab(align=TRUE), fasta = "din.fasta") Kindly help me to fix this issue.

$\endgroup$
0

2 Answers 2

4
$\begingroup$

You were very close, you just need to supply the offset argument to msaplot().

So using your code block above with one extra argument in msaplot()

library(tidyverse)
library(ggtree) 
library(seqinr)
tree = read.tree("din.newick") 
msaplot(p=ggtree(tree), fasta = "din.fasta")
msaplot(p=ggtree(tree) + geom_tiplab(align=TRUE), fasta = "din.fasta", offset = 5)

yields

msaplot with offset

Thank you for supplying a minimal and reproducible example!

$\endgroup$
1
  • 1
    $\begingroup$ Thank you @Kohl Kinning. $\endgroup$
    – Kumar
    Jun 18, 2019 at 4:45
0
$\begingroup$

I suspect the solution is to realign the two plots within "ggarrange", available here

The problem is stacking ggtree with geom_tiplab. The ggarrange library is described on STHDA here

I have not used this library however, but it should be easy because you are working singly within R. I tend to use ggplot2 within Python via rpy2, which is much more difficult and restricted.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.