@weng-lab/genomebrowser 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,124 +1,124 @@
1
- # Genome Browser Component Library
2
-
3
- ## Installation
4
- `yarn add @weng-lab/genomebrowser`
5
-
6
- `npm install @weng-lab/genomebrowser`
7
-
8
- ## Usage
9
-
10
- The library revolves around creating tracks and adding them to the browser. To do this, first you import the Genome Browser component, creating the browser state and dispatch function, and adding your tracks to the state. Then you pass the state and dispatch function to the GenomeBrowser component as props.
11
-
12
- ### Walkthrough
13
- First, import the Genome Browser component:
14
- ```tsx
15
- import { GenomeBrowser } from '@weng-lab/genomebrowser';
16
- ```
17
- Then you create the browser state and dispatch function with the `useBrowserState` hook:
18
-
19
- ```tsx
20
- import { useBrowserState } from '@weng-lab/genomebrowser';
21
- const [browserState, browserDispatch] = useBrowserState({
22
- domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
23
- preRenderedWidth: 1350,
24
- width: 1500,
25
- tracks: [],
26
- highlights: []
27
- });
28
- ```
29
-
30
- There are a few ways to add tracks to the browser.
31
- 1. You can add a track by dispatching the `ADD_TRACK` action:
32
- ```tsx
33
- import { BigWigTrackProps } from '@weng-lab/genomebrowser';
34
- const myBigWig: BigWigTrackProps = { ... }
35
- browserDispatch({ type: BrowserActionType.ADD_TRACK, track: myBigWig });
36
- ```
37
- 2. You can add a track by passing a track component as a child to the GenomeBrowser component:
38
- ```tsx
39
- import { BigBedTrack } from '@weng-lab/genomebrowser';
40
- <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
41
- <BigBedTrack ... />
42
- </GenomeBrowser>
43
- ```
44
- 3. You can also add a track by appending it to the 'tracks' array in the browser state:
45
- ```tsx
46
- import { BigWigTrackProps, BrowserState } from '@weng-lab/genomebrowser';
47
- const myBigWig: BigWigTrackProps = { ... }
48
- const myState: BrowserState = {
49
- domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
50
- ... // initialize the rest of the state
51
- tracks: [myBigWig] // add the track to the state
52
- }
53
- ```
54
-
55
- ## Full Example
56
-
57
- ```tsx
58
- // in trackExamples.ts
59
- export const bigWigExample: BigWigTrackProps = {
60
- ...DefaultBigWig,
61
- id: "1",
62
- title: "bigwig",
63
- height: 100,
64
- url: "https://downloads.wenglab.org/DNAse_All_ENCODE_MAR20_2024_merged.bw",
65
- color: "blue"
66
- }
67
- export const bigBedExample: BigBedTrackProps = {
68
- ...DefaultBigBed,
69
- id: "2",
70
- title: "bigbed",
71
- height: 75,
72
- rowHeight: 12,
73
- color: "red",
74
- url: "https://downloads.wenglab.org/GRCh38-cCREs.DCC.bigBed"
75
- }
76
- export const transcriptExample: TranscriptTrackProps = {
77
- ...DefaultTranscript,
78
- id: "3",
79
- title: "transcript",
80
- rowHeight: 12,
81
- assembly: "GRCh38",
82
- queryType: "gene",
83
- version: TranscriptHumanVersion.V47,
84
- height: 100,
85
- color: "green"
86
- }
87
- ```
88
-
89
- ```tsx
90
- // in main.tsx
91
- import { useEffect } from 'react'
92
- import {
93
- GenomeBrowser, BrowserState, BrowserActionType, useBrowserState,
94
- BigBedTrack
95
- } from '../lib'
96
- import { bigWigExample, bigBedExample, transcriptExample } from './trackExamples'
97
-
98
- const defaultState: BrowserState = {
99
- domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
100
- preRenderedWidth: 1350,
101
- width: 1500,
102
- zoomLevel: 148,
103
- delta: 0,
104
- tracks: [bigWigExample] // adds a BigWig track to the state
105
- }
106
-
107
- function Main() {
108
- const [browserState, browserDispatch] = useBrowserState(defaultState)
109
-
110
- useEffect(() => {
111
- // add a Transcript track to the state
112
- browserDispatch({ type: BrowserActionType.ADD_TRACK, track: transcriptExample })
113
- }, [])
114
-
115
- return (
116
- <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
117
- <BigBedTrack {...bigBedExample} /> // add a BigBed track to the browser
118
- </GenomeBrowser>
119
- )
120
- }
121
- ```
122
-
123
- The browser will look something like this:
124
- ![Browser Example](https://github.com/weng-lab/genomebrowser-components/blob/master/image.png)
1
+ # Genome Browser Component Library
2
+
3
+ ## Installation
4
+ `yarn add @weng-lab/genomebrowser`
5
+
6
+ `npm install @weng-lab/genomebrowser`
7
+
8
+ ## Usage
9
+
10
+ The library revolves around creating tracks and adding them to the browser. To do this, first you import the Genome Browser component, creating the browser state and dispatch function, and adding your tracks to the state. Then you pass the state and dispatch function to the GenomeBrowser component as props.
11
+
12
+ ### Walkthrough
13
+ First, import the Genome Browser component:
14
+ ```tsx
15
+ import { GenomeBrowser } from '@weng-lab/genomebrowser';
16
+ ```
17
+ Then you create the browser state and dispatch function with the `useBrowserState` hook:
18
+
19
+ ```tsx
20
+ import { useBrowserState } from '@weng-lab/genomebrowser';
21
+ const [browserState, browserDispatch] = useBrowserState({
22
+ domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
23
+ preRenderedWidth: 1350,
24
+ width: 1500,
25
+ tracks: [],
26
+ highlights: []
27
+ });
28
+ ```
29
+
30
+ There are a few ways to add tracks to the browser.
31
+ 1. You can add a track by dispatching the `ADD_TRACK` action:
32
+ ```tsx
33
+ import { BigWigTrackProps } from '@weng-lab/genomebrowser';
34
+ const myBigWig: BigWigTrackProps = { ... }
35
+ browserDispatch({ type: BrowserActionType.ADD_TRACK, track: myBigWig });
36
+ ```
37
+ 2. You can add a track by passing a track component as a child to the GenomeBrowser component:
38
+ ```tsx
39
+ import { BigBedTrack } from '@weng-lab/genomebrowser';
40
+ <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
41
+ <BigBedTrack ... />
42
+ </GenomeBrowser>
43
+ ```
44
+ 3. You can also add a track by appending it to the 'tracks' array in the browser state:
45
+ ```tsx
46
+ import { BigWigTrackProps, BrowserState } from '@weng-lab/genomebrowser';
47
+ const myBigWig: BigWigTrackProps = { ... }
48
+ const myState: BrowserState = {
49
+ domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
50
+ ... // initialize the rest of the state
51
+ tracks: [myBigWig] // add the track to the state
52
+ }
53
+ ```
54
+
55
+ ## Full Example
56
+
57
+ ```tsx
58
+ // in trackExamples.ts
59
+ export const bigWigExample: BigWigTrackProps = {
60
+ ...DefaultBigWig,
61
+ id: "1",
62
+ title: "bigwig",
63
+ height: 100,
64
+ url: "https://downloads.wenglab.org/DNAse_All_ENCODE_MAR20_2024_merged.bw",
65
+ color: "blue"
66
+ }
67
+ export const bigBedExample: BigBedTrackProps = {
68
+ ...DefaultBigBed,
69
+ id: "2",
70
+ title: "bigbed",
71
+ height: 75,
72
+ rowHeight: 12,
73
+ color: "red",
74
+ url: "https://downloads.wenglab.org/GRCh38-cCREs.DCC.bigBed"
75
+ }
76
+ export const transcriptExample: TranscriptTrackProps = {
77
+ ...DefaultTranscript,
78
+ id: "3",
79
+ title: "transcript",
80
+ rowHeight: 12,
81
+ assembly: "GRCh38",
82
+ queryType: "gene",
83
+ version: TranscriptHumanVersion.V47,
84
+ height: 100,
85
+ color: "green"
86
+ }
87
+ ```
88
+
89
+ ```tsx
90
+ // in main.tsx
91
+ import { useEffect } from 'react'
92
+ import {
93
+ GenomeBrowser, BrowserState, BrowserActionType, useBrowserState,
94
+ BigBedTrack
95
+ } from '../lib'
96
+ import { bigWigExample, bigBedExample, transcriptExample } from './trackExamples'
97
+
98
+ const defaultState: BrowserState = {
99
+ domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
100
+ preRenderedWidth: 1350,
101
+ width: 1500,
102
+ zoomLevel: 148,
103
+ delta: 0,
104
+ tracks: [bigWigExample] // adds a BigWig track to the state
105
+ }
106
+
107
+ function Main() {
108
+ const [browserState, browserDispatch] = useBrowserState(defaultState)
109
+
110
+ useEffect(() => {
111
+ // add a Transcript track to the state
112
+ browserDispatch({ type: BrowserActionType.ADD_TRACK, track: transcriptExample })
113
+ }, [])
114
+
115
+ return (
116
+ <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
117
+ <BigBedTrack {...bigBedExample} /> // add a BigBed track to the browser
118
+ </GenomeBrowser>
119
+ )
120
+ }
121
+ ```
122
+
123
+ The browser will look something like this:
124
+ ![Browser Example](https://github.com/weng-lab/genomebrowser-components/blob/master/image.png)