Figtree - Make branches the same colour as their tip labels
1
3
Entering edit mode
6.3 years ago
wl284 ▴ 100

I have a tree with more than 1000 sequences. I want to colour branches based on a string in the tip labels.

For example, all the branches leading to tip labels that have the word 'bacteria' in, I want to label blue, and those with the word 'archaea' I want to label red.

It is straight forward to do this for the tip labels themselves, just by using ctrl + f, and searching for your string of interest, then selecting a colour, but it seems like it is not possible to also colour the branches. Does anybody know a straightforward way of doing this, ideally without needing to write a script?

Cheers!

phylogeny tree figtree • 15k views
ADD COMMENT
1
Entering edit mode

The easiest way to manipulate the tip labels, branch labels and colours is to use an annotation file in FigTree.

ADD REPLY
0
Entering edit mode

OK, cool, could you maybe expand on this a bit, perhaps explain how I would do this for the example in my question?

ADD REPLY
2
Entering edit mode

The annotations file is a simple tab-delimited file. The first row should have the annotation names and the first column the taxon names. So:

taxa attrib1 attrib2

Tip1 1.0 1.0

Tip2 2.0 2.0

You can have an annotation file with all taxa and corresponding category you want to use for colouring the tips and branches. This file can be imported into FigTree from File -> Import Annotations... option. If annotations are imported successfully, you can colour the branches and/or tips according to an attribute in the file by selecting the appropriate attribute in the pull-down menu, e.g. Node Labels -> Colour by: Category.

Ref: https://groups.google.com/forum/#!topic/figtree-discuss/UR2rTvtIzcw

ADD REPLY
0
Entering edit mode

Also, it's the branches themselves that I would like to colour, not the branch labels. Cheers

ADD REPLY
1
Entering edit mode

There are lots of results on google and on the github repo/google group for using annotation files. They're just tab delimited files with a list of attributes for each taxa.

ADD REPLY
0
Entering edit mode

OK thanks, I'll take a look

ADD REPLY
1
Entering edit mode

Just consider that you will also need to expend time creating an annotation file for every one of your trees too, so unless you're prepared to script something to write your annotation files for you as well, you may not necessarily see much in the way of a time or effort saving.

Though to be clear, I'm not advocating against automating it, I think that's a good idea generally, rather than relying on GUI tools - but you will have to get your hands dirty writing something that at least resembles some code (even if it's - God forbid - an Excel macro).

ADD REPLY
2
Entering edit mode
6.3 years ago
Joe 21k

In FigTree you can just click on the nodes or branches of interest and colour them accordingly using the colour wheel.

If you change your selection mode to Clade, all child nodes and branches will be selected at the same time, so you only need to select the common ancestor for any set of branches you want to colour.

I don't believe there is any way to do this 'automatically' based on a given string, but it is fairly trivial to do by hand.

Example:

  1. Change selection mode to Clade (Blue box)

  2. Select a node/branch set (black box)

  3. Apply a colour (red box)

enter image description here

ADD COMMENT
1
Entering edit mode

Thanks for taking the time to reply. I am aware of how to colour branches using the process you describe, however I have more than 1000 sequences in my tree, and colouring each branch manually would take a very long time and would also need repeating each time I make a new version of the tree, so unfortunately this just isn't practical.

ADD REPLY
2
Entering edit mode

more than 1000 sequences

Should have mentioned that in your post, so people have all the information they need and don't waste time addressing the wrong problem. Please edit your post and mention that, and also remove the "someone is prepared to write it for me" - it's not funny. If you have a well defined task and a proposed hourly rate, mention that, maybe someone will be willing to do it at your price point.

ADD REPLY
0
Entering edit mode

I did state that there were a large number of sequences in my original post, which I thought was sufficient, but have now clarified this to state more than 1000. Apologies for wasting your time jrj.healey. Also, I didn’t mean to cause offense regarding the scripting. All I meant was that I’m not very good at writing code, so was looking for a method that didn’t involve it. I wasn’t seriously expecting someone to write something for me, hence the wink. As you can see from my limited number of posts, I’m not the most experienced of the participants in this community and was unaware that my etiquette was so vitriolic. Thanks for making me feel so welcome here though.

ADD REPLY
1
Entering edit mode

Apologies that I sounded rude, that was not my intention. As jrj.healey mentions, we get a lot of users who want us to do their work for them, and I wanted to discourage you in case you were headed in that direction. Tone does not carry well over text based communication, and your wink-wink statement sounded like a subtle ask for someone to script it for you.

ADD REPLY
0
Entering edit mode

OK, no problem, I'll stick to writing my posts in a more formal style/tone in future to avoid misinterpretation.

ADD REPLY
0
Entering edit mode

Thank you, yes, that should work to unambiguously convey intentions.

ADD REPLY
0
Entering edit mode

No problem, it took very little of my time (and to be honest its a pleasant distraction from the thesis I'm supposed to be writing ;) )

It was obviously in jest, but we do get a lot of questions on the forum which amount to: "I can't script, please do my work for me" so we have to discourage those. Ram meant no offence - just one of the problems of conveying meaning on the internet!

The short answer to your question is either what I posted above, or that you will have to get your hands dirty with a little code most likely, even if that is just to write your annotation files for you.

Just another note for the future, it would be worth posting a minimal example of the tree you're working with (we don't need all 1000 taxa). Just so we can see the breadth of the data you're working with and the strings that would be available to manipulate.

ADD REPLY
1
Entering edit mode

Without a code-based solution you might struggle a little. Typically there's a bit of a trade off in GUI apps for automatability/versatility in favour of user friendliness.

I assumed with classifications as broad as "bacteria" you probably wouldn't be looking for much granularity to your colourations, in which case it would be simple just to select a dozen or so common ancestor nodes and colour it all.

ADD REPLY
1
Entering edit mode

Thanks for the information, sorry the information I provided was unclear. I was trying to keep it as simple as I could to try not to confuse people but seems like it had the opposite effect. I'll try to look into code-based solutions as you suggest.

ADD REPLY

Login before adding your answer.

Traffic: 1550 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6