jbrowse-plugin-tview 2.0.4 → 2.1.0
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 +157 -4
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.d.ts +132 -0
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js +152 -0
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js.map +1 -0
- package/dist/LaunchTView/TviewGetPlanRpc/index.d.ts +3 -0
- package/dist/LaunchTView/TviewGetPlanRpc/index.js +5 -0
- package/dist/LaunchTView/TviewGetPlanRpc/index.js.map +1 -0
- package/dist/LaunchTView/align.d.ts +93 -9
- package/dist/LaunchTView/align.js +290 -15
- package/dist/LaunchTView/align.js.map +1 -1
- package/dist/LaunchTView/alleles.d.ts +57 -0
- package/dist/LaunchTView/alleles.js +94 -0
- package/dist/LaunchTView/alleles.js.map +1 -0
- package/dist/LaunchTView/components/ArrayReport.d.ts +10 -0
- package/dist/LaunchTView/components/ArrayReport.js +59 -0
- package/dist/LaunchTView/components/ArrayReport.js.map +1 -0
- package/dist/LaunchTView/components/LaunchTViewDialog.js +74 -37
- package/dist/LaunchTView/components/LaunchTViewDialog.js.map +1 -1
- package/dist/LaunchTView/fetchTviewPlan.d.ts +20 -13
- package/dist/LaunchTView/fetchTviewPlan.js +27 -27
- package/dist/LaunchTView/fetchTviewPlan.js.map +1 -1
- package/dist/LaunchTView/launchView.d.ts +25 -0
- package/dist/LaunchTView/launchView.js +20 -0
- package/dist/LaunchTView/launchView.js.map +1 -0
- package/dist/LaunchTView/readLayout.d.ts +85 -0
- package/dist/LaunchTView/readLayout.js +96 -0
- package/dist/LaunchTView/readLayout.js.map +1 -0
- package/dist/LaunchTView/repeats.d.ts +68 -0
- package/dist/LaunchTView/repeats.js +200 -0
- package/dist/LaunchTView/repeats.js.map +1 -0
- package/dist/LaunchTView/sampleTree.d.ts +37 -0
- package/dist/LaunchTView/sampleTree.js +65 -0
- package/dist/LaunchTView/sampleTree.js.map +1 -0
- package/dist/LaunchTView/tview.d.ts +67 -44
- package/dist/LaunchTView/tview.js +190 -121
- package/dist/LaunchTView/tview.js.map +1 -1
- package/dist/LaunchTView/useTviewMsa.d.ts +13 -9
- package/dist/LaunchTView/useTviewMsa.js +15 -11
- package/dist/LaunchTView/useTviewMsa.js.map +1 -1
- package/dist/TViewPanel/coords.d.ts +9 -1
- package/dist/TViewPanel/coords.js +22 -2
- package/dist/TViewPanel/coords.js.map +1 -1
- package/dist/TViewPanel/init.d.ts +56 -0
- package/dist/TViewPanel/init.js +59 -0
- package/dist/TViewPanel/init.js.map +1 -0
- package/dist/TViewPanel/model.d.ts +56 -40
- package/dist/TViewPanel/model.js +73 -51
- package/dist/TViewPanel/model.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/jbrowse-plugin-tview.umd.production.min.js +59 -21
- package/dist/jbrowse-plugin-tview.umd.production.min.js.map +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -3
- package/src/LaunchTView/TviewGetPlanRpc/TviewGetPlan.ts +264 -0
- package/src/LaunchTView/TviewGetPlanRpc/index.ts +14 -0
- package/src/LaunchTView/align.ts +343 -17
- package/src/LaunchTView/alleles.ts +132 -0
- package/src/LaunchTView/components/ArrayReport.tsx +64 -0
- package/src/LaunchTView/components/LaunchTViewDialog.tsx +122 -39
- package/src/LaunchTView/fetchTviewPlan.ts +42 -42
- package/src/LaunchTView/launchView.ts +50 -0
- package/src/LaunchTView/readLayout.ts +145 -0
- package/src/LaunchTView/repeats.ts +218 -0
- package/src/LaunchTView/sampleTree.ts +73 -0
- package/src/LaunchTView/tview.ts +259 -157
- package/src/LaunchTView/useTviewMsa.ts +20 -17
- package/src/TViewPanel/coords.ts +23 -1
- package/src/TViewPanel/init.ts +127 -0
- package/src/TViewPanel/model.ts +82 -61
- package/src/index.ts +5 -1
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -20,13 +20,117 @@ insertion show their base, reads that span the position without it show `-`, and
|
|
|
20
20
|
reads that do not cover it show `.` — so every row stays the same width and the
|
|
21
21
|
reference columns still line up.
|
|
22
22
|
|
|
23
|
-
Regenerate with `pnpm figure
|
|
23
|
+
Regenerate with `pnpm figure`; the tandem-repeat figures below come from
|
|
24
|
+
`pnpm figures:repeats`.
|
|
25
|
+
|
|
26
|
+
## How it is built
|
|
27
|
+
|
|
28
|
+
The alignment is built in an **RPC worker** (`TviewGetPlan`), so the reads never
|
|
29
|
+
cross to the main thread — the fetch, the pairwise alignments and the string
|
|
30
|
+
building all happen there and only the FASTA comes back. That is also what makes
|
|
31
|
+
several files one call: their rows are squared up against the same reference
|
|
32
|
+
interval, so an array's copies are counted once, over rows from all of them.
|
|
33
|
+
|
|
34
|
+
## Tandem repeats
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
The ABCA7 VNTR in one PacBio HiFi sample, a copy per block of columns. Every row
|
|
39
|
+
carries its copy count, and the rows sort by it, so the genotype is the step in
|
|
40
|
+
the ladder: two reads at 88 copies, a scatter between, and a group at 20-21.
|
|
41
|
+
Laid out base by base this is 2.2kb of sequence with nothing to line it up
|
|
42
|
+
against.
|
|
43
|
+
|
|
44
|
+
### An array is an interval, not an insertion
|
|
45
|
+
|
|
46
|
+
The array is found in the **reference**, and a row's allele is what it has
|
|
47
|
+
between the two ends of that interval — its matched bases, plus what it inserted
|
|
48
|
+
inside, minus what it deleted. Everything else follows from that:
|
|
49
|
+
|
|
50
|
+
- **The count is the allele, not the excess.** An STR is already in the
|
|
51
|
+
reference, so a read's insertion is only how much more it carries than hg19
|
|
52
|
+
does, and a contracted allele inserts nothing at all.
|
|
53
|
+
- **One locus is one array.** An indel inside an array has no unique placement,
|
|
54
|
+
so an aligner anchors different reads at different positions; measured over an
|
|
55
|
+
interval those choices cancel. ATXN3 in HG002 reported as four separate arrays
|
|
56
|
+
when anchored on insertions, splitting one locus's alleles across four counts.
|
|
57
|
+
- **Every spanning read is counted**, including the ones that match the
|
|
58
|
+
reference exactly — usually the commonest allele, and invisible to anything
|
|
59
|
+
keyed on insertions.
|
|
60
|
+
- **The reference is a row.** It is laid out and counted like any other allele,
|
|
61
|
+
which is what the coordinates are named after.
|
|
62
|
+
|
|
63
|
+
Nothing declares a repeat. Periods from 2 to 300bp are scanned, the shortest one
|
|
64
|
+
that explains a stretch wins, and a homopolymer is declined — it is periodic at
|
|
65
|
+
every lag and its "unit" is an arbitrary cut through one run.
|
|
66
|
+
|
|
67
|
+
At a detected array:
|
|
68
|
+
|
|
69
|
+
- **copy k of every row occupies the same block**, so one divergent copy shows
|
|
70
|
+
up as a column rather than shifting every copy after it.
|
|
71
|
+
- **each row is labelled with its copy count** (`readname|n=32`), which is the
|
|
72
|
+
measurement, rather than leaving it to be read off where the row ends.
|
|
73
|
+
- **rows are ordered longest allele first**, so the alleles form a ladder.
|
|
74
|
+
- the default column width shrinks to fit the array on screen.
|
|
75
|
+
|
|
76
|
+
**Blocks are array order, not homology.** Copies are counted from the left edge
|
|
77
|
+
of the interval, and arrays expand and contract anywhere inside themselves, so
|
|
78
|
+
the 9th copy of one row need not be the 9th copy of another. Reading down a row
|
|
79
|
+
is sound; reading across two is a hypothesis.
|
|
80
|
+
|
|
81
|
+
### What the numbers were checked against
|
|
82
|
+
|
|
83
|
+
`pnpm qc:repeats` runs the plan builder over the GIAB Ashkenazi trio (PacBio
|
|
84
|
+
HiFi, GRCh37) at known loci. Reading the per-sample modes as a genotype, every
|
|
85
|
+
locus with variation to check is Mendelian:
|
|
86
|
+
|
|
87
|
+
| locus | ref | HG003 (father) | HG004 (mother) | HG002 (son) |
|
|
88
|
+
| ------------- | --- | -------------- | -------------- | ----------- |
|
|
89
|
+
| HTT (CAG) | 33 | 31 / 31 | 31 / 38 | 31 / 38 |
|
|
90
|
+
| ATXN3 (CTG) | 8 | 8 / 17 | 8 / 8 | 8 / 17 |
|
|
91
|
+
| TCF4 CTG18.1 | 38 | 25 / 46 | 28 / 38 | 28 / 46 |
|
|
92
|
+
| DMPK (CTG) | 21 | 12 / 14 | 6 / 12 | 12 / 12 |
|
|
93
|
+
| FMR1 (CGG), X | 21 | 30 | 31 / 32 | 32 |
|
|
94
|
+
|
|
95
|
+
FMR1 is the one that cannot be right by accident: nothing tells the layout which
|
|
96
|
+
chromosome it is on, and the two males come back with one allele each and the
|
|
97
|
+
mother with two, with the son's allele one of hers.
|
|
98
|
+
|
|
99
|
+
### Where it is weaker
|
|
100
|
+
|
|
101
|
+
- **The interval is what scans as periodic, not a curated locus definition.**
|
|
102
|
+
Where a locus runs two related units together — HTT's CAG tract and the CCG
|
|
103
|
+
tract after it are both period 3 — they are one array, the count spans both,
|
|
104
|
+
and it will not match a published CAG size.
|
|
105
|
+
- **A few reads per locus land off the mode.** HG004 at ATXN3 is 8/8 on 47 of 51
|
|
106
|
+
spanning reads, with 3 reads at 21. Read the distribution, not one row.
|
|
107
|
+
- **Long VNTR alleles are noisy.** ABCA7's expanded haplotype in HG003 comes
|
|
108
|
+
back as 87, 88, 88 on three reads but also 49 and 58 on two more; a 2.2kb
|
|
109
|
+
array of a 25bp unit is where slippage in the read and in the aligner both
|
|
110
|
+
show up.
|
|
111
|
+
- **Coverage thins with array length**, because a row is only counted if it
|
|
112
|
+
spans the interval end to end: 123 spanning reads at FMR1's 62bp array, 11 at
|
|
113
|
+
ABCA7's 466bp one.
|
|
114
|
+
|
|
115
|
+
### Several samples at once
|
|
116
|
+
|
|
117
|
+

|
|
118
|
+
|
|
119
|
+
The FMR1 CGG repeat in the GIAB Ashkenazi trio, all three files in one
|
|
120
|
+
alignment. Rows are grouped into a clade per sample by a synthetic tree, which
|
|
121
|
+
turns on react-msaview's collapse and show-only controls for free.
|
|
122
|
+
|
|
123
|
+
The copy numbers are checkable, which is the point of this locus: FMR1 is on the
|
|
124
|
+
X, so the two male samples come back with one allele each (HG002 32, HG003 30)
|
|
125
|
+
and the mother with two (31 and 32) — and the son's single allele is one of his
|
|
126
|
+
mother's, as an X-linked allele has to be.
|
|
24
127
|
|
|
25
128
|
## Usage
|
|
26
129
|
|
|
27
130
|
- Install the plugin
|
|
28
131
|
- Open the track menu (vertical `...`) on an alignments track
|
|
29
132
|
- Click "Launch tview for visible region"
|
|
133
|
+
- Tick any other open alignments track to fold its reads into the same alignment
|
|
30
134
|
|
|
31
135
|
The launched view stays connected to the genome view it came from: hovering or
|
|
32
136
|
clicking an alignment column highlights the corresponding genome position, and
|
|
@@ -36,6 +140,46 @@ switches between centering and zooming.
|
|
|
36
140
|
The visible region is capped at 20kb, since one column per base gets unwieldy
|
|
37
141
|
beyond that.
|
|
38
142
|
|
|
143
|
+
### As a session, with no click path
|
|
144
|
+
|
|
145
|
+
A tview is a locus, an assembly and the files to read it from, so it can be
|
|
146
|
+
declared rather than driven. In a `defaultSession` or a saved session that is
|
|
147
|
+
the view's `init` block:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"type": "TView",
|
|
152
|
+
"init": {
|
|
153
|
+
"assembly": "hg19",
|
|
154
|
+
"loc": "chrX:146,993,530..146,993,670",
|
|
155
|
+
"tracks": [
|
|
156
|
+
{ "trackId": "HG002", "sample": "HG002_son" },
|
|
157
|
+
{ "trackId": "HG003", "sample": "HG003_father" }
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
A [session spec](https://jbrowse.org/jb2/docs/urlparams/) URL takes the same
|
|
164
|
+
keys **flat** — that is the one shape difference, and it is JBrowse's, not this
|
|
165
|
+
plugin's:
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"type": "TView",
|
|
170
|
+
"assembly": "hg19",
|
|
171
|
+
"loc": "chrX:146,993,530..146,993,670",
|
|
172
|
+
"tracks": ["HG002"]
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Either way the view resolves it itself, which is also how a restored session
|
|
177
|
+
gets its alignment back: react-msaview drops an MSA over 50kb from snapshots and
|
|
178
|
+
there is no file to reload from, so `init` is what persists.
|
|
179
|
+
|
|
180
|
+
`public/repeats.json` is a working example — the GIAB trio on hosted hg19, with
|
|
181
|
+
a tview at FMR1 open on load.
|
|
182
|
+
|
|
39
183
|
## Requirements
|
|
40
184
|
|
|
41
185
|
Needs a JBrowse build shipping `@jbrowse/core` >=4.3 with MUI 9 — currently
|
|
@@ -47,13 +191,22 @@ internals that the 4.3.0 release does not ship.
|
|
|
47
191
|
|
|
48
192
|
```bash
|
|
49
193
|
pnpm install
|
|
50
|
-
pnpm start
|
|
51
|
-
pnpm test
|
|
52
|
-
pnpm test:e2e
|
|
194
|
+
pnpm start # dev server on :9000, serves dist/out.js with CORS
|
|
195
|
+
pnpm test # unit tests
|
|
196
|
+
pnpm test:e2e # puppeteer tests (creates .test-jbrowse on first run)
|
|
53
197
|
pnpm lint
|
|
54
198
|
pnpm build
|
|
199
|
+
|
|
200
|
+
pnpm figures:repeats # the tandem-repeat figures in img/
|
|
201
|
+
pnpm qc:repeats # copy numbers at known loci, from live GIAB data
|
|
55
202
|
```
|
|
56
203
|
|
|
204
|
+
`qc:repeats` is not a test. It fetches from GIAB and UCSC and prints what the
|
|
205
|
+
plan builder measured at each locus, per sample, so the numbers can be read
|
|
206
|
+
against what the locus is known to carry — Mendelian consistency across the
|
|
207
|
+
trio, hemizygosity on the X, published allele ranges. The loci and samples live
|
|
208
|
+
in `test/liveRepeatsData.ts`.
|
|
209
|
+
|
|
57
210
|
`pnpm start` serves the repo root, so a JBrowse instance unpacked at
|
|
58
211
|
`.test-jbrowse` can load the plugin from the same origin via
|
|
59
212
|
`http://localhost:9000/.test-jbrowse/index.html?config=../public/config.json`.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { RpcMethodType } from '@jbrowse/core/pluggableElementTypes';
|
|
2
|
+
import type { Region } from '@jbrowse/core/util';
|
|
3
|
+
/** one BAM/CRAM to draw rows from, and the name its rows are grouped under */
|
|
4
|
+
export interface TviewSourceArgs {
|
|
5
|
+
adapterConfig: Record<string, unknown>;
|
|
6
|
+
sample?: string;
|
|
7
|
+
/**
|
|
8
|
+
* what this file calls the region's sequence. Filled in on the client, where
|
|
9
|
+
* the assembly's aliases live: two files over one assembly routinely spell it
|
|
10
|
+
* `4` and `chr4`, and a mismatched name fetches nothing and reports nothing.
|
|
11
|
+
*/
|
|
12
|
+
refName?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TviewGetPlanArgs {
|
|
15
|
+
sessionId: string;
|
|
16
|
+
sources: TviewSourceArgs[];
|
|
17
|
+
/** the assembly's sequence adapter, when it has one */
|
|
18
|
+
sequenceAdapterConfig?: Record<string, unknown>;
|
|
19
|
+
/** the sequence adapter's own spelling of the region */
|
|
20
|
+
sequenceRefName?: string;
|
|
21
|
+
region: Region;
|
|
22
|
+
/** stop before rendering an alignment bigger than this many cells */
|
|
23
|
+
maxCells: number;
|
|
24
|
+
}
|
|
25
|
+
/** what crosses back: the alignment, and the numbers the dialog reports */
|
|
26
|
+
export interface TviewArrayReport {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
period: number;
|
|
30
|
+
unit: string;
|
|
31
|
+
width: number;
|
|
32
|
+
/** per row: copies carried, and allele length in bp */
|
|
33
|
+
copies: [string, number][];
|
|
34
|
+
lengths: [string, number][];
|
|
35
|
+
}
|
|
36
|
+
export interface TviewPlanResult {
|
|
37
|
+
msa: string;
|
|
38
|
+
/** Newick grouping rows by sample; absent unless several were loaded */
|
|
39
|
+
tree?: string;
|
|
40
|
+
rowCount: number;
|
|
41
|
+
columnCount: number;
|
|
42
|
+
cellCount: number;
|
|
43
|
+
insertionWidths: [number, number][];
|
|
44
|
+
arraySpans: [number, number, number][];
|
|
45
|
+
region: {
|
|
46
|
+
refName: string;
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
};
|
|
50
|
+
arrays: TviewArrayReport[];
|
|
51
|
+
subjectIndex?: number;
|
|
52
|
+
referenceName?: string;
|
|
53
|
+
samples: string[];
|
|
54
|
+
/** set when the alignment was over maxCells and `msa` is empty */
|
|
55
|
+
tooLarge?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Builds the whole alignment in the worker and sends back the FASTA.
|
|
59
|
+
*
|
|
60
|
+
* The work this moves is not the fetch — `CoreGetFeatures` already ran in a
|
|
61
|
+
* worker — but everything after it. Fetching from the client meant serializing
|
|
62
|
+
* every read's sequence and CIGAR across the boundary and then running the
|
|
63
|
+
* pairwise alignments and the string building on the main thread, where a
|
|
64
|
+
* region carrying a kilobase-scale array froze the UI for as long as it took.
|
|
65
|
+
* What comes back now is the alignment, which is smaller than the reads it was
|
|
66
|
+
* built from and is the only thing the view has a use for.
|
|
67
|
+
*
|
|
68
|
+
* It is also what makes several files one call: their rows are squared up
|
|
69
|
+
* against the same reference interval, so an array's copies are counted once,
|
|
70
|
+
* over rows from all of them.
|
|
71
|
+
*/
|
|
72
|
+
export default class TviewGetPlan extends RpcMethodType {
|
|
73
|
+
name: string;
|
|
74
|
+
/**
|
|
75
|
+
* Written against the 4.3.0 base class, which takes a bare
|
|
76
|
+
* `Record<string, unknown>` and has no `renameRegions` helper — that is the
|
|
77
|
+
* oldest host this bundle boots on, and the newer base class accepts the same
|
|
78
|
+
* shape.
|
|
79
|
+
*/
|
|
80
|
+
serializeArguments(args: Record<string, unknown>, rpcDriverClassName: string): Promise<Record<string, unknown>>;
|
|
81
|
+
execute(args: TviewGetPlanArgs, rpcDriverClassName: string): Promise<{
|
|
82
|
+
msa: string;
|
|
83
|
+
tooLarge: boolean;
|
|
84
|
+
rowCount: number;
|
|
85
|
+
columnCount: number;
|
|
86
|
+
cellCount: number;
|
|
87
|
+
insertionWidths: [number, number][];
|
|
88
|
+
arraySpans: [number, number, number][];
|
|
89
|
+
region: {
|
|
90
|
+
refName: string;
|
|
91
|
+
start: number;
|
|
92
|
+
end: number;
|
|
93
|
+
};
|
|
94
|
+
arrays: {
|
|
95
|
+
start: number;
|
|
96
|
+
end: number;
|
|
97
|
+
period: number;
|
|
98
|
+
unit: string;
|
|
99
|
+
width: number;
|
|
100
|
+
copies: [string, number][];
|
|
101
|
+
lengths: [string, number][];
|
|
102
|
+
}[];
|
|
103
|
+
subjectIndex: number | undefined;
|
|
104
|
+
referenceName: string | undefined;
|
|
105
|
+
samples: string[];
|
|
106
|
+
} | {
|
|
107
|
+
msa: string;
|
|
108
|
+
tree: string | undefined;
|
|
109
|
+
rowCount: number;
|
|
110
|
+
columnCount: number;
|
|
111
|
+
cellCount: number;
|
|
112
|
+
insertionWidths: [number, number][];
|
|
113
|
+
arraySpans: [number, number, number][];
|
|
114
|
+
region: {
|
|
115
|
+
refName: string;
|
|
116
|
+
start: number;
|
|
117
|
+
end: number;
|
|
118
|
+
};
|
|
119
|
+
arrays: {
|
|
120
|
+
start: number;
|
|
121
|
+
end: number;
|
|
122
|
+
period: number;
|
|
123
|
+
unit: string;
|
|
124
|
+
width: number;
|
|
125
|
+
copies: [string, number][];
|
|
126
|
+
lengths: [string, number][];
|
|
127
|
+
}[];
|
|
128
|
+
subjectIndex: number | undefined;
|
|
129
|
+
referenceName: string | undefined;
|
|
130
|
+
samples: string[];
|
|
131
|
+
}>;
|
|
132
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { getAdapter } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
2
|
+
import { RpcMethodType } from '@jbrowse/core/pluggableElementTypes';
|
|
3
|
+
import { renameRegionsIfNeeded } from '@jbrowse/core/util';
|
|
4
|
+
import { buildSampleTree } from '../sampleTree';
|
|
5
|
+
import { planTviewMsa, renderTviewMsa } from '../tview';
|
|
6
|
+
function isFeatureSource(adapter) {
|
|
7
|
+
return 'getFeatures' in adapter && typeof adapter.getFeatures === 'function';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Drains an adapter's feature observable into an array.
|
|
11
|
+
*
|
|
12
|
+
* Hand-rolled rather than `firstValueFrom(...pipe(toArray()))` because rxjs is
|
|
13
|
+
* not a dependency here and `@jbrowse/core/util/rxjs` publishes only
|
|
14
|
+
* `ObservableCreate`. Subscribing directly needs neither.
|
|
15
|
+
*/
|
|
16
|
+
async function fetchAll(pluginManager, sessionId, adapterConfig, region) {
|
|
17
|
+
const { dataAdapter } = await getAdapter(pluginManager, sessionId, adapterConfig);
|
|
18
|
+
if (!isFeatureSource(dataAdapter)) {
|
|
19
|
+
throw new Error(`${adapterConfig.type} has no getFeatures`);
|
|
20
|
+
}
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const ret = [];
|
|
23
|
+
dataAdapter.getFeatures(region).subscribe({
|
|
24
|
+
next: feature => ret.push(feature),
|
|
25
|
+
error: reject,
|
|
26
|
+
complete: () => {
|
|
27
|
+
resolve(ret);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builds the whole alignment in the worker and sends back the FASTA.
|
|
34
|
+
*
|
|
35
|
+
* The work this moves is not the fetch — `CoreGetFeatures` already ran in a
|
|
36
|
+
* worker — but everything after it. Fetching from the client meant serializing
|
|
37
|
+
* every read's sequence and CIGAR across the boundary and then running the
|
|
38
|
+
* pairwise alignments and the string building on the main thread, where a
|
|
39
|
+
* region carrying a kilobase-scale array froze the UI for as long as it took.
|
|
40
|
+
* What comes back now is the alignment, which is smaller than the reads it was
|
|
41
|
+
* built from and is the only thing the view has a use for.
|
|
42
|
+
*
|
|
43
|
+
* It is also what makes several files one call: their rows are squared up
|
|
44
|
+
* against the same reference interval, so an array's copies are counted once,
|
|
45
|
+
* over rows from all of them.
|
|
46
|
+
*/
|
|
47
|
+
export default class TviewGetPlan extends RpcMethodType {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
this.name = 'TviewGetPlan';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Written against the 4.3.0 base class, which takes a bare
|
|
54
|
+
* `Record<string, unknown>` and has no `renameRegions` helper — that is the
|
|
55
|
+
* oldest host this bundle boots on, and the newer base class accepts the same
|
|
56
|
+
* shape.
|
|
57
|
+
*/
|
|
58
|
+
async serializeArguments(args, rpcDriverClassName) {
|
|
59
|
+
const typed = args;
|
|
60
|
+
const assemblyManager = this.pluginManager.rootModel?.session?.assemblyManager;
|
|
61
|
+
if (!assemblyManager) {
|
|
62
|
+
throw new Error('no assembly manager');
|
|
63
|
+
}
|
|
64
|
+
const refNameFor = async (adapterConfig) => {
|
|
65
|
+
const { regions } = await renameRegionsIfNeeded(assemblyManager, {
|
|
66
|
+
sessionId: typed.sessionId,
|
|
67
|
+
adapterConfig,
|
|
68
|
+
regions: [typed.region],
|
|
69
|
+
});
|
|
70
|
+
return regions[0].refName;
|
|
71
|
+
};
|
|
72
|
+
const sources = await Promise.all(typed.sources.map(async (source) => ({
|
|
73
|
+
...source,
|
|
74
|
+
refName: await refNameFor(source.adapterConfig),
|
|
75
|
+
})));
|
|
76
|
+
const sequenceRefName = typed.sequenceAdapterConfig
|
|
77
|
+
? await refNameFor(typed.sequenceAdapterConfig)
|
|
78
|
+
: undefined;
|
|
79
|
+
return super.serializeArguments({ ...args, sources, sequenceRefName }, rpcDriverClassName);
|
|
80
|
+
}
|
|
81
|
+
async execute(args, rpcDriverClassName) {
|
|
82
|
+
const { sessionId, sources, sequenceAdapterConfig, sequenceRefName, region, maxCells, } = await this.deserializeArguments(args, rpcDriverClassName);
|
|
83
|
+
const perSource = await Promise.all(sources.map(source => fetchAll(this.pluginManager, sessionId, source.adapterConfig, {
|
|
84
|
+
...region,
|
|
85
|
+
refName: source.refName ?? region.refName,
|
|
86
|
+
})));
|
|
87
|
+
const features = [];
|
|
88
|
+
const sampleByIndex = [];
|
|
89
|
+
for (const [i, feats] of perSource.entries()) {
|
|
90
|
+
for (const feature of feats) {
|
|
91
|
+
if (feature.get('seq')) {
|
|
92
|
+
features.push(feature);
|
|
93
|
+
sampleByIndex.push(sources[i].sample);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let sequence;
|
|
98
|
+
if (sequenceAdapterConfig) {
|
|
99
|
+
const seqFeats = await fetchAll(this.pluginManager, sessionId, sequenceAdapterConfig, { ...region, refName: sequenceRefName ?? region.refName });
|
|
100
|
+
const seq = seqFeats[0]?.get('seq');
|
|
101
|
+
const seqStart = seqFeats[0]?.get('start');
|
|
102
|
+
// the adapter may answer with a wider block than it was asked for
|
|
103
|
+
const sliced = seq !== undefined && seqStart !== undefined
|
|
104
|
+
? seq.slice(region.start - seqStart, region.end - seqStart)
|
|
105
|
+
: undefined;
|
|
106
|
+
// a short answer means the region runs off the end of the contig, and a
|
|
107
|
+
// reference row that stops early would misplace every column after it
|
|
108
|
+
sequence =
|
|
109
|
+
sliced?.length === region.end - region.start ? sliced : undefined;
|
|
110
|
+
}
|
|
111
|
+
const plan = planTviewMsa({
|
|
112
|
+
features,
|
|
113
|
+
refName: region.refName,
|
|
114
|
+
start: region.start,
|
|
115
|
+
end: region.end,
|
|
116
|
+
sequence,
|
|
117
|
+
sampleOf: i => sampleByIndex[i],
|
|
118
|
+
});
|
|
119
|
+
const shared = {
|
|
120
|
+
rowCount: plan.reads.length,
|
|
121
|
+
columnCount: plan.layout.totalColumns,
|
|
122
|
+
cellCount: plan.cellCount,
|
|
123
|
+
insertionWidths: plan.insertionWidths,
|
|
124
|
+
arraySpans: plan.arraySpans,
|
|
125
|
+
region: plan.region,
|
|
126
|
+
arrays: plan.arrays.map(a => ({
|
|
127
|
+
start: a.start,
|
|
128
|
+
end: a.end,
|
|
129
|
+
period: a.period,
|
|
130
|
+
unit: a.unit,
|
|
131
|
+
width: a.width,
|
|
132
|
+
copies: [...a.copiesByName.entries()],
|
|
133
|
+
lengths: [...a.lengthByName.entries()],
|
|
134
|
+
})),
|
|
135
|
+
subjectIndex: plan.subject
|
|
136
|
+
? plan.arrays.indexOf(plan.subject)
|
|
137
|
+
: undefined,
|
|
138
|
+
referenceName: plan.referenceName,
|
|
139
|
+
samples: plan.samples,
|
|
140
|
+
};
|
|
141
|
+
// the render is the expensive half and the only part bounded by rows x
|
|
142
|
+
// columns, so the size check happens before it rather than after
|
|
143
|
+
return plan.cellCount > maxCells
|
|
144
|
+
? { ...shared, msa: '', tooLarge: true }
|
|
145
|
+
: {
|
|
146
|
+
...shared,
|
|
147
|
+
msa: renderTviewMsa(plan),
|
|
148
|
+
tree: buildSampleTree(plan.reads),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=TviewGetPlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TviewGetPlan.js","sourceRoot":"","sources":["../../../src/LaunchTView/TviewGetPlanRpc/TviewGetPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAuEvD,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,aAAa,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,CAAA;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,QAAQ,CACrB,aAA4B,EAC5B,SAAiB,EACjB,aAAsC,EACtC,MAAc;IAEd,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,UAAU,CACtC,aAAa,EACb,SAAS,EACT,aAAa,CACd,CAAA;IACD,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,CAAC,IAA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
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/LaunchTView/TviewGetPlanRpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAIzC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,aAA4B;IACnE,aAAa,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,aAAa,CAAC,CAAC,CAAA;AACnE,CAAC"}
|
|
@@ -5,16 +5,100 @@
|
|
|
5
5
|
* shared event stops being readable. Aligning the inserted sequences against
|
|
6
6
|
* each other fixes that.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* There are two ways to do it, and which one applies is a property of the
|
|
9
|
+
* inserted sequence rather than a setting:
|
|
10
|
+
*
|
|
11
|
+
* - **Aperiodic** (`alignInsertions`): one center-star alignment over the whole
|
|
12
|
+
* inserted sequence. Right for a novel insertion, a mobile element, anything
|
|
13
|
+
* whose bases only make sense read straight through.
|
|
14
|
+
* - **Periodic** (`alignPeriodicInsertions`): a tandem array, where the whole
|
|
15
|
+
* inserted sequence is n copies of one unit. Aligning those base-to-base is
|
|
16
|
+
* both unaffordable and wrong — it is free to align copy 5 of one read to
|
|
17
|
+
* copy 3 of another, and the difference that matters (how many copies) ends
|
|
18
|
+
* up expressed as where the row stops. Aligning unit-to-unit instead puts
|
|
19
|
+
* copy k of every read in the same columns, so copy number reads as a count
|
|
20
|
+
* of blocks and a divergent copy stands out as a column inside its block.
|
|
21
|
+
*
|
|
22
|
+
* Both are local to one reference position: the insertion still occupies "as
|
|
23
|
+
* many columns as the widest gapped sequence", which is the only thing
|
|
24
|
+
* buildColumnToRefPos knows about, so the column <-> reference mapping is
|
|
25
|
+
* untouched either way.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* The smallest lag at which a sequence repeats, or undefined when it does not.
|
|
29
|
+
*
|
|
30
|
+
* Scanning up from 1 returns the true minimal period, which is what separates a
|
|
31
|
+
* tandem array from a homopolymer: `AAAA...` matches at every lag and comes back
|
|
32
|
+
* as 1, and a 30bp unit comes back as 30 rather than as 60 or 90.
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectPeriod(seq: string): number | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Majority base at each offset within the unit, over the whole-length copies of
|
|
37
|
+
* `seq`. The consensus is what every copy of every read is aligned to, so it has
|
|
38
|
+
* to be one fixed string for the site — deriving it per read would let two reads
|
|
39
|
+
* disagree about where a unit starts.
|
|
40
|
+
*/
|
|
41
|
+
export declare function consensusUnit(seq: string, period: number): string;
|
|
42
|
+
export interface PeriodicAlignment {
|
|
43
|
+
/** repeat unit length in bp */
|
|
44
|
+
period: number;
|
|
45
|
+
/** each distinct input mapped to a gapped version, all the same length */
|
|
46
|
+
gapped: Map<string, string>;
|
|
47
|
+
/** each distinct input mapped to its copy count */
|
|
48
|
+
copies: Map<string, number>;
|
|
49
|
+
/** columns each copy occupies, left to right; sums to the gapped length */
|
|
50
|
+
unitWidths: number[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Unit-per-block alignment of the sequences inserted at one reference position.
|
|
54
|
+
*
|
|
55
|
+
* Copy k of every sequence lands in the same block of columns, and a block is
|
|
56
|
+
* as wide as the widest version of that copy across the site, so a sequence with
|
|
57
|
+
* fewer copies runs out of blocks rather than drifting out of register. Returns
|
|
58
|
+
* undefined when the site is not a tandem array, or is too big to lay out this
|
|
59
|
+
* way; the caller falls back to `alignInsertions`.
|
|
60
|
+
*
|
|
61
|
+
* **Blocks are array order, not homology.** Copies are anchored at the left edge
|
|
62
|
+
* of the insertion and counted rightward, so block k is "the kth copy along",
|
|
63
|
+
* and arrays grow and shrink by unequal crossing over anywhere inside them —
|
|
64
|
+
* block 9 of a 12-copy allele and block 9 of a 20-copy allele need not be the
|
|
65
|
+
* same copy. What the layout does buy is that copies stay in register, so a
|
|
66
|
+
* single divergent copy shows up as a column instead of shifting every copy
|
|
67
|
+
* after it. Reading down one row is sound; reading across two is a hypothesis.
|
|
68
|
+
*/
|
|
69
|
+
export declare function alignPeriodicInsertions(seqs: string[]): PeriodicAlignment | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Unit-per-block alignment against a unit the caller already knows.
|
|
72
|
+
*
|
|
73
|
+
* Separated from `alignPeriodicInsertions` because where the unit comes from is
|
|
74
|
+
* the whole difference between the two ways of finding an array. Measured off
|
|
75
|
+
* the inserted sequences, it can only be derived from one of them — the longest,
|
|
76
|
+
* which is a guess that one chimeric read overturns for the whole site. Measured
|
|
77
|
+
* off the reference, it is a property of the locus, so every read is laid out
|
|
78
|
+
* against the same unit whatever the reads happen to be.
|
|
79
|
+
*/
|
|
80
|
+
export declare function alignToUnit(seqs: string[], consensus: string): PeriodicAlignment | undefined;
|
|
81
|
+
export interface InsertionAlignment {
|
|
82
|
+
/** each distinct input mapped to a gapped version, all of the same length */
|
|
83
|
+
gapped: Map<string, string>;
|
|
84
|
+
/** present when the site is a tandem array */
|
|
85
|
+
periodic?: PeriodicAlignment;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lay out the sequences inserted at one reference position, by whichever of the
|
|
89
|
+
* two alignments the sequence itself calls for. The single place that decision
|
|
90
|
+
* is made, so a caller reading the period cannot disagree with the layout it
|
|
91
|
+
* gets.
|
|
92
|
+
*
|
|
93
|
+
* A tandem array goes unit-per-block, which is both the readable answer and the
|
|
94
|
+
* affordable one — the size caps here are what the base-to-base alignment costs,
|
|
95
|
+
* and an expansion is always past them. Everything else gets the center-star
|
|
96
|
+
* alignment, or is left alone (`gapped` empty) when there is nothing to gain
|
|
97
|
+
* from a single distinct sequence, or the site is too large to be worth it.
|
|
12
98
|
*/
|
|
99
|
+
export declare function alignInsertionSite(seqs: string[]): InsertionAlignment;
|
|
13
100
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* same length. Returns an empty map when there is nothing to gain (a single
|
|
17
|
-
* distinct sequence) or when the site is too large to be worth aligning; the
|
|
18
|
-
* caller then keeps the sequences as-is and left-justifies them.
|
|
101
|
+
* The gapped sequences alone, for callers with no use for the period. Every
|
|
102
|
+
* decision lives in `alignInsertionSite`.
|
|
19
103
|
*/
|
|
20
104
|
export declare function alignInsertions(seqs: string[]): Map<string, string>;
|