tskit
tskit copied to clipboard
Helpful viz labels for newbies using metadata
I'm just looking at the viz tutorial. It strikes me that, now we have capable metadata (thanks @benjeffery !) it would be much more user friendly when creating an SVG of the tree sequence to look there for node and mutation labels if possible, rather than defaulting to the node numbers and mutation numbers (which are baffling for beginners, and can change on table re-sorting & simplification). One problem with this is where to look: it would require establishing some rough convention, for instance, looking for node.metadata.name. I would imagine something like the following:
Tree.draw_svg(self, ..., node_label_metadata_src="name"):
...
for n in self.nodes():
node_labels[n] = str(getattr(tree.tree_sequence.node(n).metadata, node_label_metadata_src, n))
It's sort-of trivial, as the user could just pass node_labels=[n.metadata.name for n in ts.nodes()] to the draw_svg function. But beginners might find this quite daunting, I think (even if it is documented)?
OTOH, establishing a convention like this (even if it is just for viz) is not something to be taken lightly, so I imagine this is a medium-term issue.
It's a good idea, but it'll take a while to sort out the details (and we have a lot of stuff that needs to be finished now).
Yep, makes sense to do after https://github.com/tskit-dev/tskit/issues/1051