# Drawing phylogenetic tree

I am trying to generate a tree like:

Here is my code so far:

\documentclass{article}
\usepackage{tikz-qtree}

\begin{document}

\begin{tikzpicture}[every tree node/.style={font=\huge},
level distance=1.1cm,sibling distance=.8cm,
edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}],
frontier/.style={distance from root=350pt} % Align leaf nodes

\Tree
[
\edge node[near end,left] {branch};
[
\edge node[near end, left] {};
[
\edge node[] {}; [.a ]
\edge node[] {}; [.b ]
]
\edge node[] {}; [.c ]
]
\edge node[near end,right] {};
[
\edge node[] {}; [.d ]
\edge node[] {}; [.e ]
]
]
\node[draw] at (0,.2) {root};
\draw (1.6,-1.9) circle (1.3cm);
\draw[thick,->] (0,-4.5) -- (1,-3.2);
\end{tikzpicture}

\end{document}


Which produces the following (PDFLaTex):

My questions are:

1. How to make all the leaves appear at the same level?
2. Is there a better way of drawing circles than manually locating it on the tree?
3. How to make the tree horizontal?

You can use the fit library to fit a node to a set of named nodes. If you use Forest to draw the tree, it offers the fit to=<nodewalk> wrapper to make this easy.

For example,

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shapes.geometric,arrows.meta}
\begin{document}
\begin{forest}
forked edges,
/tikz/every pin edge/.append style={Latex-, shorten <=2.5pt, darkgray},
/tikz/every pin/.append style={darkgray, font=\sffamily},
/tikz/every label/.append style={darkgray, font=\sffamily},
before typesetting nodes={
delay={
where content={}{coordinate}{},
},
where n children=0{tier=terminus, label/.process={Ow{content}{right:#1}}, content=}{},
},
for tree={
grow'=0,
s sep'+=10pt,
l sep'+=15pt,
},
l sep'+=50pt,
tikz+={
\node (p) [draw=blue, circle, ellipse, densely dashed, fit to={l,tree}] {};
\draw [every pin edge] (p) -- (clades);
}
[, !l.edge label={coordinate [pos=0, pin=-135:root] }, !1.edge label={node [pos=.65, every label, above] {branch}}, !11.edge label={coordinate [pos=0, pin={[pin distance=30pt, align=center]135:internal\\node}] }
[
[
[tip (terminal node)]
[b]
]
[c]
]
[[d][e]]
]
\end{forest}

\end{document}

• Thanks!! I am getting errors Illegal parameter number in definition of \pgf@temp. ^^I\end{forest} and Package pgfkeys Error: I do not know the key '/forest/label/.process', to whiu misspelled it. ^^I\end{forest} which is for this piece of the code label/.process={Ow{content}{right:#1}},. Is it because of outdated packages? – havij May 23 '17 at 17:09
• @rzmn Probably. If you get that error when you try to compile exactly the code I posted in a clean .tex, then almost certainly you have an older version of Forest. .process is relatively new and has been extended. Which version of Forest do you have? I've got 2.1.4. – cfr May 23 '17 at 17:15
• yes, I am using the exact code in a clean .tex file. From the .log file it is 'forest 2016/03/04 v2.0.2' – havij May 23 '17 at 17:22
• @rzmn Yes. It is because you have an older version of the package. Is updating an option? – cfr May 23 '17 at 17:25
• @rzmn That depends on how you installed TeX ;). If you used TeX Live or MikTeX, you can just use the package manager. If you are using packages provided by your Linux distro, it can be less straightforward. (That is, you're using apt or something rather than TeX Live's upstream distribution.) – cfr May 23 '17 at 17:36