Comments (6)
The ouchtree
format is designed for internal use and not with a view to outside examination. That is, it is designed solely to make the internal ouch algorithms efficient. My advice would be to convert an ouchtree
into a data frame using as.data.frame()
and then to perform analysis on that.
The resulting data frame is pretty self-explanatory. Each node (internal or terminal) gets a line. That line contains the following information: the name of the node, the name of its immediate ancestor, its time (the positive direction being the future), and an optional label.
from ouch.
Aloha @soungalo As Aaron says ouchtree does not have accessor functions for returning descendants, etc. But if you want to see the internal components, you can use the attributes
function:
require(ouch)
x <- with(
bimac,
ouchtree(nodes=node,times=time/max(time),ancestors=ancestor,labels=species)
)
attributes(x)
attributes(x)$nterm
and access the elements by name (or other standard methods) on the return object of attributes().
However, there are other packages that have treewalking functions such as tidytree
and ape
. Lately Iʻve been using tidytree
(to work with the treedata object) and treeio
(to read in the phylogenetic tree in many formats into treedata), which has functions for ancestors, descendants, MRCA, etc. https://yulab-smu.top/treedata-book/chapter2.html#accesor-tidytree
Marguerite
from ouch.
I an not sure what youʻre doing, but if you want to get it your tree back into ouchtree
after editing it, you can get it into phylo
format and then use ape2ouch()
require(treeio)
require(tidytree)
require(ouch)
td_tree <- read.newick("mytree.tree") # or read.iqtree, read.nexus, read.beast, etc.
# ... some tree manipulations ...
phylo_tree <- td_tree %>% as.phylo
ouch_tree <- ape2ouch(phylo_tree)
from ouch.
Thank you both!
@kingaa - for some reason I couldn't convert the ouch tree to a data frame:
> as.data.frame(otree)
Error in as.data.frame.default(otree): cannot coerce class ‘structure("ouchtree", package = "ouch")’ to a data.frame
Traceback:
1. as.data.frame(otree)
2. as.data.frame.default(otree)
3. stop(gettextf("cannot coerce class %s to a data.frame", sQuote(deparse(class(x))[1L])),
. domain = NA)
I should have probably mentioned that the ouch tree was created using the convertTreeData function from SURFACE, so there might be something weird with the object I'm working with. In any case, it sounds like the easy way would be to go back to the original tree (phylo class) and work with it.
from ouch.
from ouch.
How about as(otree,"data.frame")
?
from ouch.
Related Issues (7)
- Problem with plot? or ape2ouch? HOT 13
- Suggestions for plotting options HOT 3
- Palette specification HOT 8
- Long labels HOT 5
- Label Lengths and Margins HOT 20
- example for plot 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 ouch.