TreeViz / metastyle

Styled publication of NeXML/NeXSON trees
MIT License
2 stars 6 forks source link

phylostylotastic reborn

We have taken over this repo for a broader project than the original phylostylotastic. The general thrust of it is to move things forward with regard to supporting portable renderings of richly annotated trees with data. The phylostylotastic approach is one part of one possible approach to this challenge.

Our plan

Our plan has not fully materialized, but it is something like this

Serialization and rendering exercise

phylostylotastic

Styled publication of NeXML/NeXSON trees. See the project wiki for more information.

This is a proof-of-concept implementation, applying TSS styles to the existing tree-visualization features of ETE.

Prerequisites

Installation instructions for ETE are here (for linux and Mac OS X). For Mac users who prefer Homebrew, @gaurav suggests these steps instead:

brew install qt sip pyqt

Quick start

easy_install pip
pip install tinycss

# Open a demo file in an interactive view, using a local stylesheet
python pstastic.py examples/met1.xml default.nexss

# Render the styled tree file to an output file (png, pdf, svg)
python pstastic.py -o met1.png examples/met1.xml default.nexss

ETE gotchas and limitations

Not surprisingly, ETE doesn't support all of the styles and manipulations we would like.

tree {tip-orientation: left;}
tree.upward {tip-orientation: top;}

We apparently can't rotate trees cleanly in ETE. That is, the entire diagram is rotated, so labels appear sideways or upside-down. There's no provision for legibility or spacing, so this is effectively useless.

figure {
    background-color: white;
    width: 500px;
    height: 500px;
}

Sadly, None of these seem to be available through ETE's TreeStyle. It seems to reckon width and height based on the tree and scale.

Font names can't be "chained" for ETE. If you ask for this:

figure {
    background-color: white;
    font: 12pt "Helvetica",serif;
}

... all text will appear as the generic serif font, ignoring "Helvetica". The interpreter will instead be optimistic and apply the first (preferred) font name found.

Dimensions can't be expressed as percentages. If you ask for this, it will be ignored:

node[nexss:bootstrap>=0.91][nexss:bootstrap<=1.0] {
    font-size: 200%;
}

Use simple numbers instead, or px (but the units will be ignored):

node[nexss:bootstrap>=0.91][nexss:bootstrap<=1.0] {
    font-size: 30px;
}