|
| 1 | +## What is GWASViewer? |
| 2 | + |
| 3 | + |
| 4 | +GWASViewer is a Google Web Toolkit (GWT) widget for displaying interactive Manhattan plots. |
| 5 | +It is a composite of multiple different GWT widgets: |
| 6 | + 1. [dygraphs-gwt][0] as the actual Manhattan plot and statistic plots |
| 7 | + 2. [GeneViewer][1] as the gene annotation track |
| 8 | + 3. [LDViewer][2] as a LD triangle viewer |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## How do I use it? |
| 14 | + |
| 15 | +Following minimum steps are required: |
| 16 | + |
| 17 | +```JAVA |
| 18 | +// create a GeneDataSource for the `GeneViewer` to dynamically fetch genes |
| 19 | +final GeneDataSource geneDataSource = new GeneDataSource() { |
| 20 | + @Override |
| 21 | + public void fetchGenes(String chr, int start, int end, boolean getFeatures, FetchGenesCallback callback) { |
| 22 | + // fetch the genes for the provided region from the backend for example |
| 23 | + } |
| 24 | + @Override |
| 25 | + public void fetchGeneInfo(String name, FetchGeneInfoCallback callback) { |
| 26 | + // fetch the gene info/description for the specific gene name |
| 27 | + } |
| 28 | +}; |
| 29 | + |
| 30 | +// the default color of the Manhattan plot is blue and the marked regions are green |
| 31 | +GWASViewer viewer = new GWASViewer("Chr1",new String[]{"blue"},"green",geneDataSource); |
| 32 | + |
| 33 | +// draw the manhattan plot |
| 34 | +viewer.draw(dataTable, maxScore, fdrThreshold, chrLengths); |
| 35 | +``` |
| 36 | + |
| 37 | +### Load list of tracks and handle the track selection |
| 38 | +`GWASViewer` can display a list of tracks when the user opens the settings popup. |
| 39 | + The user can set this list by using the `setTracks` function: |
| 40 | + |
| 41 | +``` |
| 42 | +Tracks[] listOfTracks = // get from server for example |
| 43 | +viewer.setTracks(listOfTracks); |
| 44 | +``` |
| 45 | +When the user selects a track from the popup, an `SelectTrackEvent` event will be fired. The user can handle the event |
| 46 | +retrieve the data from the backend and then call `setTrackData` to display the track: |
| 47 | + |
| 48 | +``` |
| 49 | +viewer.addHandler(new SelectTrackEvent.Handler() { |
| 50 | + @Override |
| 51 | + public void onSelectTrack(SelectTrackEvent event) { |
| 52 | + DataTable dataTable = //get track data from backend for example |
| 53 | + viewer.setTrackData(event.getId(),event.isStacked(),dataTable); |
| 54 | + } |
| 55 | +},SelectTrackEvent.getType()); |
| 56 | +
|
| 57 | +The track data has to be provided as a [gwt-charts][3] DataTable object with 2 columns (position, and value). |
| 58 | +
|
| 59 | +### Display LD Triangle plot or LD colored values |
| 60 | +
|
| 61 | +To display the LD triangle plot use the `loadLDPlot` function and for coloring the Manhattan plots based on LD |
| 62 | +the user can use `showColoredLDValues`. For more information refer to the [LDViewer documentation][2]. |
| 63 | +
|
| 64 | +### Highlight region and select SNPs |
| 65 | + |
| 66 | +To highlight one or multiple regions, use the `addDisplayFeature` function and to clear it use `clearDisplayFeatures()`: |
| 67 | + |
| 68 | +``` |
| 69 | +viewer.addDisplayFeature(new DisplayFeature("AT4G00651.1", 271486, 271879, "red"), true); |
| 70 | +viewer.addDisplayFeature(new DisplayFeature("Some interesting region", 8753993, 9241760, "green"), true); |
| 71 | +``` |
| 72 | +
|
| 73 | +To select one or more SNPs use `setSelections` and to clear `clearSelections()`: |
| 74 | +``` |
| 75 | +selections.add(148); |
| 76 | +selections.add(1220); |
| 77 | +selections.add(2240); |
| 78 | +// false will redraw after SNPs are select. If it is set to true, use viewer.refresh() to update the plot |
| 79 | +viewer.setSelections(selections,false); |
| 80 | +``` |
| 81 | +### Uploading tracks and custom TrackUploadWidget |
| 82 | +
|
| 83 | +By default the `DefaultTrackUploadWidget` is displayed. It supports uploading to a backend or to the local storage. |
| 84 | +The upload url can be changed with `setDefaultTrackUploadUrl`. The file has to be a comma separated file that can be either |
| 85 | +provided by URL or by selecting it with the a file input. |
| 86 | +When the user uploads a track the `UploadTrackEvent` is fired. |
| 87 | +
|
| 88 | +To implement a custom upload widget, create a `Composite` that implements the `UploadTrackWidget` marker interface |
| 89 | +and use the `setUploadTrackWidget`. To disable the upload functionality call the function with `null`. |
| 90 | +
|
| 91 | +## Useful events: |
| 92 | +
|
| 93 | +See the sample app below for an example how to use those events |
| 94 | + |
| 95 | +| Event | When fired ? | Parameters | Component | |
| 96 | +|------ | ------------- |-----------| ------------| |
| 97 | +| ClickGeneEvent | When the user clicks on a gene in the gene annotation track | `Gene` instance | `GeneViewer`| |
| 98 | +| HighlightGeneEvent | When the user moves the mouse over a gene in the gene annotation track | `Gene` instance | `GeneViewer` | |
| 99 | +| UnhighlightGeneEvent | When the user moved out of a gene in the gene annotation track | - | `GeneViewer` | |
| 100 | +| ZoomChangeEvent | When the user changes the zoom level of the Manhattan plot | start and end | `GWASViewer` | |
| 101 | +| HighlightPointEvent | When the user highlights a point in the Manhattan plot | x, Point[], row, seriesName | `GWASViewer` | |
| 102 | +| ClickPointEvent | When the user clicks on a point in the Manhattan plot | x, Point[] | `GWASViewer` | |
| 103 | +| SelectTrackEvent | When the user selects a track from the settings popup | id | `GWASViewer` | |
| 104 | +| UploadTrackEvent | When the user uploads a custom track | - | `GWASViewer` | |
| 105 | +| DeleteTrackEvent | When the user deletes a custom track | id | `GWASViewer` | |
| 106 | +
|
| 107 | +
|
| 108 | +## How do I install it? |
| 109 | +
|
| 110 | +If you're using Maven, you can add the following to your `<dependencies>` |
| 111 | +section: |
| 112 | +
|
| 113 | +```xml |
| 114 | + <dependency> |
| 115 | + <groupId>com.github.timeu.gwtlibs.gwasviewer</groupId> |
| 116 | + <artifactId>gwasviewer</artifactId> |
| 117 | + <version>1.0.0</version> |
| 118 | + </dependency> |
| 119 | +``` |
| 120 | + |
| 121 | +GeneViewer uses [GWT 2.8's][4] new [JSInterop feature][5] and thus it has to be enabled in the GWT compiler args. |
| 122 | +For maven: |
| 123 | +```xml |
| 124 | +<compilerArgs> |
| 125 | + <compilerArg>-generateJsInteropExports</compilerArg> |
| 126 | +</compilerArgs> |
| 127 | +``` |
| 128 | +or passing it to the compiler via `-generateJsInteropExports` |
| 129 | + |
| 130 | +You can also download the [jar][6] directly or check out the source using git |
| 131 | +from <https://github.com/timeu/geneviewer.git> and build it yourself. Once |
| 132 | +you've installed LDViewer, be sure to inherit the module in your .gwt.xml |
| 133 | +file like this: |
| 134 | + |
| 135 | +```xml |
| 136 | + <inherits name='com.github.timeu.gwtlibs.gwasviewer.GWASViewer'/> |
| 137 | +``` |
| 138 | + |
| 139 | +## Where can I learn more? |
| 140 | + |
| 141 | + * Check out the [sample app][7] ([Source Code][8]) for a full example of using GeneViewer. |
| 142 | + |
| 143 | +[0]: http://gitub.com/timeu/dygraphs-gwt |
| 144 | +[1]: http://github.com/timeu/GeneViewer |
| 145 | +[2]: http://github.com/timeu/LDViewer |
| 146 | +[3]: https://github.com/google/gwt-charts |
| 147 | +[4]: http://www.gwtproject.org/release-notes.html#Release_Notes_2_8_0_BETA1 |
| 148 | +[5]: https://docs.google.com/document/d/10fmlEYIHcyead_4R1S5wKGs1t2I7Fnp_PaNaa7XTEk0/edit#heading=h.o7amqk9edhb9 |
| 149 | +[6]: https://github.com/timeu/GWASViewer/releases |
| 150 | +[7]: http://timeu.github.io/GWASViewer |
| 151 | +[8]: https://github.com/timeu/GeneViewer/tree/master/gwasviewer-sample |
0 commit comments