arklumpus / TreeViewer

Cross-platform software to draw phylogenetic trees
GNU Affero General Public License v3.0
183 stars 8 forks source link

Plotting node states coded by more than one character #14

Closed Chloisf closed 1 year ago

Chloisf commented 1 year ago

Hello!

I have been using TreeViewer to plot data on my trees and I have found it very convenient and could create nice visualizations. However I am running into some issues with my new tree. I wish to plot data about hosts of some symbionts I am studying on the tips of my phylogeny. However, it seems that TreeViewer only accounts for the first character in the column of my attribute. Example, I would have the following hosts:

Haliclona Hyrtrios Petrosia

TreeViewer would display two colors, one for "H" (the two hosts starting by H) and one for "P". I have thought about assigning a single letter for each of my host but I have more hosts than letters in the alphabet. I have also tried with number but it is the same, eventually TreeViewer would read "2", "21", "29" as the same thing.

I am wondering how to circumvent this! Thank you for your time.

arklumpus commented 1 year ago

Hi! Thanks for using TreeViewer!

It should be relatively easy to achieve what you are trying to do. Instead of using just the name of the host (e.g., Haliclona), you should use something like {Haliclona:1}. For example, your attachment file may look something like this:

Strain1    {Haliclona:1}
Strain2    {Hyrtios:1}
Strain3    {Petrosia:1}
Strain4    {Haliclona:1}
...

Incidentally, you can use this kind of syntax also to assign multiple states to a single tip - e.g., if you have a strain that can establish symbiotic relationships both with Haliclona and Hyrtios, you can use {Haliclona:1,Hyrtios:1}. This will cause the node state on the tree to be coloured with the colours for both states (you can get different styles by playing with the settings in the Appearance section):

image

You can also change the numbers to assign a different weight to one state - e.g., {Haliclona:1,Hyrtios:2} will give the Hyrtios state twice as much weight as Haliclona:

image

I hope this makes sense, let me know if you have any other questions!

Chloisf commented 1 year ago

Hello!!

Thank you for your nice explanation. I have tried it with the syntax that you recommend and it is now working the way I wanted! Thanks also for the additional tip on how to plot several states with different weights, that seems very useful! Thank you so much!

arklumpus commented 1 year ago

Great, glad to hear it helped!

I'm closing this, feel free to reopen (or to open a new issue) if you still have problems!