statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
156 stars 29 forks source link

Data Source Field Transformations #29

Closed MrFlick closed 8 years ago

MrFlick commented 8 years ago

This update allows transformations to be applied to fields returned from the API.

For example, on the demo page if you run

var q = new LocusZoom.Data.Requester(ds);
var state = {chr:10,start:114550452,end:114555452};
var dumpbody = function(x) {console.log(x.body)};

You can then either call

q.getData(state,["position","pvalue"]).then(dumpbody).done()

or

q.getData(state,["position","pvalue|neglog10"]).then(dumpbody).done()

Transformations are indicated by pipes (|) followed by a function name. Functions can be added to LocusZoom.KnowTransformations which is an object that maps strings to functions.

MrFlick commented 8 years ago

As I started to add in the test I realized a bit more refactoring would be needed. I've decided to add the testing as a separate PR. This PR is ready for review and merging.