Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for sequence track, variant track, launching synteny from dotplot, and add UCSC plugin to demo #1558

Merged
merged 5 commits into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,116 @@ release and click "Edit," then add a description to the release. Usually you
can copy the content of the blog post that was generated (it will be named
something like `website/blog/${DATE}-${RELEASE_TAG}-release.md`), removing the
"Downloads" section. Finally, click "Publish release."

## Monorepo code organization

JBrowse 2 code is organized as a monorepo using [lerna](https://lerna.js.org/)
and [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/). Using a
monorepo means that instead of separate GitHub repositories for each piece of
JBrowse, they are all in a single place and can share code easily. In the top
level of the repository there are two directories, `packages/` and `products/`
that each contain multiple packages.

Each "package" is an npm-style (i.e. contains `package.json`) package. The
packages in `packages/` are core code, development tools, etc. The packages in
`plugins/` are JBrowse plugins. Most of JBrowse is written as plugins, so that
is where most of the code is. The packages in `products/` are user-facing
products, such as JBrowse Web, JBrowse Desktop, JBrowse CLI, etc.

### Monorepo packages

The following is a summary of some of the individual packages in the monorepo.
It's not a comprehensive list, but will hopefully help familiarize you with how
the code is organized.

#### products/jbrowse-web

This is the full JBrowse Web app. It is built using
[create-react-app](https://create-react-app.dev/).

It includes many other packages as core plugins, can load other plugins at
runtime, and more.

It also currently holds the "integration tests" that we use for our code in
`products/jbrowse-web/src/tests`.

#### products/jbrowse-desktop

JBrowse Desktop is our essentially the same as JBrowse Web, but packaged with
[electron](https://www.electronjs.org/) into a desktop app. This gives it the
ability to easily load and save tracks based on files on your local filesystem.
It also has save sessions locally, and works offline.

#### products/website

This provides the docusaurus website with docs, blog, and pdf documentation

#### plugins/alignments

This package provides the "alignments" related features including

- BamAdapter - our BAM parser that wraps @gmod/bam NPM module
- CramAdapter - our CRAM parser that wraps the @gmod/cram NPM module
- PileupTrack type - draws alignments as boxes in a "pileup" style view
- SNPCoverageTrack - draws calculated coverage with mismatches drawn over the coverage
- AlignmentsTrack - a "supertrack" which contains a PileupTrack and
SNPCoverageTrack "subtracks"
- AlignmentsFeatureWidget for alignments features

#### plugins/variants/

Provides variant features including

- VCF tabix parser
- VariantFeatureWidget
- VariantTrack that is basically just a normal track, but has logic to popup
the VariantFeatureWidget on feature click

#### plugins/hic

This provides a HicAdapter based on the .hic file format
([ref](https://github.com/aidenlab/juicer/wiki/Data#hic-files))

Also a track type and renderer to visualize these

#### plugins/bed

Provides two bed related data adapters

- BigBedAdapter
- BedTabixAdapter

These can be used with the SvgFeatureRenderer

#### plugins/wiggle

Provides wiggle track types with different types of rendering formats including

- XYPlotRenderer
- LinePlotRenderer
- DensityRenderer

The WiggleTrack type can swap out these different rendering types, and
calculates stats such as max and min score over a region before the region is
rendered

#### plugins/svg

This is the main gene glyphs, which are rendered using SVG

General usage of this involves referencing the SvgFeatureRenderer

#### plugins/spreadsheet-view

This provides a spreadsheet-in-the-browser that can be used as a data backend
to power other views

#### plugins/circular-view

This provides our 'Circos-style' whole-genome overview of data, especially
genomic translocations

#### plugins/sv-inspector

This is a "superview" type that contains a circular and spreadsheet view as
child views
26 changes: 26 additions & 0 deletions test_data/config_demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
{
"name": "GDC",
"url": "https://ghcdn.rawgit.org/GMOD/jbrowse-plugin-gdc/master/dist/plugin.js"
},
{
"name": "UCSC",
"url": "https://ghcdn.rawgit.org/cmdcolin/jbrowse-plugin-ucsc-api/master/dist/plugin.js"
}
],
"assemblies": [
Expand Down Expand Up @@ -205,6 +209,28 @@
"type": "MyGeneV3Adapter"
}
},
{
"type": "FeatureTrack",
"trackId": "genehancer_ucsc_hg38",
"name": "UCSC GeneHancer",
"category": ["Annotation"],
"assemblyNames": ["hg38"],
"adapter": {
"type": "UCSCAdapter",
"track": "geneHancerInteractionsDoubleElite"
}
},
{
"type": "FeatureTrack",
"trackId": "genehancer_ucsc_hg19",
"name": "UCSC GeneHancer",
"category": ["Annotation"],
"assemblyNames": ["hg19"],
"adapter": {
"type": "UCSCAdapter",
"track": "geneHancerInteractionsDoubleElite"
}
},
{
"type": "GDCTrack",
"trackId": "gdc_plugin_track",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: jbrowse-web 0.0.1-beta.27
title: v0.0.1-beta.27 Release
date: 2020-10-22
tags: ['release', 'jbrowse 2']
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: jbrowse-web 0.0.1-beta.28
title: v0.0.1-beta.28 Release
date: 2020-10-31
tags: ['release', 'jbrowse 2']
---
Expand Down
2 changes: 1 addition & 1 deletion website/blog/2020-11-05-jbrowse-web-1.0.0-release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: jbrowse-web 1.0.0
title: v1.0.0 Release
date: 2020-11-05
tags: ['release', 'jbrowse 2']
---
Expand Down
150 changes: 25 additions & 125 deletions website/docs/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ title: Developer guide
toplevel: true
---

In this Developer Guide, will introduce the JBrowse 2 ecosystem from the
developer's point of view. We'll examine the core concepts of how code is
packaged and structured, and then go over how to create new plugins and
pluggable elements.
In this guide, will introduce the JBrowse 2 ecosystem from the developer's
point of view. We'll examine the core concepts of how code is packaged and
structured, and then go over how to create new plugins and pluggable elements.

## Introduction and overview

Expand All @@ -19,7 +18,6 @@ The JBrowse 2 ecosystem has two main type of top-level artifacts that are
published on their own: products and plugins.

![](./img/products_and_plugins.png)

Architecture diagram of JBrowse 2, showing how plugins encapsulate views (e.g.
LinearGenomeView, DotplotView etc.), tracks (AlignmentsTrack, VariantTrack,
etc.), data adapters (BamAdapter, VcfTabixAdapter, etc.) and other logic like
Expand Down Expand Up @@ -399,7 +397,7 @@ Add a menu item to a sub-menu
| menuPath | Path to the sub-menu to add to, starting with the top-level menu (e.g. `['File', 'Insert']`). |
| menuItem | Menu item to append. |

##### Return Value
##### Return value

The new length of the sub-menu

Expand All @@ -415,7 +413,7 @@ Insert a menu item into a sub-menu
| menuItem | Menu item to insert. |
| position | Position to insert menu item. If negative, counts from the end, e.g. `insertMenu('My Menu', -1)` will insert the menu as the second-to-last one. |

##### Return Value
##### Return value

The new length of the sub-menu

Expand All @@ -442,7 +440,7 @@ types
}))
```

### Adding track context menu items
### Adding track context-menu items

When you right-click in a linear track, a context menu will appear if there are
any menu items defined for it. It's possible to add items to that menu, and you
Expand Down Expand Up @@ -496,120 +494,7 @@ class SomePlugin extends Plugin {
}
```

## Monorepo code organization

JBrowse 2 code is organized as a monorepo using [lerna](https://lerna.js.org/)
and [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/). Using a
monorepo means that instead of separate GitHub repositories for each piece of
JBrowse, they are all in a single place and can share code easily. In the top
level of the repository there are two directories, `packages/` and `products/`
that each contain multiple packages.

Each "package" is an npm-style (i.e. contains `package.json`) package. The
packages in `packages/` are core code, development tools, etc. The packages in
`plugins/` are JBrowse plugins. Most of JBrowse is written as plugins, so that
is where most of the code is. The packages in `products/` are user-facing
products, such as JBrowse Web, JBrowse Desktop, JBrowse CLI, etc.

### Monorepo packages

The following is a summary of some of the individual packages in the monorepo.
It's not a comprehensive list, but will hopefully help familiarize you with how
the code is organized.

#### products/jbrowse-web

This is the full JBrowse Web app. It is built using
[create-react-app](https://create-react-app.dev/).

It includes many other packages as core plugins, can load other plugins at
runtime, and more.

It also currently holds the "integration tests" that we use for our code in
`products/jbrowse-web/src/tests`.

#### products/jbrowse-desktop

JBrowse Desktop is our essentially the same as JBrowse Web, but packaged with
[electron](https://www.electronjs.org/) into a desktop app. This gives it the
ability to easily load and save tracks based on files on your local filesystem.
It also has save sessions locally, and works offline.

#### products/website

This provides the docusaurus website with docs, blog, and pdf documentation

#### plugins/alignments

This package provides the "alignments" related features including

- BamAdapter - our BAM parser that wraps @gmod/bam NPM module
- CramAdapter - our CRAM parser that wraps the @gmod/cram NPM module
- PileupTrack type - draws alignments as boxes in a "pileup" style view
- SNPCoverageTrack - draws calculated coverage with mismatches drawn over the coverage
- AlignmentsTrack - a "supertrack" which contains a PileupTrack and
SNPCoverageTrack "subtracks"
- AlignmentsFeatureWidget for alignments features

#### plugins/variants/

Provides variant features including

- VCF tabix parser
- VariantFeatureWidget
- VariantTrack that is basically just a normal track, but has logic to popup
the VariantFeatureWidget on feature click

#### plugins/hic

This provides a HicAdapter based on the .hic file format
([ref](https://github.com/aidenlab/juicer/wiki/Data#hic-files))

Also a track type and renderer to visualize these

#### plugins/bed

Provides two bed related data adapters

- BigBedAdapter
- BedTabixAdapter

These can be used with the SvgFeatureRenderer

#### plugins/wiggle

Provides wiggle track types with different types of rendering formats including

- XYPlotRenderer
- LinePlotRenderer
- DensityRenderer

The WiggleTrack type can swap out these different rendering types, and
calculates stats such as max and min score over a region before the region is
rendered

#### plugins/svg

This is the main gene glyphs, which are rendered using SVG

General usage of this involves referencing the SvgFeatureRenderer

#### plugins/spreadsheet-view

This provides a spreadsheet-in-the-browser that can be used as a data backend
to power other views

#### plugins/circular-view

This provides our 'Circos-style' whole-genome overview of data, especially
genomic translocations

#### plugins/sv-inspector

This is a "superview" type that contains a circular and spreadsheet view as
child views

### Plugin Build system
### Plugin build system

Plugins may be built as separate packages that can be distributed on NPM. In
order to streamline development and avoid having to build every plugin before
Expand Down Expand Up @@ -997,15 +882,30 @@ instead of manually cleaning up resources

## Creating a new plugin

We have a couple plugin examples here

- https://github.com/GMOD/jbrowse-plugin-gdc - demonstrates accessing GDC
cancer data GraphQL API, plus a custom drawer and track type for coloring
variants by impact score
- https://github.com/cmdcolin/jbrowse-plugin-biothings-api - demonstrates
accessing data from mygene.info, part of the "biothings API" family
- https://github.com/cmdcolin/jbrowse-plugin-ucsc-api - demonstrates accessing
data from UCSC

We will go over in detail some of these steps. Note that the best practices
may be found by looking at the above plugins source code directly, and you can
copy these plugins as a template for your own.

### Intro to plugins

JBrowse 2 plugins can be used to add new pluggable elements (views, tracks,
data adapters, etc), and to modify behavior of the application by adding code
that watches the application's state. For the full list of what kinds of
pluggable element types plugins can add, see the [pluggable
elements](developer_guide#pluggable-elements) page.

We will go over creating an example plugin. The first thing that we have is a
`src/index.js` which exports a default class containing the plugin registration
code
The first thing that we have is a `src/index.js` which exports a default class
containing the plugin registration code

src/index.js

Expand Down
Loading