yatisht / usher

Ultrafast Sample Placement on Existing Trees
MIT License
121 stars 40 forks source link

ENH: Give internal nodes ids, so they can be labelled in Nextstrain URL #284

Closed corneliusroemer closed 1 year ago

corneliusroemer commented 1 year ago

In order to allow Nextstrain share links to indicate the node that one was on when generating the link, you need some sort of unique id for the branch you're on.

This is not too hard to generate: https://github.com/corneliusroemer/nextstrain-deploy/blob/main/deploy.py#L17-L25

If a tree has such an internal node label, when you share a tree, the viewer will automatically zoom into that node.

See, e.g. https://next.nextstrain.org/monkeypox/hmpxv1/2022-10-18?label=id:1c0795b0

Note the id:1c0795b0 in the URL

It'd be neat if Usher added such unique labels to Nextstrain trees for more reproducible view sharing.

jmcbroome commented 1 year ago

Perhaps we could simply use our preexisting internal node IDs for this? Generally these follow the format "node_XXX" where XXX is their position in a tree traversal. Is there a limit on the formatting for Auspice UUIDs, or would any arbitrary string work?

corneliusroemer commented 1 year ago

Great idea! You can call these anything you like, no constraints at all.

On Mon, Oct 24, 2022, 22:57 Jakob McBroome @.***> wrote:

Perhaps we could simply use our preexisting internal node IDs for this? Generally these follow the format "node_XXX" where XXX is their position in a tree traversal. Is there a limit on the formatting for Auspice UUIDs, or would any arbitrary string work?

— Reply to this email directly, view it on GitHub https://github.com/yatisht/usher/issues/284#issuecomment-1289607944, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF77AQMS7C5OD3C6LGXJOODWE3Z4DANCNFSM6AAAAAARLBSH4I . You are receiving this because you authored the thread.Message ID: @.***>

AngieHinrichs commented 1 year ago

I already add the internal node_# identifiers to the JSON for the "name" attribute of non-leaf nodes (probably following what I saw in the nextstrain/ncov JSON a couple years ago):

{ "name": "node_7278821", "branch_attrs": { "labels": { "nuc mutations": ...

So in addition to "name", now I should also add it as node["branch_attrs"]["labels"]["id"] so it will be like this?:

{ "name": "node_7278821", "branch_attrs": { "labels": { "id": "node_7278821", "nuc mutations": ...

okey doke. Having the ability to link to a particular node will be nice, it is frustrating when a node's mutations are homoplasic and reloading the URL with label=mutations results in an error about that.

corneliusroemer commented 1 year ago

Fabulous! Yes if you could add it as node["branch_attrs"]["labels"]["id"] that'd be amazing, then Auspice allows it to be stably linked to and zoomed into when sharing!

corneliusroemer commented 1 year ago

This works beautifully now, thanks @jmcbroome!

image

https://next.nextstrain.org/fetch/genome-test.gi.ucsc.edu/trash/ct/subtreeAuspice1_genome_test_26e5b_3b41d0.json?f_userOrOld=uploaded%20sample&label=id:node_9569558