Skip to content

Instantly share code, notes, and snippets.

View spond's full-sized avatar

Sergei Pond spond

View GitHub Profile
@spond
spond / README.md
Last active November 22, 2023 09:52
phylotree.js "Hello World"

The simplest example of using phylotree.js

Create a phylotree.js object from a Newick tree string, and display it in an SVG element using default settings and styles. Because the default tree view supports clickable nodes, it is necessary to include jQuery and Bootstrap. It is always necessary to include d3, and phylotree.js script and styles (unless overridden by the user).

Click on internal nodes to bring up menus that allow you to collapse/select them.

{
"analysis":{
"authors":"Sergei L Kosakovsky Pond, Ben Murrell, Steven Weaver and Temple iGEM / UCSD viral evolution group",
"citation":"Less Is More: An Adaptive Branch-Site Random Effects Model for Efficient Detection of Episodic Diversifying Selection (2015). Mol Biol Evol 32 (5): 1342-1353. v2.2 adds support for multiple-hit models",
"contact":"spond@temple.edu",
"info":"aBSREL (Adaptive branch-site random effects likelihood)\n uses an adaptive random effects branch-site model framework\n to test whether each branch has evolved under positive selection,\n using a procedure which infers an optimal number of rate categories per branch.",
"requirements":"in-frame codon alignment and a phylogenetic tree",
"version":"2.2"
},
"branch attributes":{
@spond
spond / README.md
Last active August 13, 2018 10:55
Root-to-tip for intra-host HIV-1 data

Root-to-tip regression for intrahost HIV-1 phylogenies.

In this example, we read in trees with branch lengths (FastTree2), based on haplotypes and counts reported in Lorenzo-Redondo et al, construct root-to-tip distances for time-stamped tips, and regress those on time to obtain crude evolutionary rate estimates.

The initial rooting of the tree is obtained by considering all time-point 0 sequences and selecting one that maximizes R2 (regardless of the slope). The user can perform arbitrary rerooting and see what the effect on the regression slope is.

Further, 1000 simulated perturbation of haplotype counts are considered for a given rooting: the estimated frequency of each haplotype (encoded in the tip name) is multiplied by a random number from [0.05-10] distributed uniformly. The proportion of perturbations with positive inferred regression slopes is shown on the chart.

@spond
spond / README.md
Last active April 17, 2018 02:02
Annotated phylotree.js

A hackish example for annotating trees

This example uses tree.style_nodes to append colored rectangles to the node names as annotations. It requires some less than pretty spacing calculations in the handler, but both radial and rectangular layouts are supported.

This is in reference to veg/phylotree.js#64

@spond
spond / README.md
Last active February 15, 2018 19:21
clone-comaprtment-view

Within-host HIV tree.

This is an example which parses leaf names for meta information, including compartment, sample date, and copy number, and then annotates the tree accordingly. This example demonstrates how to use styling callbacks, e.g. style_nodes, and node_span.

The example also uses Bootstrap to allow interactive tree input via a model dialog.

More documentation forthcoming.

@spond
spond / README.md
Last active June 8, 2017 16:23
A JavaScript simulation of within host HIV dynamics

A JavaScript simulation of within host HIV dynamics

This code is based off a Python script kindly provided by Daniel Rosenbloom.

To INSTALL and RUN you need to have node.js and npm on your system

INSTALL and RUN

$git clone https://gist.github.com/spond/417b66f99731142268bacd957b752b09 HIV-sim
@spond
spond / README.md
Last active May 3, 2017 20:27
Vanilla tree

Non-interactive tree using phylotree.js

This is an example of using phylotree.js settings to create a tree which is suitable for a static display: no clickable nodes, nothing is selectable, fixed sizes in both dimensions.

The Newick string is loaded from a file using an asynchronous d3.text call.

@spond
spond / README.md
Last active May 18, 2016 18:48
How to add custom menu items to phylotree.js

How to add custom context menu items to tree nodes

This is accomplished via a call to d3_add_custom_menu which adds a menu to a specific node with callback defining

  1. What text is displayed (based on the node object and associated data)
  2. What happens on click (pass nodes and other data through transitive closure, because standard d3 .on handlers will be called on the menu item, not the node object).
  3. When the menu item is shown (a boolean callback based on the node object and associated data)
@spond
spond / README.md
Last active March 30, 2016 20:45
MEME vs MEME-internal [table]

Compare the results of MEME and MEME-internal on the same dataset

The table shows any site which was found significant (p ≤ 0.05) by either version of MEME.

@spond
spond / README.md
Last active March 30, 2016 20:42
MEME vs MEME-internal [chart]

Compare the results of MEME and MEME-internal on the same dataset

The two charts show mean ω (internal branches only, for MEME-internal, and the entire tree for MEME) over sites. Sites with evidence for episodic diversifying selection are shown as circles along the x-axis.