Comments (8)
@gkarthik thanks for taking care of this! :)
1., 2., and 3. have been addressed well by Karthik. Let us know if you need code references for any of these.
4. The root of the subtree being the parent of the node you called subtree
on is not a bug, but an intentional choice for producing the "exploded tree" plots with some branch length at its base. Admittedly, this is not ideal and this should ideally be an option (something like stem=True
).
treeHeight
being incorrect for the subtree is more worrying though, because the subtree
function should only deep copy the branches that comprise the subtree and assign them to a completely new tree
object which without a traversal should have treeHeight==0
by default. I can take a look at the data/code if neither is sensitive.
from baltic.
Hey!
plotPoints()
can be used to draw the posterior probability node markers. The defaulttarget
function only filters the leaf_nodes.
You can customize and pass the following lambda functions to plotPoints(),
target=lambda k:k.branchType!='leaf'
size_function=lambda k: 50 if k.traits['posterior']>=0.5 else 10
colour_function=lambda k: "#000000" if k.traits['posterior']>=0.5 else "#ECECEC"
- Could you add the exact function call you used for
subtree()
?
from baltic.
Seems like the parent of the mrca is the root of the entire tree?
A quick fix might be to pass a target
lambda function excluding the root to plotTree
.
target=lambda k: k != subtree.root
.
@evogytis might have better suggestions (accounting for time zone differences 😄).
from baltic.
- For the violin plots, I usually pull all the trees from the BEAST trees file and extract the height of the mrca. Following this, its a simple histogram that is shown in that figure. I have some ad hoc scripts lying around for this will see if I can dig them up.
- Haven't tested this much but this code should work to create tick labels at the first of every month of 2020 (01 Jan, 01 Feb .. ). You can modify it to fit the time interval you're considering.
import datetime as dt
new_ticks = [bt.decimalDate("2020-{}-01".format(i)) for i in range(1,13)]
new_tick_labels = ["01 "+dt.datetime.strptime("2020-{}-01".format(i), "%Y-%m-%d").strftime("%b") for i in range(1,13)]
ax.set_xticks(new_ticks)
ax.set_xticklabels(new_tick_labels)
from baltic.
Hey @gkarthik, thank you for your quick response.
For 1, your suggestion solved the issue! ✨ Thank you.
For 4, I've been defining the clade of interest from its ancestor
, based a set of 42 target_tips
.
keep_tips = [k.numName for k in treeFile.Objects if k.branchType == 'leaf' and k.name in target_tips]
ancestor = treeFile.commonAncestor(treeFile.getExternal(lambda k: k.numName in keep_tips))
subtree = treeFile.subtree(k=ancestor)
print(subtree.treeStats())
gives me this:
Tree height: 48.907069
Tree length: 90.130334
strictly bifurcating tree
annotations present
Numbers of objects in tree: 83 (41 nodes and 42 leaves)
and print(subtree.root.absoluteTime)
shows 2010.2653139215834
, which is actually the age of the parent node of the ancestor
, not its expected tMRCA, which is 2012.58, height=6.87 (see long root and MRCA in this newly plotted subtree, with the posterior probabilities markers).
Any idea of what is wrong? 6.87 as height is the expected result, but baltic is using the original tree height (48.907069), despite ancestor
being set as as the starting node of the subtree. It seems commonAncestor
is returning the ancestor branch, not node.
from baltic.
The root of the tree is set to the mrca's parent. Could you confirm that len(subtree.root.children)
is 1 and subtree.root.children[0].absoluteTime
is 2012.58
?
from baltic.
Correct:
len(subtree.root.children)
= 1
subtree.root.children[0].absoluteTime
= 2012.58
from baltic.
Thank you, @gkarthik.
I'm handling that using a pre-pruned tree in the meantime.
Do you have any suggestions concerning the points 2 (tMRCA violin plots) and 3 (Time ticks in months)?
from baltic.
Related Issues (20)
- Set up continuous integration HOT 1
- Add magic methods to baltic classes
- Set up sphinx for auto-documentation of classes and functions from docstrings
- Booleans as values of traits dict incorrectly output to string. HOT 1
- loadJSON translation needs to be accessing `node_attrs` within traits instead of traits directly
- loadJSON needs to be updated for the new nextstrain json format HOT 2
- Export back to NextStrain JSON HOT 3
- AttributeError: 'NoneType' object has no attribute 'traverse_tree' HOT 2
- TypeError: unsupported operand type(s) for -: 'function' and 'int' HOT 2
- Add exports HOT 2
- No way of adding text to circular tree. HOT 2
- Unicode Errors
- Take singleton as a baltic tree object
- commonAncestor returns wrong node when MRCA is root of tree HOT 1
- Tree regex tricky to use HOT 1
- Ascending branch sort? HOT 4
- Typo in assertion that checks if new coordinates were computed by the drawTree function HOT 1
- Unable to extract assigned color, clade id, and leaf id into tsv/dataframe HOT 1
- How to plot a phylogeny in a different direction HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baltic.