You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,21 +4,27 @@ Phy2HTML is a simple Python program that is designed to read a tree in Newick fo
4
4
5
5
The displayed tree is simplistic compared to what advanced phylogenetic visualization software can do, but it creates an output that may be more appropriate for display on the web, at least in some circumstances (*e.g.*, you can easily create links from the labels/taxa on the tree to any other page). The display style is simple, but can also be easily modified through basic application of CSS. Tree shape is limited to rectangular branches with the root on the left and tip labels on the right.
6
6
7
-
The program assumes/requires the tree to be rooted and it cannot contain reticulations, although polytomies are fine. At this time the program does not scale branch lengths; it is designed for display of branching patterns not evolutionary distances. Branches are simply scaled to equal node depths (the program will read branch lengths without a problem, it just doesn't use them).
7
+
The program assumes/requires the tree to be rooted and it cannot contain reticulations, although polytomies are fine. The program can draw the tree with or without scaled branch lengths.
8
8
9
9
You can see a simple example of the output by viewing [test_tree.html](http://htmlpreview.github.io/?https://github.com/msrosenberg/Phy2HTML/blob/master/test_tree.html) in a browser. (Obviously this only works on browsers which support grid css; with legacy browsers such as Internet Explorer, your mileage may vary).
10
10
11
-
Two sample Newick files are included, one with 11 taxa and one with 66. There is no technical limit to the size of the tree it can display, but very large trees will likely become visually unwieldy just due to the standard scaling issues one would have with any very large tree.
11
+
Two sample Newick files are included, one with 11 taxa and one with 66. The 66 taxa tree contains branch lengths; the 11 taxa tree does not. There is no technical limit to the size of the tree it can display, but very large trees will likely become visually unwieldy just due to the standard scaling issues one would have with any very large tree.
12
12
13
13
The code is written in Python 3 and works in vanilla Python with no external dependencies.
14
14
15
-
To use, simply run phy2html.py (for an interactive mode that will prompt for input and output file names) or import the module and call the function *create_html_tree(inname, outname)* where inname is the name of a simple text file containing a tree in Newick format and outname is the desired name for the HTML output.
15
+
To use, simply run phy2html.py (for an interactive mode that will prompt for input and output file names) or import the module and call the function *create_html_tree(inname, outname)* where inname is the name of a simple text file containing a tree in Newick format and outname is the desired name for the HTML output (a variety of other parameters are entirely optional).
16
16
17
17
*create_html_tree()* returns the html as a list, so if calling the function directly you can set outname as an empty string to suppress writing the output to a file, but still use the returned list as input into other code.
18
18
19
-
Additional options allow one to set default column widths and row heights, which effect the scale over which the tree will be drawn. These can also be changed through post-processing editing of the output css styles.
19
+
Additional options include:
20
20
21
-
An optional parameter is a *prefix* which will be pre-appended to the various css classes and ids; this can be used to more readily differentiate the classes and ids created by the code, particularly if one plans on using the output to display multiple trees in the same page.
21
+
- Draw the branch lengths to scale:
22
+
- If this option is chosen, you can specify how many columns you wish to scale the tree over (default = 1000). Larger numbers allow more precise visualization of branch length differences, but potentially require more screen width (by default each column will be 1 pixel wide, although this can be changed, including fractional column widths).
23
+
- If branch lengths are not being drawn to scale, one can specify the default column width at runtime.
24
+
- Default row height: Each taxon label is drawn over two rows and two empty rows are used as spacers between taxon labels.
25
+
- Default tip label width: how much space to preserve for tip labels past the end of the tree
26
+
- An optional *prefix*: This label will be pre-appended onto the various css classes and ids; it can be used to more readily differentiate these classes and ids automatically created by the program, and is particularly useful if you wish to combine multiple trees into a single webpage.
27
+
- Labeling branches with CSS names: this option can be used to put the CSS labels on every horizontal and vertical line. It is not meant for final output, but rather as an aid in identifying which lines is which if you wish to customize particular elements. If using this option, you might want to modify the row height (*e.g.*, to 1em or 1.1em) so that the branch labels do not overlap the drawn lines.
22
28
23
-
Another option is to label the branches with the names that appear in the html as id's. This option is not meant for final production, but is a useful aid if one wishes to modify the style for individual branches.
29
+
Many of these elements (*e.g.*, row heights, column heights), can be modified directly in the output HTML/CSS and do not require one to rerun the program. When running the program these elements can (and should) include standard CSS units (*e.g.,* 10px or 1em).
0 commit comments