Question: Figtree - Make branches the same colour as their tip labels
3
gravatar for wl284
2.6 years ago by
wl28460
UK
wl28460 wrote:

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!

figtree tree phylogeny • 5.2k views
ADD COMMENTlink modified 2.6 years ago • written 2.6 years ago by wl28460
1

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

ADD REPLYlink written 2.6 years ago by Sej Modha4.8k

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

ADD REPLYlink written 2.6 years ago by wl28460
2

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 REPLYlink modified 2.6 years ago • written 2.6 years ago by Sej Modha4.8k

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

ADD REPLYlink written 2.6 years ago by wl28460
1

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 REPLYlink written 2.6 years ago by Joe19k

OK thanks, I'll take a look

ADD REPLYlink written 2.6 years ago by wl28460
1

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 REPLYlink modified 2.6 years ago • written 2.6 years ago by Joe19k
2
gravatar for Joe
2.6 years ago by
Joe19k
United Kingdom
Joe19k wrote:

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 COMMENTlink modified 2.6 years ago • written 2.6 years ago by Joe19k

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 REPLYlink written 2.6 years ago by wl28460
2

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 REPLYlink modified 2.6 years ago • written 2.6 years ago by Ram32k

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 REPLYlink written 2.6 years ago by wl28460
1

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 REPLYlink written 2.6 years ago by Ram32k

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

ADD REPLYlink written 2.6 years ago by wl28460

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

ADD REPLYlink written 2.6 years ago by Ram32k

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 REPLYlink written 2.6 years ago by Joe19k
1

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 REPLYlink written 2.6 years ago by Joe19k
1

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 REPLYlink written 2.6 years ago by wl28460
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1368 users visited in the last hour
_