GithubHelp home page GithubHelp logo

zachcp / archaeopteryx-js Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 6.23 MB

Html-Widget wrapper for archaeopteryx.js

Home Page: https://zachcp.github.io/archaeopteryx-js/

R 7.00% JavaScript 92.56% CSS 0.24% Makefile 0.21%
phylogenetics htmlwidgets archaeopteryx r

archaeopteryx-js's Introduction

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)

archaeopteryx-js's People

Contributors

zachcp avatar

Watchers

 avatar

archaeopteryx-js's Issues

look at issues with multiple trees on the same page

after providing the ability to add multiple htmlwidgets per page I was getting errors with the node visualizations. This is probably due to the way that nodes are drawn (d3.selectall() etc). Look into it and see if there is a reasonable workaround otherwise there may be a fundamental limit to the number of widgets we can add per page.

add sequences

associate sequences with nodes. may need to alter the phyloJ object to accommodate DNAStringSets

Be able to use multiple archaeopteryx widgets on the same page

Right now the control element DOM IDs are hardcore in the archaeopteryx.js. I do not know how to change it within html widgets. It may be that the only way is to move the dom ID for the control elements into the archaeopteryx instantiation function at which point it could be passed was a parameter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.