@jbrowse/plugin-alignments 4.0.4 → 4.1.3
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/esm/AlignmentsFeatureDetail/stateModelFactory.d.ts +1 -1
- package/esm/CramAdapter/CramSlightlyLazyFeature.d.ts +1 -1
- package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +2 -2
- package/esm/LinearPileupDisplay/components/GroupByDialog.js +127 -93
- package/esm/LinearReadArcsDisplay/model.d.ts +5 -0
- package/esm/LinearReadCloudDisplay/components/LinearReadCloudReactComponent.js +6 -7
- package/esm/LinearReadCloudDisplay/model.d.ts +5 -2
- package/esm/LinearReadCloudDisplay/model.js +4 -11
- package/esm/LinearReadCloudDisplay/renderSvg.js +4 -5
- package/esm/LinearSNPCoverageDisplay/model.js +2 -2
- package/esm/PileupRenderer/makeImageData.js +3 -4
- package/esm/RenderLinearReadArcsDisplayRPC/drawFeatsRPC.d.ts +2 -1
- package/esm/RenderLinearReadArcsDisplayRPC/drawFeatsRPC.js +3 -4
- package/esm/RenderLinearReadArcsDisplayRPC/executeRenderLinearReadArcsDisplay.js +5 -4
- package/esm/RenderLinearReadCloudDisplayRPC/RenderLinearReadCloudDisplay.d.ts +0 -1
- package/esm/RenderLinearReadCloudDisplayRPC/drawFeatsCloud.d.ts +3 -4
- package/esm/RenderLinearReadCloudDisplayRPC/drawFeatsCloud.js +7 -20
- package/esm/RenderLinearReadCloudDisplayRPC/drawFeatsCommon.d.ts +2 -2
- package/esm/RenderLinearReadCloudDisplayRPC/drawFeatsCommon.js +3 -3
- package/esm/RenderLinearReadCloudDisplayRPC/drawLongReadChains.d.ts +3 -2
- package/esm/RenderLinearReadCloudDisplayRPC/drawLongReadChains.js +3 -4
- package/esm/RenderLinearReadCloudDisplayRPC/drawPairChains.d.ts +3 -2
- package/esm/RenderLinearReadCloudDisplayRPC/drawPairChains.js +4 -5
- package/esm/RenderLinearReadCloudDisplayRPC/executeRenderLinearReadCloudDisplay.js +7 -6
- package/esm/SNPCoverageRenderer/buildClickMap.d.ts +5 -0
- package/esm/SNPCoverageRenderer/buildClickMap.js +17 -0
- package/esm/SNPCoverageRenderer/calculateModificationCounts.d.ts +1 -19
- package/esm/SNPCoverageRenderer/calculateModificationCounts.js +1 -6
- package/esm/SNPCoverageRenderer/constants.d.ts +12 -0
- package/esm/SNPCoverageRenderer/constants.js +12 -0
- package/esm/SNPCoverageRenderer/createInterbaseItem.d.ts +7 -0
- package/esm/SNPCoverageRenderer/createInterbaseItem.js +13 -0
- package/esm/SNPCoverageRenderer/drawCrossHatches.d.ts +3 -0
- package/esm/SNPCoverageRenderer/drawCrossHatches.js +10 -0
- package/esm/SNPCoverageRenderer/drawNoncovEvents.d.ts +3 -0
- package/esm/SNPCoverageRenderer/drawNoncovEvents.js +56 -0
- package/esm/SNPCoverageRenderer/drawSecondPassMethylation.d.ts +2 -0
- package/esm/SNPCoverageRenderer/drawSecondPassMethylation.js +30 -0
- package/esm/SNPCoverageRenderer/drawSecondPassModifications.d.ts +6 -0
- package/esm/SNPCoverageRenderer/drawSecondPassModifications.js +85 -0
- package/esm/SNPCoverageRenderer/drawSecondPassSNPs.d.ts +2 -0
- package/esm/SNPCoverageRenderer/drawSecondPassSNPs.js +64 -0
- package/esm/SNPCoverageRenderer/drawStackedBars.d.ts +3 -0
- package/esm/SNPCoverageRenderer/drawStackedBars.js +10 -0
- package/esm/SNPCoverageRenderer/makeImage.d.ts +1 -1
- package/esm/SNPCoverageRenderer/makeImage.js +10 -306
- package/esm/SNPCoverageRenderer/types.d.ts +62 -1
- package/esm/shared/LinearReadDisplayBaseMixin.d.ts +5 -0
- package/esm/shared/createRPCRenderingSetup.d.ts +1 -0
- package/esm/shared/createRPCRenderingSetup.js +6 -1
- package/esm/shared/menuItems.js +3 -3
- package/package.json +10 -9
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
import { scaleLog } from '@mui/x-charts-vendor/d3-scale';
|
|
2
2
|
export const CLOUD_HEIGHT_PADDING = 20;
|
|
3
3
|
const DEFAULT_MAX_DISTANCE = 1000;
|
|
4
|
-
export function createCloudScale(
|
|
4
|
+
export function createCloudScale(maxDistance, height) {
|
|
5
5
|
return scaleLog()
|
|
6
6
|
.base(2)
|
|
7
|
-
.domain([
|
|
7
|
+
.domain([1, Math.max(2, maxDistance)])
|
|
8
8
|
.range([0, height - CLOUD_HEIGHT_PADDING])
|
|
9
9
|
.clamp(true);
|
|
10
10
|
}
|
|
11
|
-
export function calculateCloudTicks(
|
|
12
|
-
const
|
|
13
|
-
const scale = createCloudScale(minDistance, maxDistance, height);
|
|
11
|
+
export function calculateCloudTicks(maxDistance, height) {
|
|
12
|
+
const scale = createCloudScale(maxDistance, height);
|
|
14
13
|
const tickValues = scale.ticks(6);
|
|
15
14
|
const ticks = tickValues.map(value => ({
|
|
16
15
|
value,
|
|
17
16
|
y: scale(value),
|
|
18
17
|
}));
|
|
19
|
-
return { ticks, height,
|
|
18
|
+
return { ticks, height, maxDistance };
|
|
20
19
|
}
|
|
21
|
-
export function calculateCloudYOffsetsUtil(computedChains, height
|
|
20
|
+
export function calculateCloudYOffsetsUtil(computedChains, height) {
|
|
22
21
|
const chainYOffsets = new Map();
|
|
23
|
-
if (cloudDomain) {
|
|
24
|
-
const [, maxDistance] = cloudDomain;
|
|
25
|
-
const scale = createCloudScale(1, maxDistance, height);
|
|
26
|
-
for (const { id, distance } of computedChains) {
|
|
27
|
-
const top = distance > 0 ? scale(distance) : 0;
|
|
28
|
-
chainYOffsets.set(id, top);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
chainYOffsets,
|
|
32
|
-
cloudMaxDistance: maxDistance,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
22
|
let maxDistance = Number.MIN_VALUE;
|
|
36
23
|
for (const { distance } of computedChains) {
|
|
37
24
|
if (distance > 0) {
|
|
@@ -41,7 +28,7 @@ export function calculateCloudYOffsetsUtil(computedChains, height, cloudDomain)
|
|
|
41
28
|
if (maxDistance === Number.MIN_VALUE) {
|
|
42
29
|
maxDistance = DEFAULT_MAX_DISTANCE;
|
|
43
30
|
}
|
|
44
|
-
const scale = createCloudScale(
|
|
31
|
+
const scale = createCloudScale(maxDistance, height);
|
|
45
32
|
for (const { id, distance } of computedChains) {
|
|
46
33
|
const top = distance > 0 ? scale(distance) : 0;
|
|
47
34
|
chainYOffsets.set(id, top);
|
|
@@ -3,7 +3,7 @@ import type { FlatbushItem } from '../PileupRenderer/types.ts';
|
|
|
3
3
|
import type { FlatbushEntry } from '../shared/flatbushType.ts';
|
|
4
4
|
import type { ChainData, ColorBy, ModificationTypeWithColor } from '../shared/types.ts';
|
|
5
5
|
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
6
|
-
import type { Feature } from '@jbrowse/core/util';
|
|
6
|
+
import type { Feature, LastStopTokenCheck } from '@jbrowse/core/util';
|
|
7
7
|
import type { BaseBlock } from '@jbrowse/core/util/blockTypes';
|
|
8
8
|
import type { ThemeOptions } from '@mui/material';
|
|
9
9
|
interface ViewForDrawing {
|
|
@@ -44,7 +44,7 @@ export interface DrawFeatsParams {
|
|
|
44
44
|
regions: BaseBlock[];
|
|
45
45
|
bpPerPx: number;
|
|
46
46
|
canvasWidth: number;
|
|
47
|
-
|
|
47
|
+
stopTokenCheck?: LastStopTokenCheck;
|
|
48
48
|
visibleModifications?: Record<string, ModificationTypeWithColor>;
|
|
49
49
|
hideSmallIndels?: boolean;
|
|
50
50
|
hideMismatches?: boolean;
|
|
@@ -176,7 +176,7 @@ export function addChainMouseoverRects(computedChains, chainYOffsets, featureHei
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
export function drawFeatsCore({ ctx, params, view, calculateYOffsets, }) {
|
|
179
|
-
const { chainData, featureHeight, colorBy, drawSingletons, drawProperPairs, flipStrandLongReadChains,
|
|
179
|
+
const { chainData, featureHeight, colorBy, drawSingletons, drawProperPairs, flipStrandLongReadChains, stopTokenCheck, } = params;
|
|
180
180
|
const type = colorBy.type || 'insertSizeAndOrientation';
|
|
181
181
|
const { chains } = chainData;
|
|
182
182
|
const filteredChains = filterChains(chains, drawSingletons, drawProperPairs, type, chainData);
|
|
@@ -210,7 +210,7 @@ export function drawFeatsCore({ ctx, params, view, calculateYOffsets, }) {
|
|
|
210
210
|
bpPerPx: params.bpPerPx,
|
|
211
211
|
colorBy: params.colorBy,
|
|
212
212
|
visibleModifications: params.visibleModifications,
|
|
213
|
-
|
|
213
|
+
stopTokenCheck,
|
|
214
214
|
hideSmallIndels: params.hideSmallIndels,
|
|
215
215
|
hideMismatches: params.hideMismatches,
|
|
216
216
|
hideLargeIndels: params.hideLargeIndels,
|
|
@@ -231,7 +231,7 @@ export function drawFeatsCore({ ctx, params, view, calculateYOffsets, }) {
|
|
|
231
231
|
bpPerPx: params.bpPerPx,
|
|
232
232
|
colorBy: params.colorBy,
|
|
233
233
|
visibleModifications: params.visibleModifications,
|
|
234
|
-
|
|
234
|
+
stopTokenCheck,
|
|
235
235
|
hideSmallIndels: params.hideSmallIndels,
|
|
236
236
|
hideMismatches: params.hideMismatches,
|
|
237
237
|
hideLargeIndels: params.hideLargeIndels,
|
|
@@ -2,9 +2,10 @@ import type { MismatchData } from './drawChainsUtil.ts';
|
|
|
2
2
|
import type { ComputedChain } from './drawFeatsCommon.ts';
|
|
3
3
|
import type { ChainData, ColorBy, ModificationTypeWithColor } from '../shared/types.ts';
|
|
4
4
|
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
5
|
+
import type { LastStopTokenCheck } from '@jbrowse/core/util';
|
|
5
6
|
import type { BaseBlock } from '@jbrowse/core/util/blockTypes';
|
|
6
7
|
import type { ThemeOptions } from '@mui/material';
|
|
7
|
-
export declare function drawLongReadChains({ ctx, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, flipStrandLongReadChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications,
|
|
8
|
+
export declare function drawLongReadChains({ ctx, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, flipStrandLongReadChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications, stopTokenCheck, hideSmallIndels, hideMismatches, hideLargeIndels, showOutline, }: {
|
|
8
9
|
ctx: CanvasRenderingContext2D;
|
|
9
10
|
chainData: ChainData;
|
|
10
11
|
chainYOffsets: Map<string, number>;
|
|
@@ -19,7 +20,7 @@ export declare function drawLongReadChains({ ctx, chainData, chainYOffsets, rend
|
|
|
19
20
|
bpPerPx: number;
|
|
20
21
|
colorBy: ColorBy;
|
|
21
22
|
visibleModifications?: Record<string, ModificationTypeWithColor>;
|
|
22
|
-
|
|
23
|
+
stopTokenCheck?: LastStopTokenCheck;
|
|
23
24
|
hideSmallIndels?: boolean;
|
|
24
25
|
hideMismatches?: boolean;
|
|
25
26
|
hideLargeIndels?: boolean;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { checkStopToken2
|
|
1
|
+
import { checkStopToken2 } from '@jbrowse/core/util/stopToken';
|
|
2
2
|
import { calculateFeaturePositionPx, featureOverlapsRegion, getChainBoundsOnRef, getConnectingLineColor, getMismatchRenderingConfig, getStrandColorKey, renderFeatureMismatchesAndModifications, renderFeatureShape, } from "./drawChainsUtil.js";
|
|
3
3
|
import { lineToCtx } from "../shared/canvasUtils.js";
|
|
4
4
|
import { fillColor, getSingletonColor, strokeColor } from "../shared/color.js";
|
|
5
5
|
import { getPrimaryStrandFromFlags } from "../shared/primaryStrand.js";
|
|
6
|
-
export function drawLongReadChains({ ctx, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, flipStrandLongReadChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications,
|
|
6
|
+
export function drawLongReadChains({ ctx, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, flipStrandLongReadChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications, stopTokenCheck, hideSmallIndels, hideMismatches, hideLargeIndels, showOutline, }) {
|
|
7
7
|
const mismatchConfig = getMismatchRenderingConfig(ctx, config, configTheme, colorBy, { hideSmallIndels, hideMismatches, hideLargeIndels });
|
|
8
8
|
const canvasWidth = region.widthPx;
|
|
9
9
|
const regionStart = region.start;
|
|
10
10
|
const allCoords = [];
|
|
11
11
|
const allItems = [];
|
|
12
|
-
const lastCheck = createStopTokenChecker(stopToken);
|
|
13
12
|
for (const computedChain of computedChains) {
|
|
14
|
-
checkStopToken2(
|
|
13
|
+
checkStopToken2(stopTokenCheck);
|
|
15
14
|
const { id, chain, isPairedEnd, nonSupplementary } = computedChain;
|
|
16
15
|
if (isPairedEnd) {
|
|
17
16
|
continue;
|
|
@@ -2,9 +2,10 @@ import type { MismatchData } from './drawChainsUtil.ts';
|
|
|
2
2
|
import type { ComputedChain } from './drawFeatsCommon.ts';
|
|
3
3
|
import type { ChainData, ColorBy, ModificationTypeWithColor } from '../shared/types.ts';
|
|
4
4
|
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
5
|
+
import type { LastStopTokenCheck } from '@jbrowse/core/util';
|
|
5
6
|
import type { BaseBlock } from '@jbrowse/core/util/blockTypes';
|
|
6
7
|
import type { ThemeOptions } from '@mui/material';
|
|
7
|
-
export declare function drawPairChains({ ctx, type, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications,
|
|
8
|
+
export declare function drawPairChains({ ctx, type, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications, stopTokenCheck, hideSmallIndels, hideMismatches, hideLargeIndels, showOutline, }: {
|
|
8
9
|
ctx: CanvasRenderingContext2D;
|
|
9
10
|
type: string;
|
|
10
11
|
chainData: ChainData;
|
|
@@ -19,7 +20,7 @@ export declare function drawPairChains({ ctx, type, chainData, chainYOffsets, re
|
|
|
19
20
|
bpPerPx: number;
|
|
20
21
|
colorBy: ColorBy;
|
|
21
22
|
visibleModifications?: Record<string, ModificationTypeWithColor>;
|
|
22
|
-
|
|
23
|
+
stopTokenCheck?: LastStopTokenCheck;
|
|
23
24
|
hideSmallIndels?: boolean;
|
|
24
25
|
hideMismatches?: boolean;
|
|
25
26
|
hideLargeIndels?: boolean;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { checkStopToken2
|
|
1
|
+
import { checkStopToken2 } from '@jbrowse/core/util/stopToken';
|
|
2
2
|
import { calculateFeaturePositionPx, featureOverlapsRegion, getChainBoundsOnRef, getConnectingLineColor, getMismatchRenderingConfig, renderFeatureMismatchesAndModifications, renderFeatureShape, } from "./drawChainsUtil.js";
|
|
3
3
|
import { lineToCtx } from "../shared/canvasUtils.js";
|
|
4
4
|
import { fillColor, getPairedColor, strokeColor } from "../shared/color.js";
|
|
5
|
-
export function drawPairChains({ ctx, type, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications,
|
|
5
|
+
export function drawPairChains({ ctx, type, chainData, chainYOffsets, renderChevrons, featureHeight, computedChains, config, theme: configTheme, region, regionStartPx, bpPerPx, colorBy, visibleModifications, stopTokenCheck, hideSmallIndels, hideMismatches, hideLargeIndels, showOutline, }) {
|
|
6
6
|
const mismatchConfig = getMismatchRenderingConfig(ctx, config, configTheme, colorBy, { hideSmallIndels, hideMismatches, hideLargeIndels });
|
|
7
7
|
const canvasWidth = region.widthPx;
|
|
8
8
|
const regionStart = region.start;
|
|
9
9
|
const allCoords = [];
|
|
10
10
|
const allItems = [];
|
|
11
|
-
const lastCheck = createStopTokenChecker(stopToken);
|
|
12
11
|
for (const computedChain of computedChains) {
|
|
13
|
-
checkStopToken2(
|
|
12
|
+
checkStopToken2(stopTokenCheck);
|
|
14
13
|
const { id, chain, isPairedEnd, nonSupplementary } = computedChain;
|
|
15
14
|
if (!isPairedEnd) {
|
|
16
15
|
continue;
|
|
@@ -89,7 +88,7 @@ export function drawPairChains({ ctx, type, chainData, chainYOffsets, renderChev
|
|
|
89
88
|
allItems,
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
|
-
checkStopToken2(
|
|
91
|
+
checkStopToken2(stopTokenCheck);
|
|
93
92
|
}
|
|
94
93
|
return { coords: allCoords, items: allItems };
|
|
95
94
|
}
|
|
@@ -3,7 +3,7 @@ import { collectTransferables, dedupe, groupBy, max, min, renderToAbstractCanvas
|
|
|
3
3
|
import { bpToPx } from '@jbrowse/core/util/Base1DUtils';
|
|
4
4
|
import Base1DView from '@jbrowse/core/util/Base1DViewModel';
|
|
5
5
|
import { rpcResult } from '@jbrowse/core/util/librpc';
|
|
6
|
-
import {
|
|
6
|
+
import { checkStopToken2, createStopTokenChecker, } from '@jbrowse/core/util/stopToken';
|
|
7
7
|
import { getSnapshot } from '@jbrowse/mobx-state-tree';
|
|
8
8
|
import { firstValueFrom } from 'rxjs';
|
|
9
9
|
import { toArray } from 'rxjs/operators';
|
|
@@ -12,7 +12,8 @@ import { computeChainBounds, drawFeatsCore, filterChains, sortComputedChains, }
|
|
|
12
12
|
import { calculateStackYOffsetsUtil } from "./drawFeatsStack.js";
|
|
13
13
|
import { getInsertSizeStats } from "../shared/insertSizeStats.js";
|
|
14
14
|
export async function executeRenderLinearReadCloudDisplay({ pluginManager, args, }) {
|
|
15
|
-
const { sessionId, view: viewSnapshot, adapterConfig, sequenceAdapter, config, theme, featureHeight, noSpacing, drawCloud, colorBy, drawSingletons, drawProperPairs, flipStrandLongReadChains, trackMaxHeight, cloudModeHeight,
|
|
15
|
+
const { sessionId, view: viewSnapshot, adapterConfig, sequenceAdapter, config, theme, featureHeight, noSpacing, drawCloud, colorBy, drawSingletons, drawProperPairs, flipStrandLongReadChains, trackMaxHeight, cloudModeHeight, highResolutionScaling, exportSVG, statusCallback = () => { }, stopToken, visibleModifications, hideSmallIndels, hideMismatches, hideLargeIndels, showOutline, } = args;
|
|
16
|
+
const stopTokenCheck = createStopTokenChecker(stopToken);
|
|
16
17
|
const view = Base1DView.create(viewSnapshot);
|
|
17
18
|
if (viewSnapshot.width) {
|
|
18
19
|
view.setVolatileWidth(viewSnapshot.width);
|
|
@@ -45,7 +46,7 @@ export async function executeRenderLinearReadCloudDisplay({ pluginManager, args,
|
|
|
45
46
|
dataAdapter.setSequenceAdapterConfig(sequenceAdapter);
|
|
46
47
|
}
|
|
47
48
|
const featuresArray = await updateStatus('Fetching alignments', statusCallback, () => firstValueFrom(dataAdapter.getFeaturesInMultipleRegions(regions, args).pipe(toArray())));
|
|
48
|
-
|
|
49
|
+
checkStopToken2(stopTokenCheck);
|
|
49
50
|
const deduped = dedupe(featuresArray, f => f.id());
|
|
50
51
|
const { chains, stats } = await updateStatus('Processing alignments', statusCallback, async () => {
|
|
51
52
|
const tlens = [];
|
|
@@ -74,7 +75,7 @@ export async function executeRenderLinearReadCloudDisplay({ pluginManager, args,
|
|
|
74
75
|
};
|
|
75
76
|
});
|
|
76
77
|
const chainData = { chains, stats };
|
|
77
|
-
|
|
78
|
+
checkStopToken2(stopTokenCheck);
|
|
78
79
|
const { computedChains } = await updateStatus('Calculating layout', statusCallback, async () => {
|
|
79
80
|
const filtered = filterChains(chains, drawSingletons, drawProperPairs, colorBy.type || 'insertSizeAndOrientation', chainData);
|
|
80
81
|
const computed = computeChainBounds(filtered, viewSnap);
|
|
@@ -115,7 +116,7 @@ export async function executeRenderLinearReadCloudDisplay({ pluginManager, args,
|
|
|
115
116
|
theme,
|
|
116
117
|
regions,
|
|
117
118
|
bpPerPx,
|
|
118
|
-
|
|
119
|
+
stopTokenCheck,
|
|
119
120
|
visibleModifications,
|
|
120
121
|
hideSmallIndels,
|
|
121
122
|
hideMismatches,
|
|
@@ -125,7 +126,7 @@ export async function executeRenderLinearReadCloudDisplay({ pluginManager, args,
|
|
|
125
126
|
view: viewSnap,
|
|
126
127
|
calculateYOffsets: (chains) => {
|
|
127
128
|
return drawCloud
|
|
128
|
-
? calculateCloudYOffsetsUtil(chains, actualHeight
|
|
129
|
+
? calculateCloudYOffsetsUtil(chains, actualHeight)
|
|
129
130
|
: calculateStackYOffsetsUtil(chains, featureHeight, noSpacing, trackMaxHeight ?? 1200);
|
|
130
131
|
},
|
|
131
132
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Flatbush from '@jbrowse/core/util/flatbush';
|
|
2
|
+
export function buildClickMap(coords, items) {
|
|
3
|
+
const flatbush = new Flatbush(Math.max(items.length, 1));
|
|
4
|
+
if (coords.length) {
|
|
5
|
+
for (let i = 0; i < coords.length; i += 4) {
|
|
6
|
+
flatbush.add(coords[i], coords[i + 1], coords[i + 2], coords[i + 3]);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
flatbush.add(0, 0);
|
|
11
|
+
}
|
|
12
|
+
flatbush.finish();
|
|
13
|
+
return {
|
|
14
|
+
flatbush: flatbush.data,
|
|
15
|
+
items,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
readonly entryDepth: number;
|
|
3
|
-
readonly '1': number;
|
|
4
|
-
readonly '-1': number;
|
|
5
|
-
readonly '0': number;
|
|
6
|
-
}
|
|
7
|
-
export interface ModificationCountsParams {
|
|
8
|
-
readonly base: string;
|
|
9
|
-
readonly isSimplex: boolean;
|
|
10
|
-
readonly refbase: string | undefined;
|
|
11
|
-
readonly snps: Readonly<Record<string, Partial<StrandCounts>>>;
|
|
12
|
-
readonly ref: StrandCounts;
|
|
13
|
-
readonly score0: number;
|
|
14
|
-
}
|
|
15
|
-
interface ModificationCountsResult {
|
|
16
|
-
readonly modifiable: number;
|
|
17
|
-
readonly detectable: number;
|
|
18
|
-
}
|
|
1
|
+
import type { ModificationCountsParams, ModificationCountsResult } from './types.ts';
|
|
19
2
|
export declare function calculateModificationCounts({ base, isSimplex, refbase, snps, ref, score0, }: ModificationCountsParams): ModificationCountsResult;
|
|
20
|
-
export {};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
C: 'G',
|
|
3
|
-
G: 'C',
|
|
4
|
-
A: 'T',
|
|
5
|
-
T: 'A',
|
|
6
|
-
};
|
|
1
|
+
import { complementBase } from "./constants.js";
|
|
7
2
|
export function calculateModificationCounts({ base, isSimplex, refbase, snps, ref, score0, }) {
|
|
8
3
|
if (base === 'N') {
|
|
9
4
|
return { modifiable: score0, detectable: score0 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const INTERBASE_INDICATOR_WIDTH = 7;
|
|
2
|
+
export declare const INTERBASE_INDICATOR_HEIGHT = 4.5;
|
|
3
|
+
export declare const MINIMUM_INTERBASE_INDICATOR_READ_DEPTH = 7;
|
|
4
|
+
export declare const INTERBASE_DRAW_THRESHOLD = 0.1;
|
|
5
|
+
export declare const complementBase: {
|
|
6
|
+
readonly C: "G";
|
|
7
|
+
readonly G: "C";
|
|
8
|
+
readonly A: "T";
|
|
9
|
+
readonly T: "A";
|
|
10
|
+
};
|
|
11
|
+
export declare const fudgeFactor = 0.6;
|
|
12
|
+
export declare const SNP_CLICKMAP_THRESHOLD = 0.04;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const INTERBASE_INDICATOR_WIDTH = 7;
|
|
2
|
+
export const INTERBASE_INDICATOR_HEIGHT = 4.5;
|
|
3
|
+
export const MINIMUM_INTERBASE_INDICATOR_READ_DEPTH = 7;
|
|
4
|
+
export const INTERBASE_DRAW_THRESHOLD = 0.1;
|
|
5
|
+
export const complementBase = {
|
|
6
|
+
C: 'G',
|
|
7
|
+
G: 'C',
|
|
8
|
+
A: 'T',
|
|
9
|
+
T: 'A',
|
|
10
|
+
};
|
|
11
|
+
export const fudgeFactor = 0.6;
|
|
12
|
+
export const SNP_CLICKMAP_THRESHOLD = 0.04;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InterbaseIndicatorItem } from './types.ts';
|
|
2
|
+
export declare function createInterbaseItem(maxBase: string, count: number, total: number, start: number, maxEntry?: {
|
|
3
|
+
avgLength?: number;
|
|
4
|
+
minLength?: number;
|
|
5
|
+
maxLength?: number;
|
|
6
|
+
topSequence?: string;
|
|
7
|
+
}): InterbaseIndicatorItem;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function createInterbaseItem(maxBase, count, total, start, maxEntry) {
|
|
2
|
+
return {
|
|
3
|
+
type: maxBase,
|
|
4
|
+
base: maxBase,
|
|
5
|
+
count,
|
|
6
|
+
total,
|
|
7
|
+
avgLength: maxEntry?.avgLength,
|
|
8
|
+
minLength: maxEntry?.minLength,
|
|
9
|
+
maxLength: maxEntry?.maxLength,
|
|
10
|
+
topSequence: maxEntry?.topSequence,
|
|
11
|
+
start,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function drawCrossHatches(ctx, ticks, width, toY) {
|
|
2
|
+
ctx.lineWidth = 1;
|
|
3
|
+
ctx.strokeStyle = 'rgba(140,140,140,0.8)';
|
|
4
|
+
for (const tick of ticks.values) {
|
|
5
|
+
ctx.beginPath();
|
|
6
|
+
ctx.moveTo(0, Math.round(toY(tick)));
|
|
7
|
+
ctx.lineTo(width, Math.round(toY(tick)));
|
|
8
|
+
ctx.stroke();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SecondPassContext } from './types.ts';
|
|
2
|
+
import type { BaseCoverageBin } from '../shared/types.ts';
|
|
3
|
+
export declare function drawNoncovEvents(passCtx: SecondPassContext, snpinfo: BaseCoverageBin, leftPx: number, score0: number, prevTotal: number, skipDraw: boolean, fstart: number): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { INTERBASE_DRAW_THRESHOLD, INTERBASE_INDICATOR_HEIGHT, INTERBASE_INDICATOR_WIDTH, MINIMUM_INTERBASE_INDICATOR_READ_DEPTH, } from "./constants.js";
|
|
2
|
+
import { createInterbaseItem } from "./createInterbaseItem.js";
|
|
3
|
+
export function drawNoncovEvents(passCtx, snpinfo, leftPx, score0, prevTotal, skipDraw, fstart) {
|
|
4
|
+
const { ctx, colorMap, toHeight2, extraHorizontallyFlippedOffset, coords, items, bpPerPx, indicatorThreshold, showInterbaseCounts, showInterbaseIndicators, } = passCtx;
|
|
5
|
+
let totalCount = 0;
|
|
6
|
+
let maxDepth = 0;
|
|
7
|
+
let maxBase = '';
|
|
8
|
+
let totalHeight = 0;
|
|
9
|
+
const r = 0.6;
|
|
10
|
+
const x = leftPx - r + extraHorizontallyFlippedOffset;
|
|
11
|
+
for (const base in snpinfo.noncov) {
|
|
12
|
+
const { entryDepth } = snpinfo.noncov[base];
|
|
13
|
+
totalCount += entryDepth;
|
|
14
|
+
if (entryDepth > maxDepth) {
|
|
15
|
+
maxDepth = entryDepth;
|
|
16
|
+
maxBase = base;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const isSignificant = score0 > 0 && totalCount > score0 * INTERBASE_DRAW_THRESHOLD;
|
|
20
|
+
const showCounts = showInterbaseCounts && (!skipDraw || isSignificant);
|
|
21
|
+
if (showCounts) {
|
|
22
|
+
for (const base in snpinfo.noncov) {
|
|
23
|
+
const { entryDepth } = snpinfo.noncov[base];
|
|
24
|
+
const barHeight = toHeight2(entryDepth);
|
|
25
|
+
ctx.fillStyle = colorMap[base];
|
|
26
|
+
ctx.fillRect(x, INTERBASE_INDICATOR_HEIGHT + totalHeight, r * 2, barHeight);
|
|
27
|
+
totalHeight += barHeight;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (totalCount > 0) {
|
|
31
|
+
const maxEntry = snpinfo.noncov[maxBase];
|
|
32
|
+
if (showCounts) {
|
|
33
|
+
if (bpPerPx < 50 || isSignificant) {
|
|
34
|
+
const clickWidth = Math.max(r * 2, 2);
|
|
35
|
+
coords.push(x, INTERBASE_INDICATOR_HEIGHT, x + clickWidth, INTERBASE_INDICATOR_HEIGHT + totalHeight);
|
|
36
|
+
items.push(createInterbaseItem(maxBase, totalCount, score0, fstart, maxEntry));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (showInterbaseIndicators && (!skipDraw || isSignificant)) {
|
|
40
|
+
const indicatorComparatorScore = Math.max(score0, prevTotal);
|
|
41
|
+
if (totalCount > indicatorComparatorScore * indicatorThreshold &&
|
|
42
|
+
indicatorComparatorScore > MINIMUM_INTERBASE_INDICATOR_READ_DEPTH) {
|
|
43
|
+
ctx.fillStyle = colorMap[maxBase];
|
|
44
|
+
ctx.beginPath();
|
|
45
|
+
const l = leftPx + extraHorizontallyFlippedOffset;
|
|
46
|
+
ctx.moveTo(l - INTERBASE_INDICATOR_WIDTH / 2, 0);
|
|
47
|
+
ctx.lineTo(l + INTERBASE_INDICATOR_WIDTH / 2, 0);
|
|
48
|
+
ctx.lineTo(l, INTERBASE_INDICATOR_HEIGHT);
|
|
49
|
+
ctx.fill();
|
|
50
|
+
const hitboxPadding = 1;
|
|
51
|
+
coords.push(l - INTERBASE_INDICATOR_WIDTH / 2 - hitboxPadding, 0, l + INTERBASE_INDICATOR_WIDTH / 2 + hitboxPadding, INTERBASE_INDICATOR_HEIGHT + hitboxPadding);
|
|
52
|
+
items.push(createInterbaseItem(maxBase, totalCount, indicatorComparatorScore, fstart, maxEntry));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { checkStopToken2, featureSpanPx } from '@jbrowse/core/util';
|
|
2
|
+
import { drawNoncovEvents } from "./drawNoncovEvents.js";
|
|
3
|
+
import { drawStackedBars } from "./drawStackedBars.js";
|
|
4
|
+
export function drawSecondPassMethylation(passCtx) {
|
|
5
|
+
const { ctx, coverageFeatures, region, bpPerPx, colorMap, toY, toHeight, stopTokenCheck, } = passCtx;
|
|
6
|
+
let snpDrawn = 0;
|
|
7
|
+
const snpSkipped = 0;
|
|
8
|
+
let lastDrawnX = Number.NEGATIVE_INFINITY;
|
|
9
|
+
let prevTotal = 0;
|
|
10
|
+
for (let i = 0, l = coverageFeatures.length; i < l; i++) {
|
|
11
|
+
checkStopToken2(stopTokenCheck);
|
|
12
|
+
const feature = coverageFeatures[i];
|
|
13
|
+
const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx);
|
|
14
|
+
const snpinfo = feature.get('snpinfo');
|
|
15
|
+
const w = Math.max(rightPx - leftPx, 1);
|
|
16
|
+
const score0 = feature.get('score');
|
|
17
|
+
const drawX = Math.round(leftPx);
|
|
18
|
+
const skipDraw = drawX === lastDrawnX;
|
|
19
|
+
const { depth, nonmods, mods } = snpinfo;
|
|
20
|
+
const h = toHeight(score0);
|
|
21
|
+
const bottom = toY(score0) + h;
|
|
22
|
+
const curr = drawStackedBars(ctx, mods, colorMap, drawX, bottom, w, h, depth, 0);
|
|
23
|
+
drawStackedBars(ctx, nonmods, colorMap, drawX, bottom, w, h, depth, curr);
|
|
24
|
+
snpDrawn++;
|
|
25
|
+
lastDrawnX = drawX;
|
|
26
|
+
drawNoncovEvents(passCtx, snpinfo, leftPx, score0, prevTotal, skipDraw, feature.get('start'));
|
|
27
|
+
prevTotal = score0;
|
|
28
|
+
}
|
|
29
|
+
return { snpDrawn, snpSkipped };
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SecondPassContext, SecondPassStats } from './types.ts';
|
|
2
|
+
export declare function drawSecondPassModifications(passCtx: SecondPassContext, visibleModifications: Record<string, {
|
|
3
|
+
base: string;
|
|
4
|
+
type: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
}>, isolatedModification: string | undefined, simplexSet: Set<string>): SecondPassStats;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { checkStopToken2, featureSpanPx } from '@jbrowse/core/util';
|
|
2
|
+
import { calculateModificationCounts } from "./calculateModificationCounts.js";
|
|
3
|
+
import { drawNoncovEvents } from "./drawNoncovEvents.js";
|
|
4
|
+
import { alphaColor } from "../shared/util.js";
|
|
5
|
+
export function drawSecondPassModifications(passCtx, visibleModifications, isolatedModification, simplexSet) {
|
|
6
|
+
const { ctx, coverageFeatures, region, bpPerPx, toY, toHeight, stopTokenCheck, } = passCtx;
|
|
7
|
+
let snpDrawn = 0;
|
|
8
|
+
let snpSkipped = 0;
|
|
9
|
+
let lastDrawnX = Number.NEGATIVE_INFINITY;
|
|
10
|
+
let prevTotal = 0;
|
|
11
|
+
for (let i = 0, l = coverageFeatures.length; i < l; i++) {
|
|
12
|
+
checkStopToken2(stopTokenCheck);
|
|
13
|
+
const feature = coverageFeatures[i];
|
|
14
|
+
const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx);
|
|
15
|
+
const snpinfo = feature.get('snpinfo');
|
|
16
|
+
const w = Math.max(rightPx - leftPx, 1);
|
|
17
|
+
const score0 = feature.get('score');
|
|
18
|
+
const drawX = Math.round(leftPx);
|
|
19
|
+
const skipDraw = drawX === lastDrawnX;
|
|
20
|
+
let curr = 0;
|
|
21
|
+
const refbase = snpinfo?.refbase?.toUpperCase();
|
|
22
|
+
const { nonmods, mods, snps, ref } = snpinfo || {};
|
|
23
|
+
const h = toHeight(score0);
|
|
24
|
+
const bottom = toY(score0) + h;
|
|
25
|
+
for (const key in nonmods) {
|
|
26
|
+
const modKey = key.slice(7);
|
|
27
|
+
const mod = visibleModifications[modKey];
|
|
28
|
+
if (!mod || (isolatedModification && mod.type !== isolatedModification)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const { modifiable, detectable } = calculateModificationCounts({
|
|
32
|
+
base: mod.base,
|
|
33
|
+
isSimplex: simplexSet.has(mod.type),
|
|
34
|
+
refbase,
|
|
35
|
+
snps: snps || {},
|
|
36
|
+
ref: ref || { entryDepth: 0, '1': 0, '-1': 0, '0': 0 },
|
|
37
|
+
score0,
|
|
38
|
+
});
|
|
39
|
+
const { entryDepth, avgProbability = 0 } = nonmods[key];
|
|
40
|
+
const modFraction = (modifiable / score0) * (entryDepth / detectable);
|
|
41
|
+
const barHeight = modFraction * h;
|
|
42
|
+
if (skipDraw) {
|
|
43
|
+
snpSkipped++;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
ctx.fillStyle = alphaColor('blue', avgProbability);
|
|
47
|
+
ctx.fillRect(drawX, bottom - (curr + barHeight), w, barHeight);
|
|
48
|
+
snpDrawn++;
|
|
49
|
+
lastDrawnX = drawX;
|
|
50
|
+
}
|
|
51
|
+
curr += barHeight;
|
|
52
|
+
}
|
|
53
|
+
for (const key in mods) {
|
|
54
|
+
const modKey = key.slice(4);
|
|
55
|
+
const mod = visibleModifications[modKey];
|
|
56
|
+
if (!mod || (isolatedModification && mod.type !== isolatedModification)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const { modifiable, detectable } = calculateModificationCounts({
|
|
60
|
+
base: mod.base,
|
|
61
|
+
isSimplex: simplexSet.has(mod.type),
|
|
62
|
+
refbase,
|
|
63
|
+
snps: snps || {},
|
|
64
|
+
ref: ref || { entryDepth: 0, '1': 0, '-1': 0, '0': 0 },
|
|
65
|
+
score0,
|
|
66
|
+
});
|
|
67
|
+
const { entryDepth, avgProbability = 0 } = mods[key];
|
|
68
|
+
const modFraction = (modifiable / score0) * (entryDepth / detectable);
|
|
69
|
+
const barHeight = modFraction * h;
|
|
70
|
+
if (skipDraw) {
|
|
71
|
+
snpSkipped++;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
ctx.fillStyle = alphaColor(mod.color || 'black', avgProbability);
|
|
75
|
+
ctx.fillRect(drawX, bottom - (curr + barHeight), w, barHeight);
|
|
76
|
+
snpDrawn++;
|
|
77
|
+
lastDrawnX = drawX;
|
|
78
|
+
}
|
|
79
|
+
curr += barHeight;
|
|
80
|
+
}
|
|
81
|
+
drawNoncovEvents(passCtx, snpinfo, leftPx, score0, prevTotal, skipDraw, feature.get('start'));
|
|
82
|
+
prevTotal = score0;
|
|
83
|
+
}
|
|
84
|
+
return { snpDrawn, snpSkipped };
|
|
85
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { checkStopToken2, featureSpanPx } from '@jbrowse/core/util';
|
|
2
|
+
import { SNP_CLICKMAP_THRESHOLD } from "./constants.js";
|
|
3
|
+
import { drawNoncovEvents } from "./drawNoncovEvents.js";
|
|
4
|
+
export function drawSecondPassSNPs(passCtx) {
|
|
5
|
+
const { ctx, coverageFeatures, region, bpPerPx, colorMap, toY, toHeight, stopTokenCheck, coords, items, } = passCtx;
|
|
6
|
+
let snpDrawn = 0;
|
|
7
|
+
let snpSkipped = 0;
|
|
8
|
+
let lastDrawnX = Number.NEGATIVE_INFINITY;
|
|
9
|
+
let lastDrawnDepth = -1;
|
|
10
|
+
let prevTotal = 0;
|
|
11
|
+
for (let i = 0, l = coverageFeatures.length; i < l; i++) {
|
|
12
|
+
checkStopToken2(stopTokenCheck);
|
|
13
|
+
const feature = coverageFeatures[i];
|
|
14
|
+
const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx);
|
|
15
|
+
const snpinfo = feature.get('snpinfo');
|
|
16
|
+
const w = Math.max(rightPx - leftPx, 1);
|
|
17
|
+
const score0 = feature.get('score');
|
|
18
|
+
const drawX = Math.round(leftPx);
|
|
19
|
+
const skipDraw = drawX === lastDrawnX;
|
|
20
|
+
const { depth, snps, refbase } = snpinfo;
|
|
21
|
+
const refbaseUpper = refbase?.toUpperCase();
|
|
22
|
+
const h = toHeight(score0);
|
|
23
|
+
const bottom = toY(score0) + h;
|
|
24
|
+
let curr = 0;
|
|
25
|
+
for (const base in snps) {
|
|
26
|
+
const entry = snps[base];
|
|
27
|
+
const { entryDepth } = entry;
|
|
28
|
+
const y1 = bottom - ((entryDepth + curr) / depth) * h;
|
|
29
|
+
const barHeight = (entryDepth / depth) * h;
|
|
30
|
+
const isSignificant = entryDepth / score0 >= SNP_CLICKMAP_THRESHOLD;
|
|
31
|
+
const sameDepthAtSameX = skipDraw && entryDepth === lastDrawnDepth;
|
|
32
|
+
if ((skipDraw && !isSignificant) || sameDepthAtSameX) {
|
|
33
|
+
snpSkipped++;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
ctx.fillStyle = colorMap[base] || 'black';
|
|
37
|
+
ctx.fillRect(drawX, y1, w, barHeight);
|
|
38
|
+
snpDrawn++;
|
|
39
|
+
lastDrawnX = drawX;
|
|
40
|
+
lastDrawnDepth = entryDepth;
|
|
41
|
+
}
|
|
42
|
+
if (isSignificant) {
|
|
43
|
+
coords.push(drawX, y1, drawX + w, y1 + barHeight);
|
|
44
|
+
items.push({
|
|
45
|
+
type: 'snp',
|
|
46
|
+
base,
|
|
47
|
+
count: entryDepth,
|
|
48
|
+
total: score0,
|
|
49
|
+
refbase: refbaseUpper,
|
|
50
|
+
avgQual: entry.avgProbability,
|
|
51
|
+
fwdCount: entry['1'] || 0,
|
|
52
|
+
revCount: entry['-1'] || 0,
|
|
53
|
+
bin: snpinfo,
|
|
54
|
+
start: feature.get('start'),
|
|
55
|
+
end: feature.get('end'),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
curr += entryDepth;
|
|
59
|
+
}
|
|
60
|
+
drawNoncovEvents(passCtx, snpinfo, leftPx, score0, prevTotal, skipDraw, feature.get('start'));
|
|
61
|
+
prevTotal = score0;
|
|
62
|
+
}
|
|
63
|
+
return { snpDrawn, snpSkipped };
|
|
64
|
+
}
|