genetics-statistics/purescript-genetics-browser

Name: purescript-genetics-browser

Owner: genetics-statistics

Description: Purescript-based genome and genetics browser

Forked from: chfi/purescript-genetics-browser

Created: 2017-08-06 10:58:40.0

Updated: 2017-08-06 10:58:41.0

Pushed: 2017-08-04 13:01:53.0

Homepage: null

Size: 196

Language: PureScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Purescript Genetics Browser

Usage

Make sure you have Purescript installed globally, e.g. using NPM:

install -g purescript
install

Install dependencies

run deps

Build a bundle for the renderer you want, like this:

build pgb.js

This compiles a bundle to the file “pgb.js”, which can be used by including it in a HTML page, which exposes the main Halogen container at PS. Also make sure to include the Biodalliance scripts if you are using it:

ipt language="javascript" src="./pgb.js"></script>
ipt language="javascript" src="./dalliance-all.js"></script>

The browser requires a configuration to be run, in the form of a JS object. In the PS code it is defined as a newtype record:

ype BrowserConfig = BrowserConfig { wrapRenderer :: RenderWrapper
                                  , browser :: BrowserConstructor
                                  , tracks :: TracksMap
                                  }

wrapRenderer and browser are helper functions for initializing a Biodalliance browser, and should always be set to WrappedRenderer.wrapRenderer and Browser respectively, which are exported from dalliance-all.js. tracks is a map of arrays of track configurations, with BD tracks under the BDTrack key, and Cy.js graphs under the CyGraph key (not yet implemented).

This is a basic configuration example, with two BD tracks. The last line runs the browser with the config:

ipt language="javascript">
r sources = [
  {
      name: 'Genome',
      twoBitURI: 'http://www.biodalliance.org/datasets/GRCm38/mm10.2bit',
      desc: 'Mouse reference genome build GRCm38',
      tier_type: 'sequence',
      provides_entrypoints: true
  },
  {
      name: 'QTL',
      tier_type: 'qtl',
      renderer: "qtlRenderer",
      uri: 'http://test-gn2.genenetwork.org/api_pre1/qtl/lod2.csv'
  }


r config = { wrapRenderer: WrappedRenderer.wrapRenderer,
            browser: Browser,
            tracks: {BDTrack: sources}


.main(config)();
ript>

Placing the above in an HTML file containing a div with ID “psgbHolder” should get you a basic browser. A full example can be found in example.html in this repo – make sure to place the compiled BD files in the right place before running it.

Renderers

A Renderer needs to implement one single function: glyphifyFeatures:

 View = { viewStart :: Number, scale :: Number }

hifyFeatures :: forall r eff. View -> Array (Feature r) -> Array (Glyph r eff)

Look at Biodalliance.Renderer.GWAS for an example.

The coordinate system used is relative and normalized to features, horizontally, and the canvas, vertically.

Tests

Visual tests of the SVG and Canvas renderers can be found in Test.Main. To run them, first compile the test module:

 build --main Test.Main --to ./index.js

Then open index.html in a web browser.

Unit tests and QuickCheck tests can be run with

 test

run test

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.