arklumpus / TreeViewer

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

Is it possible to add circular clade highlights? #7

Closed carlosmag closed 2 years ago

carlosmag commented 2 years ago

Hello! Is it possible to add circular clade highlights (example: ggtree R package)?

P.S. Unlike other tools, TreeViewer's search and navigation/zoom functionalities are fast!

arklumpus commented 2 years ago

Hi! If I understand what you mean, I think this is similar to what @Dichromatism was asking in #5.

I have now added three new modules to the repository that can be used to achieve this; you can install them by going to Modules>Module repository and then locating them in the respective tabs (you should also get a prompt to do so the next time you open TreeViewer after midnight):

With these modules, you can create something like this:

Let me know if these work for you!

carlosmag commented 2 years ago

Thanks a lot for your effort! I am amazed on how much you could do in a short period of time.

Your images look great! However, I couldn't reproduce the new features in my tree.

treeviewer_nodehighlight treeviewer_afterplotactionsnodehighlight

After selecting a node and clicking 'Add plot action -> Highlight node', it produces a very big circle... Unfortunately, there's no CTRL+Z functionality... Am I doing something wrong here?

P.S. I restarted the program after installing the modules...

arklumpus commented 2 years ago

If you want to highlight the selected node, you need to use the "Highlight" button in the "Selection actions" panel.

Alternatively, after adding the highlight module like you did, you need to expand its options and change the "Node" specifying it as the LCA of some taxa. This is because, by adding the module in this way, it doesn't know which node you selected.

carlosmag commented 2 years ago

I found it!, thanks!

Is it possible to change highlighting color without resorting to code?

arklumpus commented 2 years ago

Yes, sure! If you expand the options for this module, you can just change the "Fill colour":

image

You can also "play" with the other options to see how they affect the result - e.g. the stroke is set to a transparent colour by default, but if you change the "Stroke colour" (increasing the alpha value) the outline of the node will be drawn as well.

carlosmag commented 2 years ago

Thanks a lot! Need to play more with these options and the rest of the tool!

arklumpus commented 2 years ago

Happy to help, have fun! 😁

carlosmag commented 2 years ago

Is it possible to colour branch lines? Something like this:

branchcolortree

I guess it might work better for me than increasing transparency in node highlights...

arklumpus commented 2 years ago

If you want the node highlight to appear behind the tree, that is easy: you just have to open the modules panel and drag the "Highlight node" module above all the rest.

If you want to change the colour of a part of the tree, you can do it like this:

Here is a clip showing how to do both these things:

https://user-images.githubusercontent.com/32712606/142518052-aea4b2a0-3c74-4bae-a5d2-79b237848431.mp4

I would recommend having a look at the tutorials in the Wiki: for example, this section of the tutorial to draw a sequence alignment with the tree shows how to use a different colour for different parts of the tree.

carlosmag commented 2 years ago

It worked! I guess I am understanding better the mechanics of the program...

I proceeded to the Group labels module, using the tutorial you provided (which is great!, by the way). However, the labels appear only in the root of the tree and not as in the example shown in the help of the module for circular trees.

grouplabels_treeviewer

arklumpus commented 2 years ago

If you open the options of the Group labels module, there is a setting called Distance: this determines the distance of the labels from the root node. You need to increase this value to move the labels to the outside of the tree (try different values and see where the labels move).

carlosmag commented 2 years ago

Thanks, it worked!

In the tree I am working it, there are some branches placed a bit far comparatively to the others. Only way to have labels for these groups is to massively increase Distance, which will lead to lots of empty space on the nodes closer to the root...

grouplabels_distance

Is there a way to place labels outside each specified group, or do I need to set branch lengths to none?

arklumpus commented 2 years ago

You can enable two (or more) separate instances of the Group labels module and use a different distance for each. You would then set the label values in different attributes, so that each module only shows some labels (you can change the attribute that is shown by each module by changing the Attribute parameter).

Like this:

https://user-images.githubusercontent.com/32712606/142661407-8097ca43-02f4-4cc3-aa52-833197d69a17.mp4

carlosmag commented 2 years ago

Is it possible to add newline characters to node attributes? I've tried some combinations but it didn't work... Alternatively, is it possible to rotate text? This is because I have few space to write labels in some highlights, such as this:

newlinecharfortree

P.S. Annotation experience has been great so far!

arklumpus commented 2 years ago

I'm glad to hear you've had success with the program!

Unfortunately, you can't have newlines in the labels. You also can't rotate the text in the Group labels module, but you can rotate it in the Labels module. To achieve something similar to the group labels effect, you should set the "Anchor" to Origin and the "Branch reference" to Circular; then by increasing the X coordinate of the Position you can move the label outside the tree, like this:

https://user-images.githubusercontent.com/32712606/142785741-87ad2152-e986-4365-9990-d3813073add4.mp4

Alternatively, you can use the Text module (this lets you draw a single string of text that you specify in the module parameters rather than as an attribute on the tree).

The Legend module does support newlines (it draws Markdown code), but it's probably overkill.

carlosmag commented 2 years ago

Labels module tip did the trick!

Thank you for your amazing support throughout this process! I hope to cite TreeViewer in a paper in the coming months. Fingers crossed!

arklumpus commented 2 years ago

Great, good luck!