@jbrowse/plugin-alignments 2.16.0 → 2.17.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/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +2 -3
- package/dist/AlignmentsFeatureDetail/Flags.js +2 -2
- package/dist/AlignmentsFeatureDetail/LinkedPairedAlignments.js +2 -2
- package/dist/AlignmentsFeatureDetail/SupplementaryAlignments.js +2 -2
- package/dist/AlignmentsFeatureDetail/getSAFeatures.js +2 -2
- package/dist/AlignmentsFeatureDetail/stateModelFactory.d.ts +1 -1
- package/dist/BamAdapter/BamAdapter.d.ts +3 -2
- package/dist/BamAdapter/BamAdapter.js +34 -11
- package/dist/BamAdapter/BamSlightlyLazyFeature.d.ts +3 -17
- package/dist/BamAdapter/BamSlightlyLazyFeature.js +42 -72
- package/dist/CramAdapter/CramAdapter.d.ts +4 -3
- package/dist/CramAdapter/CramAdapter.js +24 -7
- package/dist/CramAdapter/CramSlightlyLazyFeature.d.ts +21 -27
- package/dist/CramAdapter/CramSlightlyLazyFeature.js +74 -73
- package/dist/CramAdapter/util.d.ts +1 -10
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +1 -1
- package/dist/LinearAlignmentsDisplay/index.js +2 -2
- package/dist/LinearAlignmentsDisplay/{models/model.d.ts → model.d.ts} +6 -3
- package/dist/LinearAlignmentsDisplay/{models/model.js → model.js} +11 -7
- package/dist/LinearPileupDisplay/SharedLinearPileupDisplayMixin.d.ts +6 -27
- package/dist/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +43 -21
- package/dist/LinearPileupDisplay/components/ColorByTagDialog.d.ts +5 -4
- package/dist/LinearPileupDisplay/components/ColorByTagDialog.js +3 -1
- package/dist/LinearPileupDisplay/components/GroupByDialog.js +8 -6
- package/dist/LinearPileupDisplay/components/SortByTagDialog.js +6 -4
- package/dist/LinearPileupDisplay/model.d.ts +41 -45
- package/dist/LinearPileupDisplay/model.js +118 -41
- package/dist/LinearReadArcsDisplay/components/ReactComponent.js +1 -1
- package/dist/LinearReadArcsDisplay/model.d.ts +22 -21
- package/dist/LinearReadArcsDisplay/model.js +13 -14
- package/dist/LinearReadCloudDisplay/components/ReactComponent.js +1 -1
- package/dist/LinearReadCloudDisplay/model.d.ts +14 -22
- package/dist/LinearReadCloudDisplay/model.js +12 -13
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.js +49 -19
- package/dist/LinearSNPCoverageDisplay/index.js +3 -2
- package/dist/LinearSNPCoverageDisplay/{models/model.d.ts → model.d.ts} +3 -13
- package/dist/LinearSNPCoverageDisplay/{models/model.js → model.js} +71 -45
- package/dist/MismatchParser/cigarToMismatches.d.ts +3 -0
- package/dist/MismatchParser/cigarToMismatches.js +94 -0
- package/dist/MismatchParser/getNextRefPos.d.ts +4 -0
- package/dist/MismatchParser/getNextRefPos.js +40 -0
- package/dist/MismatchParser/index.d.ts +4 -29
- package/dist/MismatchParser/index.js +10 -321
- package/dist/MismatchParser/mdToMismatches.d.ts +3 -0
- package/dist/MismatchParser/mdToMismatches.js +80 -0
- package/dist/ModificationParser/index.d.ts +19 -0
- package/dist/ModificationParser/index.js +144 -0
- package/dist/PileupRPC/methods/GetGlobalValueForTag.js +1 -2
- package/dist/PileupRPC/methods/GetReducedFeatures.d.ts +1 -1
- package/dist/PileupRPC/methods/GetReducedFeatures.js +19 -16
- package/dist/PileupRPC/methods/GetVisibleModifications.d.ts +2 -1
- package/dist/PileupRPC/methods/GetVisibleModifications.js +9 -6
- package/dist/PileupRenderer/PileupLayoutSession.d.ts +8 -7
- package/dist/PileupRenderer/PileupRenderer.d.ts +6 -14
- package/dist/PileupRenderer/PileupRenderer.js +7 -5
- package/dist/PileupRenderer/renderAlignment.js +17 -4
- package/dist/PileupRenderer/renderAlignmentShape.js +102 -21
- package/dist/PileupRenderer/renderMethylation.d.ts +2 -1
- package/dist/PileupRenderer/renderMethylation.js +17 -9
- package/dist/PileupRenderer/renderMismatches.js +19 -19
- package/dist/PileupRenderer/renderModifications.d.ts +3 -2
- package/dist/PileupRenderer/renderModifications.js +31 -34
- package/dist/PileupRenderer/renderPerBaseLettering.d.ts +2 -1
- package/dist/PileupRenderer/renderPerBaseLettering.js +1 -3
- package/dist/PileupRenderer/renderPerBaseQuality.d.ts +2 -1
- package/dist/PileupRenderer/renderPerBaseQuality.js +1 -3
- package/dist/PileupRenderer/renderSoftClipping.js +6 -6
- package/dist/PileupRenderer/sortUtil.d.ts +2 -7
- package/dist/PileupRenderer/sortUtil.js +13 -13
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js +10 -5
- package/dist/SNPCoverageAdapter/generateCoverageBins.d.ts +13 -9
- package/dist/SNPCoverageAdapter/generateCoverageBins.js +269 -166
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +2 -1
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js +171 -54
- package/dist/shared/color.d.ts +0 -10
- package/dist/shared/color.js +1 -7
- package/{esm/shared → dist/shared/components}/BaseDisplayComponent.d.ts +2 -2
- package/{esm/shared → dist/shared/components}/FilterByTagDialog.d.ts +3 -3
- package/dist/shared/{FilterByTagDialog.js → components/FilterByTagDialog.js} +5 -1
- package/dist/shared/fetchChains.js +1 -2
- package/dist/shared/getMaximumModificationAtEachPosition.d.ts +8 -0
- package/dist/shared/getMaximumModificationAtEachPosition.js +42 -0
- package/dist/shared/getUniqueModifications.d.ts +14 -0
- package/dist/shared/getUniqueModifications.js +16 -0
- package/dist/shared/getUniqueTags.d.ts +15 -0
- package/dist/shared/getUniqueTags.js +18 -0
- package/dist/shared/types.d.ts +94 -0
- package/dist/shared/util.d.ts +8 -0
- package/dist/shared/util.js +26 -0
- package/dist/util.d.ts +7 -4
- package/dist/util.js +30 -30
- package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +2 -3
- package/esm/AlignmentsFeatureDetail/Flags.js +1 -1
- package/esm/AlignmentsFeatureDetail/LinkedPairedAlignments.js +1 -1
- package/esm/AlignmentsFeatureDetail/SupplementaryAlignments.js +1 -1
- package/esm/AlignmentsFeatureDetail/getSAFeatures.js +2 -2
- package/esm/AlignmentsFeatureDetail/stateModelFactory.d.ts +1 -1
- package/esm/BamAdapter/BamAdapter.d.ts +3 -2
- package/esm/BamAdapter/BamAdapter.js +31 -8
- package/esm/BamAdapter/BamSlightlyLazyFeature.d.ts +3 -17
- package/esm/BamAdapter/BamSlightlyLazyFeature.js +43 -73
- package/esm/CramAdapter/CramAdapter.d.ts +4 -3
- package/esm/CramAdapter/CramAdapter.js +22 -5
- package/esm/CramAdapter/CramSlightlyLazyFeature.d.ts +21 -27
- package/esm/CramAdapter/CramSlightlyLazyFeature.js +74 -73
- package/esm/CramAdapter/util.d.ts +1 -10
- package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +1 -1
- package/esm/LinearAlignmentsDisplay/index.js +2 -2
- package/esm/LinearAlignmentsDisplay/{models/model.d.ts → model.d.ts} +6 -3
- package/esm/LinearAlignmentsDisplay/{models/model.js → model.js} +11 -7
- package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.d.ts +6 -27
- package/esm/LinearPileupDisplay/SharedLinearPileupDisplayMixin.js +45 -23
- package/esm/LinearPileupDisplay/components/ColorByTagDialog.d.ts +5 -4
- package/esm/LinearPileupDisplay/components/ColorByTagDialog.js +3 -1
- package/esm/LinearPileupDisplay/components/GroupByDialog.js +8 -6
- package/esm/LinearPileupDisplay/components/SortByTagDialog.js +6 -4
- package/esm/LinearPileupDisplay/model.d.ts +41 -45
- package/esm/LinearPileupDisplay/model.js +119 -42
- package/esm/LinearReadArcsDisplay/components/ReactComponent.js +1 -1
- package/esm/LinearReadArcsDisplay/model.d.ts +22 -21
- package/esm/LinearReadArcsDisplay/model.js +14 -15
- package/esm/LinearReadCloudDisplay/components/ReactComponent.js +1 -1
- package/esm/LinearReadCloudDisplay/model.d.ts +14 -22
- package/esm/LinearReadCloudDisplay/model.js +13 -14
- package/esm/LinearSNPCoverageDisplay/components/Tooltip.js +49 -19
- package/esm/LinearSNPCoverageDisplay/index.js +3 -2
- package/esm/LinearSNPCoverageDisplay/{models/model.d.ts → model.d.ts} +3 -13
- package/esm/LinearSNPCoverageDisplay/{models/model.js → model.js} +72 -46
- package/esm/MismatchParser/cigarToMismatches.d.ts +3 -0
- package/esm/MismatchParser/cigarToMismatches.js +91 -0
- package/esm/MismatchParser/getNextRefPos.d.ts +4 -0
- package/esm/MismatchParser/getNextRefPos.js +37 -0
- package/esm/MismatchParser/index.d.ts +4 -29
- package/esm/MismatchParser/index.js +5 -311
- package/esm/MismatchParser/mdToMismatches.d.ts +3 -0
- package/esm/MismatchParser/mdToMismatches.js +77 -0
- package/esm/ModificationParser/index.d.ts +19 -0
- package/esm/ModificationParser/index.js +138 -0
- package/esm/PileupRPC/methods/GetGlobalValueForTag.js +1 -2
- package/esm/PileupRPC/methods/GetReducedFeatures.d.ts +1 -1
- package/esm/PileupRPC/methods/GetReducedFeatures.js +19 -16
- package/esm/PileupRPC/methods/GetVisibleModifications.d.ts +2 -1
- package/esm/PileupRPC/methods/GetVisibleModifications.js +9 -6
- package/esm/PileupRenderer/PileupLayoutSession.d.ts +8 -7
- package/esm/PileupRenderer/PileupRenderer.d.ts +6 -14
- package/esm/PileupRenderer/PileupRenderer.js +8 -6
- package/esm/PileupRenderer/renderAlignment.js +17 -4
- package/esm/PileupRenderer/renderAlignmentShape.js +102 -21
- package/esm/PileupRenderer/renderMethylation.d.ts +2 -1
- package/esm/PileupRenderer/renderMethylation.js +17 -9
- package/esm/PileupRenderer/renderMismatches.js +19 -19
- package/esm/PileupRenderer/renderModifications.d.ts +3 -2
- package/esm/PileupRenderer/renderModifications.js +30 -33
- package/esm/PileupRenderer/renderPerBaseLettering.d.ts +2 -1
- package/esm/PileupRenderer/renderPerBaseLettering.js +1 -3
- package/esm/PileupRenderer/renderPerBaseQuality.d.ts +2 -1
- package/esm/PileupRenderer/renderPerBaseQuality.js +1 -3
- package/esm/PileupRenderer/renderSoftClipping.js +6 -6
- package/esm/PileupRenderer/sortUtil.d.ts +2 -7
- package/esm/PileupRenderer/sortUtil.js +13 -13
- package/esm/SNPCoverageAdapter/SNPCoverageAdapter.js +10 -5
- package/esm/SNPCoverageAdapter/generateCoverageBins.d.ts +13 -9
- package/esm/SNPCoverageAdapter/generateCoverageBins.js +269 -166
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +2 -1
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.js +171 -54
- package/esm/shared/color.d.ts +0 -10
- package/esm/shared/color.js +0 -6
- package/{dist/shared → esm/shared/components}/BaseDisplayComponent.d.ts +2 -2
- package/{dist/shared → esm/shared/components}/FilterByTagDialog.d.ts +3 -3
- package/esm/shared/{FilterByTagDialog.js → components/FilterByTagDialog.js} +5 -1
- package/esm/shared/fetchChains.js +1 -2
- package/esm/shared/getMaximumModificationAtEachPosition.d.ts +8 -0
- package/esm/shared/getMaximumModificationAtEachPosition.js +39 -0
- package/esm/shared/getUniqueModifications.d.ts +14 -0
- package/esm/shared/getUniqueModifications.js +13 -0
- package/esm/shared/getUniqueTags.d.ts +15 -0
- package/esm/shared/getUniqueTags.js +15 -0
- package/esm/shared/types.d.ts +94 -0
- package/esm/shared/util.d.ts +8 -0
- package/esm/shared/util.js +23 -0
- package/esm/util.d.ts +7 -4
- package/esm/util.js +28 -27
- package/package.json +4 -4
- package/dist/LinearPileupDisplay/components/ColorByModificationsDialog.d.ts +0 -15
- package/dist/LinearPileupDisplay/components/ColorByModificationsDialog.js +0 -41
- package/dist/LinearPileupDisplay/components/ModificationsTable.d.ts +0 -4
- package/dist/LinearPileupDisplay/components/ModificationsTable.js +0 -28
- package/dist/SNPCoverageAdapter/util.d.ts +0 -25
- package/dist/shared/index.d.ts +0 -49
- package/dist/shared/index.js +0 -41
- package/esm/LinearPileupDisplay/components/ColorByModificationsDialog.d.ts +0 -15
- package/esm/LinearPileupDisplay/components/ColorByModificationsDialog.js +0 -36
- package/esm/LinearPileupDisplay/components/ModificationsTable.d.ts +0 -4
- package/esm/LinearPileupDisplay/components/ModificationsTable.js +0 -22
- package/esm/SNPCoverageAdapter/util.d.ts +0 -25
- package/esm/shared/index.d.ts +0 -49
- package/esm/shared/index.js +0 -36
- /package/dist/LinearAlignmentsDisplay/{models/alignmentsModel.d.ts → alignmentsModel.d.ts} +0 -0
- /package/dist/LinearAlignmentsDisplay/{models/alignmentsModel.js → alignmentsModel.js} +0 -0
- /package/dist/LinearAlignmentsDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/dist/LinearAlignmentsDisplay/{models/configSchema.js → configSchema.js} +0 -0
- /package/dist/LinearAlignmentsDisplay/{models/util.d.ts → util.d.ts} +0 -0
- /package/dist/LinearAlignmentsDisplay/{models/util.js → util.js} +0 -0
- /package/dist/LinearSNPCoverageDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/dist/LinearSNPCoverageDisplay/{models/configSchema.js → configSchema.js} +0 -0
- /package/dist/shared/{BaseDisplayComponent.js → components/BaseDisplayComponent.js} +0 -0
- /package/dist/shared/{renderSvg.d.ts → renderSvgUtil.d.ts} +0 -0
- /package/dist/shared/{renderSvg.js → renderSvgUtil.js} +0 -0
- /package/dist/{SNPCoverageAdapter/util.js → shared/types.js} +0 -0
- /package/esm/LinearAlignmentsDisplay/{models/alignmentsModel.d.ts → alignmentsModel.d.ts} +0 -0
- /package/esm/LinearAlignmentsDisplay/{models/alignmentsModel.js → alignmentsModel.js} +0 -0
- /package/esm/LinearAlignmentsDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/esm/LinearAlignmentsDisplay/{models/configSchema.js → configSchema.js} +0 -0
- /package/esm/LinearAlignmentsDisplay/{models/util.d.ts → util.d.ts} +0 -0
- /package/esm/LinearAlignmentsDisplay/{models/util.js → util.js} +0 -0
- /package/esm/LinearSNPCoverageDisplay/{models/configSchema.d.ts → configSchema.d.ts} +0 -0
- /package/esm/LinearSNPCoverageDisplay/{models/configSchema.js → configSchema.js} +0 -0
- /package/esm/shared/{BaseDisplayComponent.js → components/BaseDisplayComponent.js} +0 -0
- /package/esm/shared/{renderSvg.d.ts → renderSvgUtil.d.ts} +0 -0
- /package/esm/shared/{renderSvg.js → renderSvgUtil.js} +0 -0
- /package/esm/{SNPCoverageAdapter/util.js → shared/types.js} +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import { doesIntersect2, max, sum } from '@jbrowse/core/util';
|
|
2
|
+
// locals
|
|
3
|
+
import { parseCigar } from '../MismatchParser';
|
|
4
|
+
import { getMethBins } from '../ModificationParser';
|
|
5
|
+
import { getMaxProbModAtEachPosition } from '../shared/getMaximumModificationAtEachPosition';
|
|
4
6
|
function mismatchLen(mismatch) {
|
|
5
7
|
return !isInterbase(mismatch.type) ? mismatch.length : 1;
|
|
6
8
|
}
|
|
@@ -11,192 +13,293 @@ function inc(bin, strand, type, field) {
|
|
|
11
13
|
let thisBin = bin[type][field];
|
|
12
14
|
if (thisBin === undefined) {
|
|
13
15
|
thisBin = bin[type][field] = {
|
|
14
|
-
|
|
16
|
+
entryDepth: 0,
|
|
17
|
+
probabilities: [],
|
|
15
18
|
'-1': 0,
|
|
16
19
|
'0': 0,
|
|
17
20
|
'1': 0,
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
|
-
thisBin.
|
|
23
|
+
thisBin.entryDepth++;
|
|
21
24
|
thisBin[strand]++;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const fend = feature.get('end');
|
|
40
|
-
const fstrand = feature.get('strand');
|
|
41
|
-
const mismatches = feature.get('mismatches') || [];
|
|
42
|
-
for (let j = fstart; j < fend + 1; j++) {
|
|
43
|
-
const i = j - region.start;
|
|
44
|
-
if (i >= 0 && i < binMax) {
|
|
45
|
-
if (bins[i] === undefined) {
|
|
46
|
-
bins[i] = {
|
|
47
|
-
total: 0,
|
|
48
|
-
all: 0,
|
|
49
|
-
ref: 0,
|
|
26
|
+
function processDepth({ feature, bins, region, regionSequence, }) {
|
|
27
|
+
const fstart = feature.get('start');
|
|
28
|
+
const fend = feature.get('end');
|
|
29
|
+
const fstrand = feature.get('strand');
|
|
30
|
+
const regionLength = region.end - region.start;
|
|
31
|
+
for (let j = fstart; j < fend + 1; j++) {
|
|
32
|
+
const i = j - region.start;
|
|
33
|
+
if (i >= 0 && i < regionLength) {
|
|
34
|
+
if (bins[i] === undefined) {
|
|
35
|
+
bins[i] = {
|
|
36
|
+
depth: 0,
|
|
37
|
+
readsCounted: 0,
|
|
38
|
+
refbase: regionSequence[i],
|
|
39
|
+
ref: {
|
|
40
|
+
probabilities: [],
|
|
41
|
+
entryDepth: 0,
|
|
50
42
|
'-1': 0,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
0: 0,
|
|
44
|
+
1: 0,
|
|
45
|
+
},
|
|
46
|
+
snps: {},
|
|
47
|
+
mods: {},
|
|
48
|
+
nonmods: {},
|
|
49
|
+
delskips: {},
|
|
50
|
+
noncov: {},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (j !== fend) {
|
|
54
|
+
bins[i].depth++;
|
|
55
|
+
bins[i].readsCounted++;
|
|
56
|
+
bins[i].ref.entryDepth++;
|
|
57
|
+
bins[i].ref[fstrand]++;
|
|
65
58
|
}
|
|
66
59
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function processSNPs({ feature, region, bins, skipmap, }) {
|
|
63
|
+
var _a;
|
|
64
|
+
const fstart = feature.get('start');
|
|
65
|
+
const fstrand = feature.get('strand');
|
|
66
|
+
const mismatches = (_a = feature.get('mismatches')) !== null && _a !== void 0 ? _a : [];
|
|
67
|
+
// normal SNP based coloring
|
|
68
|
+
for (const mismatch of mismatches) {
|
|
69
|
+
const mstart = fstart + mismatch.start;
|
|
70
|
+
const mlen = mismatchLen(mismatch);
|
|
71
|
+
const mend = mstart + mlen;
|
|
72
|
+
for (let j = mstart; j < mstart + mlen; j++) {
|
|
73
|
+
const epos = j - region.start;
|
|
74
|
+
if (epos >= 0 && epos < bins.length) {
|
|
75
|
+
const bin = bins[epos];
|
|
76
|
+
const { base, type } = mismatch;
|
|
77
|
+
const interbase = isInterbase(type);
|
|
78
|
+
if (type === 'deletion' || type === 'skip') {
|
|
79
|
+
inc(bin, fstrand, 'delskips', type);
|
|
80
|
+
bin.depth--;
|
|
81
|
+
}
|
|
82
|
+
else if (!interbase) {
|
|
83
|
+
inc(bin, fstrand, 'snps', base);
|
|
84
|
+
bin.ref.entryDepth--;
|
|
85
|
+
bin.ref[fstrand]--;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
inc(bin, fstrand, 'noncov', type);
|
|
97
89
|
}
|
|
98
90
|
}
|
|
99
91
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
if (mismatch.type === 'skip') {
|
|
93
|
+
// for upper case XS and TS: reports the literal strand of the genomic
|
|
94
|
+
// transcript
|
|
95
|
+
const tags = feature.get('tags');
|
|
96
|
+
const xs = (tags === null || tags === void 0 ? void 0 : tags.XS) || (tags === null || tags === void 0 ? void 0 : tags.TS);
|
|
97
|
+
// for lower case ts from minimap2: genomic transcript flipped by read
|
|
98
|
+
// strand
|
|
99
|
+
const ts = tags === null || tags === void 0 ? void 0 : tags.ts;
|
|
100
|
+
const effectiveStrand = xs === '+'
|
|
101
|
+
? 1
|
|
102
|
+
: xs === '-'
|
|
103
|
+
? -1
|
|
104
|
+
: (ts === '+' ? 1 : xs === '-' ? -1 : 0) * fstrand;
|
|
105
|
+
const hash = `${mstart}_${mend}_${effectiveStrand}`;
|
|
106
|
+
if (skipmap[hash] === undefined) {
|
|
107
|
+
skipmap[hash] = {
|
|
108
|
+
feature: feature,
|
|
109
|
+
start: mstart,
|
|
110
|
+
end: mend,
|
|
111
|
+
strand: fstrand,
|
|
112
|
+
effectiveStrand,
|
|
113
|
+
score: 0,
|
|
114
|
+
};
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
116
|
+
skipmap[hash].score++;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function processReferenceCpGs({ feature, region, bins, regionSequence, }) {
|
|
121
|
+
var _a;
|
|
122
|
+
const fstart = feature.get('start');
|
|
123
|
+
const fend = feature.get('end');
|
|
124
|
+
const fstrand = feature.get('strand');
|
|
125
|
+
const seq = feature.get('seq');
|
|
126
|
+
const mismatches = (_a = feature.get('mismatches')) !== null && _a !== void 0 ? _a : [];
|
|
127
|
+
const r = regionSequence.toLowerCase();
|
|
128
|
+
if (seq) {
|
|
129
|
+
const cigarOps = parseCigar(feature.get('CIGAR'));
|
|
130
|
+
const { methBins, methProbs } = getMethBins(feature, cigarOps);
|
|
131
|
+
const dels = mismatches.filter(f => f.type === 'deletion');
|
|
132
|
+
// methylation based coloring takes into account both reference sequence
|
|
133
|
+
// CpG detection and reads
|
|
134
|
+
for (let i = 0; i < fend - fstart; i++) {
|
|
135
|
+
const j = i + fstart;
|
|
136
|
+
const l1 = r[j - region.start + 1];
|
|
137
|
+
const l2 = r[j - region.start + 2];
|
|
138
|
+
if (l1 === 'c' && l2 === 'g') {
|
|
139
|
+
const bin0 = bins[j - region.start];
|
|
140
|
+
const bin1 = bins[j - region.start + 1];
|
|
141
|
+
const b0 = methBins[i];
|
|
142
|
+
const b1 = methBins[i + 1];
|
|
143
|
+
const p0 = methProbs[i];
|
|
144
|
+
const p1 = methProbs[i + 1];
|
|
145
|
+
// color
|
|
146
|
+
if ((b0 && (p0 !== undefined ? p0 > 0.5 : true)) ||
|
|
147
|
+
(b1 && (p1 !== undefined ? p1 > 0.5 : true))) {
|
|
148
|
+
if (bin0) {
|
|
149
|
+
incWithProbabilities(bin0, fstrand, 'mods', 'cpg_meth', p0 || 0);
|
|
150
|
+
bin0.ref.entryDepth--;
|
|
151
|
+
bin0.ref[fstrand]--;
|
|
136
152
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
if (bin1) {
|
|
154
|
+
incWithProbabilities(bin1, fstrand, 'mods', 'cpg_meth', p1 || 0);
|
|
155
|
+
bin1.ref.entryDepth--;
|
|
156
|
+
bin1.ref[fstrand]--;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
if (bin0) {
|
|
161
|
+
if (!dels.some(d => doesIntersect2(j, j + 1, d.start + fstart, d.start + fstart + d.length))) {
|
|
162
|
+
incWithProbabilities(bin0, fstrand, 'nonmods', 'cpg_unmeth', 1 - (p0 || 0));
|
|
163
|
+
bin0.ref.entryDepth--;
|
|
164
|
+
bin0.ref[fstrand]--;
|
|
144
165
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
166
|
+
}
|
|
167
|
+
if (bin1) {
|
|
168
|
+
if (!dels.some(d => doesIntersect2(j + 1, j + 2, d.start + fstart, d.start + fstart + d.length))) {
|
|
169
|
+
incWithProbabilities(bin1, fstrand, 'nonmods', 'cpg_unmeth', 1 - (p1 || 0));
|
|
170
|
+
bin1.ref.entryDepth--;
|
|
171
|
+
bin1.ref[fstrand]--;
|
|
151
172
|
}
|
|
152
173
|
}
|
|
153
174
|
}
|
|
154
175
|
}
|
|
155
176
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function processModification({ feature, colorBy, region, bins, regionSequence, }) {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
const fstart = feature.get('start');
|
|
182
|
+
const fstrand = feature.get('strand');
|
|
183
|
+
const fend = feature.get('end');
|
|
184
|
+
const twoColor = (_a = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _a === void 0 ? void 0 : _a.twoColor;
|
|
185
|
+
const isolatedModification = (_b = colorBy === null || colorBy === void 0 ? void 0 : colorBy.modifications) === null || _b === void 0 ? void 0 : _b.isolatedModification;
|
|
186
|
+
(_c = getMaxProbModAtEachPosition(feature)) === null || _c === void 0 ? void 0 : _c.forEach(({ type, prob, allProbs }, pos) => {
|
|
187
|
+
if (isolatedModification && type !== isolatedModification) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const epos = pos + fstart - region.start;
|
|
191
|
+
if (epos >= 0 && epos < bins.length && pos + fstart < fend) {
|
|
192
|
+
if (bins[epos] === undefined) {
|
|
193
|
+
bins[epos] = {
|
|
194
|
+
depth: 0,
|
|
195
|
+
readsCounted: 0,
|
|
196
|
+
refbase: regionSequence[epos],
|
|
197
|
+
snps: {},
|
|
198
|
+
ref: {
|
|
199
|
+
probabilities: [],
|
|
200
|
+
entryDepth: 0,
|
|
201
|
+
'-1': 0,
|
|
202
|
+
0: 0,
|
|
203
|
+
1: 0,
|
|
204
|
+
},
|
|
205
|
+
mods: {},
|
|
206
|
+
nonmods: {},
|
|
207
|
+
delskips: {},
|
|
208
|
+
noncov: {},
|
|
209
|
+
};
|
|
184
210
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
strand: fstrand,
|
|
193
|
-
xs: getTag(feature, 'XS') || getTag(feature, 'TS'),
|
|
194
|
-
score: 0,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
skipmap[hash].score++;
|
|
211
|
+
const s = 1 - sum(allProbs);
|
|
212
|
+
const bin = bins[epos];
|
|
213
|
+
if (twoColor && s > max(allProbs)) {
|
|
214
|
+
incWithProbabilities(bin, fstrand, 'nonmods', `nonmod_${type}`, s);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
incWithProbabilities(bin, fstrand, 'mods', `mod_${type}`, prob);
|
|
198
218
|
}
|
|
199
219
|
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function incWithProbabilities(bin, strand, type, field, probability) {
|
|
223
|
+
let thisBin = bin[type][field];
|
|
224
|
+
if (thisBin === undefined) {
|
|
225
|
+
thisBin = bin[type][field] = {
|
|
226
|
+
entryDepth: 0,
|
|
227
|
+
probabilities: [],
|
|
228
|
+
'-1': 0,
|
|
229
|
+
'0': 0,
|
|
230
|
+
'1': 0,
|
|
231
|
+
};
|
|
200
232
|
}
|
|
201
|
-
|
|
233
|
+
thisBin.entryDepth++;
|
|
234
|
+
thisBin.probabilities.push(probability);
|
|
235
|
+
thisBin[strand]++;
|
|
236
|
+
}
|
|
237
|
+
export async function generateCoverageBins({ fetchSequence, features, region, opts, }) {
|
|
238
|
+
const { colorBy } = opts;
|
|
239
|
+
const skipmap = {};
|
|
240
|
+
const bins = [];
|
|
241
|
+
const start2 = Math.max(0, region.start - 1);
|
|
242
|
+
const diff = region.start - start2;
|
|
243
|
+
const regionSequence = (await fetchSequence({
|
|
244
|
+
...region,
|
|
245
|
+
start: start2,
|
|
246
|
+
end: region.end + 1,
|
|
247
|
+
})) || '';
|
|
248
|
+
for (const feature of features) {
|
|
249
|
+
processDepth({
|
|
250
|
+
feature,
|
|
251
|
+
bins,
|
|
252
|
+
region,
|
|
253
|
+
regionSequence: regionSequence.slice(diff),
|
|
254
|
+
});
|
|
255
|
+
if ((colorBy === null || colorBy === void 0 ? void 0 : colorBy.type) === 'modifications') {
|
|
256
|
+
processModification({
|
|
257
|
+
feature,
|
|
258
|
+
colorBy,
|
|
259
|
+
bins,
|
|
260
|
+
region,
|
|
261
|
+
regionSequence: regionSequence.slice(diff),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else if ((colorBy === null || colorBy === void 0 ? void 0 : colorBy.type) === 'methylation') {
|
|
265
|
+
processReferenceCpGs({
|
|
266
|
+
feature,
|
|
267
|
+
bins,
|
|
268
|
+
region,
|
|
269
|
+
regionSequence,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
processSNPs({ feature, skipmap, bins, region });
|
|
273
|
+
}
|
|
274
|
+
for (const bin of bins) {
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
276
|
+
if (bin) {
|
|
277
|
+
bin.mods = Object.fromEntries(Object.entries(bin.mods).map(([key, val]) => {
|
|
278
|
+
return [
|
|
279
|
+
key,
|
|
280
|
+
{
|
|
281
|
+
...val,
|
|
282
|
+
avgProbability: val.probabilities.length
|
|
283
|
+
? sum(val.probabilities) / val.probabilities.length
|
|
284
|
+
: undefined,
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
}));
|
|
288
|
+
bin.nonmods = Object.fromEntries(Object.entries(bin.nonmods).map(([key, val]) => {
|
|
289
|
+
return [
|
|
290
|
+
key,
|
|
291
|
+
{
|
|
292
|
+
...val,
|
|
293
|
+
avgProbability: val.probabilities.length
|
|
294
|
+
? sum(val.probabilities) / val.probabilities.length
|
|
295
|
+
: undefined,
|
|
296
|
+
},
|
|
297
|
+
];
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
bins,
|
|
303
|
+
skipmap,
|
|
304
|
+
};
|
|
202
305
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Feature } from '@jbrowse/core/util';
|
|
2
2
|
import { RenderArgsDeserialized as FeatureRenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType';
|
|
3
3
|
import { ScaleOpts, WiggleBaseRenderer } from '@jbrowse/plugin-wiggle';
|
|
4
|
+
import { ModificationTypeWithColor } from '../shared/types';
|
|
4
5
|
export interface RenderArgsDeserialized extends FeatureRenderArgsDeserialized {
|
|
5
6
|
bpPerPx: number;
|
|
6
7
|
height: number;
|
|
@@ -13,7 +14,7 @@ export interface RenderArgsDeserializedWithFeatures extends RenderArgsDeserializ
|
|
|
13
14
|
values: number[];
|
|
14
15
|
};
|
|
15
16
|
displayCrossHatches: boolean;
|
|
16
|
-
|
|
17
|
+
visibleModifications?: Record<string, ModificationTypeWithColor>;
|
|
17
18
|
}
|
|
18
19
|
export default class SNPCoverageRenderer extends WiggleBaseRenderer {
|
|
19
20
|
draw(ctx: CanvasRenderingContext2D, props: RenderArgsDeserializedWithFeatures): Promise<undefined>;
|