Skip to content

Commit d13139d

Browse files
committed
Merge branch 'release/0.14.0'
2 parents 03fc214 + a2389b8 commit d13139d

File tree

259 files changed

+25076
-12954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+25076
-12954
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = {
4545
'node': true,
4646
},
4747
'parserOptions': {
48-
'ecmaVersion': 2016,
48+
'ecmaVersion': 2020,
4949
'sourceType': 'module',
5050
},
5151
};

README.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,27 @@
22

33
LocusZoom is a Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
44

5+
6+
For more information, see our paper:
7+
8+
*Boughton, A. P. et al. LocusZoom.js: interactive and embeddable visualization of genetic association study results. Bioinformatics (2021) [doi:10.1093/bioinformatics/btab186](https://doi.org/10.1093/bioinformatics/btab186).*
9+
10+
**This is a low level library aimed at developers who want to customize their own data sharing/visualization tools. If you are a genetics researcher who just wants to make a fast visualization of your research results, try our user-friendly plot-your-own data services built on LocusZoom.js: [my.locuszoom.org](https://my.locuszoom.org/) and [LocalZoom](https://statgen.github.io/localzoom/)**.
11+
12+
513
![Build Status](https://github.com/statgen/locuszoom/workflows/Unit%20tests/badge.svg?branch=develop)
614

715
See [https://statgen.github.io/locuszoom/docs/](https://statgen.github.io/locuszoom/docs/) for full documentation and API reference.
816

917
To see functional examples of plots generated with LocusZoom.js see [statgen.github.io/locuszoom](http://statgen.github.io/locuszoom/) and [statgen.github.io/locuszoom/#examples](http://statgen.github.io/locuszoom/#examples).
1018

11-
![LocusZoom.js Standard Association Plot](http://statgen.github.io/locuszoom/wiki_images/locuszoom_standard_association_plot_0.5.2.png)
19+
![LocusZoom.js Standard Association Plot](examples/locuszoom_standard_association_example.png)
1220

13-
## Making a LocusZoom Plot
21+
## Making a LocusZoom Plot: Quickstart tutorial
1422

1523
### 1. Include Necessary JavaScript and CSS
1624

17-
The page you build that embeds the LocusZoom plugin must include the following resources, found in the `dist` directory:
25+
The page you build that embeds the LocusZoom plugin must include the following resources, found in the `dist` directory (or preferably loaded via CDN):
1826

1927
* `d3.js`
2028
[D3.js](https://d3js.org/) v5.16.0 is used to draw graphics in LocusZoom plots. It may be loaded [via a CDN](https://cdn.jsdelivr.net/npm/d3@^5.16.0). It must be present before LocusZoom is loaded.
@@ -42,7 +50,7 @@ Here's an example of defining a data sources object for a remote API:
4250

4351
```javascript
4452
var data_sources = new LocusZoom.DataSources();
45-
data_sources.add("assoc", ["AssociationLZ", { url: "http://server.com/api/", params: {source: 1} }]);
53+
data_sources.add("assoc", ["AssociationLZ", { url: "http://server.com/api/", source: 1 }]);
4654
```
4755

4856
The above example adds an "AssociationLZ" data source (a predefined data source designed to make requests for association data) with a defined URL. The namespace for this data source is "assoc".
@@ -73,7 +81,6 @@ var layout = {
7381
{
7482
id: "association",
7583
type: "scatter",
76-
fields: ["assoc:position", "assoc:pvalue"],
7784
x_axis: { field: "assoc:position" },
7885
y_axis: { field: "assoc:pvalue" }
7986
}
@@ -96,33 +103,32 @@ A basic example may then look like this:
96103
```html
97104
<html>
98105
<head>
99-
<script src="locuszoom.app.min.js" type="text/javascript"></script>
100-
<link rel="stylesheet" type="text/css" href="locuszoom.css"/>
106+
<script src="dist/locuszoom.app.min.js" type="text/javascript"></script>
107+
<link rel="stylesheet" type="text/css" href="dist/locuszoom.css"/>
101108
</head>
102109
<body>
103-
<div id="plot"></div>
110+
<div id="lz-plot"></div>
104111
<script type="text/javascript">
105-
var data_sources = new LocusZoom.DataSources();
106-
data_sources.add("assoc", ["AssociationLZ", { url: "https://server.com/api/single/", params: {source: 1} }]);
107-
var layout = {
108-
width: 500,
112+
const data_sources = new LocusZoom.DataSources();
113+
data_sources.add("assoc", ["AssociationLZ", { url: "https://server.com/api/single/", source: 1 }]);
114+
const layout = {
115+
width: 800,
109116
panels: [
110117
{
111118
id : "association",
112-
height: 500,
119+
height: 300,
113120
data_layers: [
114121
{
115122
id: "association",
116123
type: "scatter",
117-
fields: ["assoc:position", "assoc:pvalue"],
118124
x_axis: { field: "assoc:position" },
119-
y_axis: { field: "assoc:pvalue" }
125+
y_axis: { field: "assoc:log_pvalue" }
120126
}
121127
]
122128
}
123129
]
124130
};
125-
var plot = LocusZoom.populate("#lz-plot", data_sources, layout);
131+
const plot = LocusZoom.populate("#lz-plot", data_sources, layout);
126132
</script>
127133
</body>
128134
</html>
@@ -132,11 +138,11 @@ A basic example may then look like this:
132138

133139
#### Use a Predefined Layout
134140

135-
The core LocusZoom library comes equipped with several predefined layouts, organized by type ("plot", "panel", "data_layer", and "toolbar"). You can see what layouts are predefined by reading the contents of `assets/js/app/Layouts.js` or in the browser by entering `LocusZoom.Layouts.list()` (or to list one specific type: `LocusZoom.Layouts.list(type)`).
141+
The core LocusZoom library comes equipped with several predefined layouts, organized by type ("plot", "panel", "data_layer", and "toolbar"). You can see what layouts are predefined by reading the [documentation](https://statgen.github.io/locuszoom/docs/api/module-LocusZoom_Layouts.html) or introspecting in the browser by entering `LocusZoom.Layouts.list()` (or to list one specific type, like "data_layer": `LocusZoom.Layouts.list(type)`).
136142

137143
Get any predefined layout by type and name using `LocusZoom.Layouts.get(type, name)`.
138144

139-
If your data matches the field names and formats of the [UMich PortalDev API](https://portaldev.sph.umich.edu/docs/api/v1/#overview-of-api-endpoints), these layouts will provide a quick way to get started. If your data obeys different format rules, customization may be necessary.
145+
If your data matches the field names and formats of the [UMich PortalDev API](https://portaldev.sph.umich.edu/docs/api/v1/#overview-of-api-endpoints), these layouts will provide a quick way to get started. If your data obeys different format rules, customization may be necessary. (for example, some LocusZoom features assume the presence of a field called `log_pvalue`)
140146

141147
See the [guide to working with layouts](https://statgen.github.io/locuszoom/docs/guides/rendering_layouts.html) for further details.
142148

@@ -150,7 +156,7 @@ const layout = {
150156
width: 1000,
151157
height: 500,
152158
panels: [
153-
LocusZoom.Layouts.get("panel", "gwas"),
159+
LocusZoom.Layouts.get("panel", "association"),
154160
{
155161
id: "custom_panel",
156162
...options
@@ -166,24 +172,21 @@ const layout = {
166172
The `get()` function also accepts a partial layout to be merged with the predefined layout as a third argument, providing the ability to use predefined layouts as starting points for custom layouts with only minor differences. Example:
167173

168174
```javascript
169-
const changes = {
170-
label_font_size: 20,
171-
transition: false
172-
};
173-
LocusZoom.Layouts.get("data_layer", "genes", changes);
175+
const overrides = { label_font_size: 20 };
176+
LocusZoom.Layouts.get("data_layer", "genes", overrides);
174177
```
175178

176179
#### Predefining State by Building a State Object
177180

178-
**State** is a serializable JSON object that describes orientation to specific data from data sources, and specific interactions with the layout. This can include a specific query against various data sources or pre-selecting specific elements. Essentially, the state object is what tracks these types of user input under the hood in LocusZoom, and it can be predefined at initialization as a top-level parameter in the layout. For example:
181+
**State** is JSON-serializable object containing information that can affect the entire plot (including all data retrieval requests). State can be set before or after the plot is initialized. For example, the following special-named fields will cause the plot to be loaded to a specific region of interest on first render:
179182

180183
```javascript
181184
const layout = LocusZoom.Layouts.get('plot', 'standard_association', { state: { chr: 6, start: 20379709, end: 20979709 } })
182185
```
183186

184-
#### Predefining State With `data-region`
187+
#### Alternate: setting the initial view via `data-region`
185188

186-
You can also describe the locus query aspect of the State (chromosome, start, and end position) using a `data-region` attribute of the containing element before populating it, like so:
189+
You can also describe the locususing a `data-region` attribute of the containing element before populating it, like so:
187190

188191
```html
189192
<div id="lz-plot" data-region="10:114550452-115067678"></div>
@@ -192,7 +195,6 @@ You can also describe the locus query aspect of the State (chromosome, start, an
192195
When `LocusZoom.populate()` is executed on the element defined above it will automatically parse any `data-region` parameter to convert those values into the initial state.
193196

194197
## Development Setup
195-
196198
### Dependencies
197199

198200
LocusZoom is an entirely client-side library designed to plug into arbitrary data sets, be they local files, APIs, or something else entirely. It has the following external dependencies:
@@ -218,8 +220,8 @@ This build process will also write sourcemaps, to help with debugging code even
218220
* `npm run test` - Run unit tests (optional: `npm run test:coverage` to output a code coverage report)
219221
* `npm run dev` - Automatically rebuild the library whenever code changes (development mode)
220222
* `npm run build` - Run tests, and if they pass, build the library for release
221-
* `npm run css` - Rebuild the CSS using SASS
222-
* `npm run docs` - Build the library documentation
223+
* `npm run css` - Rebuild the CSS using SASS (CSS rarely changes, so this doesn't get done automatically in dev mode)
224+
* `npm run docs` - Build just the library documentation
223225

224226

225227
#### Automated Testing
@@ -231,9 +233,9 @@ LocusZoom runs code quality checks via [ESLint](http://eslint.org/), the rules f
231233

232234
## Help and Support
233235

234-
Full documentation can be found here: [docs/](https://statgen.github.io/locuszoom/docs/)
236+
Full API documentation and prose guides are available at: [https://statgen.github.io/locuszoom/docs/](https://statgen.github.io/locuszoom/docs/)
235237

236-
A LocusZoom discussion forum is available here: [groups.google.com/forum/#!forum/locuszoom](https://groups.google.com/forum/#!forum/locuszoom).
238+
A LocusZoom discussion forum is available here: [https://groups.google.com/forum/#!forum/locuszoom](https://groups.google.com/forum/#!forum/locuszoom).
237239
For the most effective help, please specify that your question is about "LocusZoom.js".
238240

239241
If you have questions or feedback please file an issue on the [LocusZoom.js GitHub repository](https://github.com/statgen/locuszoom/issues) or post at the discussion forum referenced above.

0 commit comments

Comments
 (0)