Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

zachcp/archaeopteryx-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

archaeopteryx

The goal of archaeopteryx is to wrap the wonderful archaeopteryx.js library and make it accessible as an htmlwidget. Currently the basics work but I will be exploring changes to the API to try to make it work with R's pipe-based workflow.

Install

require(devtools)
devtools::install_github("zachcp/archaeopteryx-js")

Mini Roadmap

A few thoughts on how to improve this code (no guarantees):

  • To be able to get all of the control-elements, we will need to specify the DOM elements.
  • If we want to have multiple trees on an RMD page, the DOM elements need to be labelled in the RMB code using htmlwidget tags.
  • To do this is not-trivial since the code names are hardcoded in the archeompertyx.js code and at first look they do not seem to be replaces usign the options or settings features that allow you to customize the chart.
  • provide access to some reasonably complete set of options that can be passed to users.
  • right now newick strings are passed/parsed. Can a direct JSON blob be transferred in order to save the encode/decode step? This would also allow us to adorn information on each node.
  • be able to specify per-node attributes - which measn being able to pass in the information and using an API to modify the nodes.

Simple Usage.

## basic example code
library(archaeopteryx)
library(ape)
library(data.table)
library(Biostrings)

tree <- ape::read.tree(text="(mammal,(turtle,rayfinfish,(frog,salamander)));")
dna1 <- DNAStringSet(c("AAA","CCC","TTT","TTG","GTG"))
names(dna1) <- c("mammal", "turtle", "rayfinfish", "frog", "salamander")
phyJ <- create_phyloJ(phylo = tree, seqs = dna1)
phyJ <- add_sequences(phyJ)

archaeopteryx(phyJ)

Color SubClades

t1   <- ape::read.tree(text="(mammal,(turtle,rayfinfish,(frog,salamander)));")
dt   <- data.table(nodes=c("mammal","turtle","rayfinfish","frog","salamander"), 
                   size=c(1,2,3,4,5),
                   scale = c("a","b","c","d","d"))

red      <- J("java.awt.Color")$RED
phyJ     <- create_phyloJ(phylo=t1, annotation=dt)
mrca     <- get_MRCA(phyJ, tips=c("frog", "turtle"))
set_clade_color(phyJ, mrca, red)
archaeopteryx(phyJ)

Color Multiple SubClades

data(bird.families)
phyJ <- create_phyloJ(bird.families)
mrca1 <- get_MRCA(phyJ, c("Pardalotidae", "Centropidae"))
mrca2 <- get_MRCA(phyJ, c("Laridae", "Thinocoridae"))
red     <- J("java.awt.Color")$RED
blue    <- J("java.awt.Color")$BLUE
set_clade_color(phyJ, mrca1, red)
set_clade_color(phyJ, mrca2, blue)
archaeopteryx(phyJ)
annotdt <- data.table(nodes=bird.families$tip.label)
annotdt[, alph := .(substr(nodes,start = 1, stop=1))]
annotdt
phyJ <- create_phyloJ(bird.families, annotation = annotdt)
archaeopteryx(phyJ)

Releases

No releases published

Packages

No packages published

Languages