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

[request] Allow scatter plots to use log-log axis #202

Closed abought closed 4 years ago

abought commented 4 years ago

Request from the T2D Portal team:

For the phewas plot, we are now seeing cases where a log(log) plot would be useful on the y-axis Is it possible to add an option for a user to toggle between the current log(P) and a log(log(P))?

This would consist of a new axis scale layout directive (scaleLog). We should also investigate whether display_options supports the new directive, to allow for users to switch between the axis scale dynamically. Otherwise, external widgets would need to mutate the layout and re-render manually.

Configuration would be at the panel level; we'd need to give some thought to the interaction between stacked datalayers.

abought commented 4 years ago

Jason has indicated that he would be ok with a linear scale on the axis, which can be accomplished with existing code.

To make it easier to render this way (without modifying the data from the server), I've implemented a log10 template filter.

It may be used by modifying the default panel.y_axis.field section to look like the following:

    y_axis: {
        axis: 1,
        field: '{{namespace[assoc]}}log_pvalue|log10', // Bad field name. The api actually sends back -log10, so this really means "log10( -log10 (p))"
        // floor: 0,
        upper_buffer: 0.10,
        // min_extent: [0, 10],
    }

And adjusting the axes label to reflect the data: association_panel_layout.axes.y1.label = 'log(-log10 (p))';

Note that log(log) is not guaranteed to be positive! Negative values will result for any pvalue > 0.1. Setting min_extent and floor would have the effect of clipping out non-significant hits from the view- the example above is tweaked to show everything.

I tested on a regular association scatter plot to see the effect of various extreme values: Screen Shot 2020-08-04 at 12 57 23 PM

abought commented 4 years ago

Required transform functions and docs merged and delivered. Closing this ticket but let me know if further work is required here.