Open mathidachuk opened 4 years ago
I do think a function for translating multiple types of files to hierplane ready data is important. Please take a look at data.tree
and let me know what you think. It's a very popular package for this type of data and we can take advantage. For example, being able to parse multiple file formats:
csv -> data.frame in table format (?read.csv) -> data.tree (?as.Node.data.frame) Newick -> ape phylo (?ape::read.tree) -> data.tree (?as.Node.phylo ) csv -> data.frame in network format (?read.csv) -> data.tree (c.f. ?FromDataFrameNetwork) yaml -> list of lists (?yaml::yaml.load) -> data.tree (?as.Node.list) json -> list of lists (e.g. ?jsonlite::fromJSON) -> data.tree (?as.Node.list)
If we have an hp_datatree
function, we can automatically take advantage of csv/newick/yaml/json all at once!
Regarding this comment:
attribute2 = NA # maybe attributes should be defaulted to two columns....
I was also thinking about this... attributes feels like it should just be a single parameter and the user passes n column names to it.
I played with data.tree a little bit when I was building the build_tree
and build_node
functions, but it was not doing what I needed it to do at all unfortunately. Maybe you will have better luck getting it to work for our purposes.
I thought as.Node.data.frame would work for converting spacyr to a list that we need for example, but it didn't work for me. I was probably doing something wrong.
Well we will still need build_tree/build_node since hp_dataframe calls those, and that's fine IMO. And spacyr just works, so I don't think we need to touch that. I am saying that we might need to consider removing hp_dataframe as an export and make it an internal function. The data.tree
package can just be something we make sure hierplane is compatible with, namely that a user can pass a data.tree object to hierplane and it's able to render.
Ok gotcha. I think it's a great idea to make sure we have a data.tree
compatible function. I have some reservations about removing hp_dataframe tho. See #39
Also reminder that hp_spacyr
also relies on the build_
functions. The build_
functions allows use to go from df --> hierarchical list structure.
I 100% agree which is why I don't think build functions should be touched, they just work. It's hp_dataframe
that I am on the fence about because of the work required.
Maybe we show users how to construct a dataframe from data.tree
and how to add link and node and attribute columns?? That can be an option. And then they can just use hp_dataframe????
So based on the org data I built the following function that converts the json data into a hierplane-compatible dataset. I think it maybe useful if say...someone wants to modify json tree data as a dataframe then convert it back to json + hierplane.
Let me know what you think about including it in the package.
p.s. tree.json = the org data