-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tree.draw_tikz() to output tex/tikz drawing code. #798
Conversation
Ping @gtsambos. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me @grahamgower, but I just had a quick scan.
fyi @grahamgower, I'm forking this now so I can play around with getting mutations in here |
Hi @grahamgower, I've created a PR against your fork (let me know if you have trouble with this). The additional code puts mutations on the plots, like this: So far the code assumes mutation times aren't known -- but the case when they are shouldn't be difficult either, will look into it later this weekend |
Thanks, that looks great! |
Codecov Report
@@ Coverage Diff @@
## main #798 +/- ##
==========================================
- Coverage 93.60% 87.22% -6.38%
==========================================
Files 27 24 -3
Lines 23035 19558 -3477
Branches 1079 3686 +2607
==========================================
- Hits 21561 17060 -4501
+ Misses 1440 1403 -37
- Partials 34 1095 +1061
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
very nice 👀 I'd like to get a handle on the TreeSequence-wide |
Yeah, adding the scaling and axes would be really useful. Just give me a moment, I've changed to use a |
Ok, have at it @gtsambos! Now we can do silly things like this: import msprime
ts = msprime.simulate(10, recombination_rate=1, mutation_rate=1, random_seed=1)
ts.draw_tikz(
"/tmp/s.tex",
tree_height_scale="rank",
standalone=True,
preamble="\\usetikzlibrary{3d, shapes.geometric}",
style="""%
every pic/.append style={canvas is zy plane at x},
mutationlabels/.append style = {
opacity=0,
},
mutations/.append style = {
star,
star point ratio=2.5,
},\
"""
) |
With bigger sample sizes (n=1000, with 19 trees) I get: |
The solution for large drawings is to compile with
|
I wouldn't be too worried about this -- I doubt people will be using |
Yeah, I'm 100% not worried about rendering large trees within tex. This is fundamentally for printed page output, so if it's too big to go on a printed page we don't care about it. |
@grahamgower does this need tests to be mergable? Or are there still open questions about the implementation? |
Probably tests and docs are the biggest things outstanding. And making sure the API is consistent enough with the other drawing functions would be a good idea. |
Rebased. I'll take another look though this in the coming week. |
This is really useful and a great addition, but I'm gone off the idea of incorporating it into tskit. Our experience with the SVG viz is that it quickly turns into a lot of code, and it's quite hard to test. In this case, we'd need to pull in a tex engine to CI and for all of our client side dependencies. Keeping consistency between the various viz APIs is a pain also. @benjeffery, I'm guessing you're in a similar mind? So, I suggest spinning it out into an independent project? |
I think this is probably the right thing to do, and that maybe even the svg code is hefty enough not be in tskit, but that is another discussion! |
Does this belong in https://github.com/tskit-dev/tsviz ? Perhaps we could move the PR over there and eventually merge it? |
Sounds good to me! |
Closing this as we decided to move it to tsviz - have opened tskit-dev/tsviz#9 so this PR code doesn't get lost. |
No description provided.