@jbrowse/plugin-variants 3.0.0 → 3.0.2
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/MultiLinearVariantDisplay/components/Crosshair.js +1 -1
- package/dist/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +1 -1
- package/dist/MultiLinearVariantDisplay/model.d.ts +7 -7
- package/dist/MultiLinearVariantDisplay/renderSvg.js +1 -1
- package/dist/MultiLinearVariantMatrixDisplay/components/Crosshair.js +1 -1
- package/dist/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +1 -1
- package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +7 -7
- package/dist/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
- package/dist/MultiLinearVariantMatrixRenderer/LinearVariantMatrixRenderer.js +5 -5
- package/dist/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +6 -3
- package/dist/MultiLinearVariantMatrixRenderer/makeImageData.js +58 -68
- package/dist/MultiLinearVariantMatrixRenderer/types.d.ts +2 -1
- package/dist/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +1 -1
- package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.d.ts +22 -0
- package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.js +52 -0
- package/dist/MultiLinearVariantRenderer/index.js +1 -1
- package/dist/MultiLinearVariantRenderer/makeImageData.js +13 -21
- package/dist/MultiLinearVariantRenderer/types.d.ts +1 -1
- package/dist/MultiVariantBaseRenderer.d.ts +5 -5
- package/dist/VariantRPC/MultiVariantGetGenotypeMatrix.js +4 -4
- package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +1 -1
- package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.js +9 -9
- package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +6 -3
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +13 -13
- package/dist/getMultiVariantFeaturesAutorun.d.ts +1 -1
- package/dist/getMultiVariantSourcesAutorun.d.ts +1 -1
- package/dist/shared/MultiVariantBaseModel.d.ts +1 -1
- package/dist/shared/MultiVariantBaseModel.js +4 -4
- package/dist/shared/{SourcesGridHeader.js → components/SourcesGridHeader.js} +5 -5
- package/dist/shared/constants.d.ts +2 -0
- package/dist/shared/constants.js +5 -0
- package/dist/shared/drawAlleleCount.d.ts +1 -0
- package/dist/shared/{multiVariantColor.js → drawAlleleCount.js} +7 -14
- package/dist/shared/drawPhased.d.ts +1 -0
- package/dist/shared/drawPhased.js +21 -0
- package/dist/shared/findSecondLargestNumber.d.ts +0 -0
- package/dist/shared/findSecondLargestNumber.js +1 -0
- package/dist/shared/minorAlleleFrequencyUtils.d.ts +11 -0
- package/dist/shared/minorAlleleFrequencyUtils.js +62 -0
- package/dist/shared/sourcesGridUtils.d.ts +10 -0
- package/dist/shared/sourcesGridUtils.js +32 -0
- package/dist/shared/util.d.ts +3 -10
- package/dist/shared/util.js +23 -26
- package/dist/util.d.ts +0 -8
- package/dist/util.js +0 -85
- package/esm/MultiLinearVariantDisplay/components/Crosshair.js +1 -1
- package/esm/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +1 -1
- package/esm/MultiLinearVariantDisplay/model.d.ts +7 -7
- package/esm/MultiLinearVariantDisplay/renderSvg.js +1 -1
- package/esm/MultiLinearVariantMatrixDisplay/components/Crosshair.js +1 -1
- package/esm/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +1 -1
- package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +7 -7
- package/esm/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
- package/esm/MultiLinearVariantMatrixRenderer/LinearVariantMatrixRenderer.js +5 -5
- package/esm/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +6 -3
- package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +56 -66
- package/esm/MultiLinearVariantMatrixRenderer/types.d.ts +2 -1
- package/esm/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +1 -1
- package/esm/MultiLinearVariantRenderer/components/MultiVariantRendering.d.ts +22 -0
- package/esm/MultiLinearVariantRenderer/components/MultiVariantRendering.js +47 -0
- package/esm/MultiLinearVariantRenderer/index.js +1 -1
- package/esm/MultiLinearVariantRenderer/makeImageData.js +6 -14
- package/esm/MultiLinearVariantRenderer/types.d.ts +1 -1
- package/esm/MultiVariantBaseRenderer.d.ts +5 -5
- package/esm/VariantRPC/MultiVariantGetGenotypeMatrix.js +3 -3
- package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +1 -1
- package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.js +8 -8
- package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +6 -3
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js +13 -13
- package/esm/getMultiVariantFeaturesAutorun.d.ts +1 -1
- package/esm/getMultiVariantSourcesAutorun.d.ts +1 -1
- package/esm/shared/MultiVariantBaseModel.d.ts +1 -1
- package/esm/shared/MultiVariantBaseModel.js +4 -4
- package/esm/shared/{SourcesGridHeader.js → components/SourcesGridHeader.js} +1 -1
- package/esm/shared/constants.d.ts +2 -0
- package/esm/shared/constants.js +2 -0
- package/esm/shared/drawAlleleCount.d.ts +1 -0
- package/esm/shared/{multiVariantColor.js → drawAlleleCount.js} +6 -11
- package/esm/shared/drawPhased.d.ts +1 -0
- package/esm/shared/drawPhased.js +18 -0
- package/esm/shared/findSecondLargestNumber.d.ts +0 -0
- package/esm/shared/findSecondLargestNumber.js +1 -0
- package/esm/shared/minorAlleleFrequencyUtils.d.ts +11 -0
- package/esm/shared/minorAlleleFrequencyUtils.js +56 -0
- package/esm/shared/sourcesGridUtils.d.ts +10 -0
- package/esm/shared/sourcesGridUtils.js +28 -0
- package/esm/shared/util.d.ts +3 -10
- package/esm/shared/util.js +20 -24
- package/esm/util.d.ts +0 -8
- package/esm/util.js +1 -77
- package/package.json +11 -11
- package/dist/shared/multiVariantColor.d.ts +0 -3
- package/esm/shared/multiVariantColor.d.ts +0 -3
- /package/dist/shared/{BulkEditPanel.d.ts → components/BulkEditPanel.d.ts} +0 -0
- /package/dist/shared/{BulkEditPanel.js → components/BulkEditPanel.js} +0 -0
- /package/dist/shared/{ClusterDialog.d.ts → components/ClusterDialog.d.ts} +0 -0
- /package/dist/shared/{ClusterDialog.js → components/ClusterDialog.js} +0 -0
- /package/dist/shared/{ColorLegend.d.ts → components/ColorLegend.d.ts} +0 -0
- /package/dist/shared/{ColorLegend.js → components/ColorLegend.js} +0 -0
- /package/dist/shared/{HelpfulTips.d.ts → components/HelpfulTips.d.ts} +0 -0
- /package/dist/shared/{HelpfulTips.js → components/HelpfulTips.js} +0 -0
- /package/dist/shared/{LegendBar.d.ts → components/LegendBar.d.ts} +0 -0
- /package/dist/shared/{LegendBar.js → components/LegendBar.js} +0 -0
- /package/dist/shared/{MAFFilterDialog.d.ts → components/MAFFilterDialog.d.ts} +0 -0
- /package/dist/shared/{MAFFilterDialog.js → components/MAFFilterDialog.js} +0 -0
- /package/dist/shared/{MultiVariantTooltip.d.ts → components/MultiVariantTooltip.d.ts} +0 -0
- /package/dist/shared/{MultiVariantTooltip.js → components/MultiVariantTooltip.js} +0 -0
- /package/dist/shared/{RectBg.d.ts → components/RectBg.d.ts} +0 -0
- /package/dist/shared/{RectBg.js → components/RectBg.js} +0 -0
- /package/dist/shared/{RowPalettizer.d.ts → components/RowPalettizer.d.ts} +0 -0
- /package/dist/shared/{RowPalettizer.js → components/RowPalettizer.js} +0 -0
- /package/dist/shared/{SetColorDialog.d.ts → components/SetColorDialog.d.ts} +0 -0
- /package/dist/shared/{SetColorDialog.js → components/SetColorDialog.js} +0 -0
- /package/dist/shared/{SetMinMaxDialog.d.ts → components/SetMinMaxDialog.d.ts} +0 -0
- /package/dist/shared/{SetMinMaxDialog.js → components/SetMinMaxDialog.js} +0 -0
- /package/dist/shared/{SetRowHeightDialog.d.ts → components/SetRowHeightDialog.d.ts} +0 -0
- /package/dist/shared/{SetRowHeightDialog.js → components/SetRowHeightDialog.js} +0 -0
- /package/dist/shared/{SourcesDataGrid.d.ts → components/SourcesDataGrid.d.ts} +0 -0
- /package/dist/shared/{SourcesDataGrid.js → components/SourcesDataGrid.js} +0 -0
- /package/dist/shared/{SourcesGrid.d.ts → components/SourcesGrid.d.ts} +0 -0
- /package/dist/shared/{SourcesGrid.js → components/SourcesGrid.js} +0 -0
- /package/dist/shared/{SourcesGridHeader.d.ts → components/SourcesGridHeader.d.ts} +0 -0
- /package/dist/{types.d.ts → shared/types.d.ts} +0 -0
- /package/dist/{types.js → shared/types.js} +0 -0
- /package/esm/shared/{BulkEditPanel.d.ts → components/BulkEditPanel.d.ts} +0 -0
- /package/esm/shared/{BulkEditPanel.js → components/BulkEditPanel.js} +0 -0
- /package/esm/shared/{ClusterDialog.d.ts → components/ClusterDialog.d.ts} +0 -0
- /package/esm/shared/{ClusterDialog.js → components/ClusterDialog.js} +0 -0
- /package/esm/shared/{ColorLegend.d.ts → components/ColorLegend.d.ts} +0 -0
- /package/esm/shared/{ColorLegend.js → components/ColorLegend.js} +0 -0
- /package/esm/shared/{HelpfulTips.d.ts → components/HelpfulTips.d.ts} +0 -0
- /package/esm/shared/{HelpfulTips.js → components/HelpfulTips.js} +0 -0
- /package/esm/shared/{LegendBar.d.ts → components/LegendBar.d.ts} +0 -0
- /package/esm/shared/{LegendBar.js → components/LegendBar.js} +0 -0
- /package/esm/shared/{MAFFilterDialog.d.ts → components/MAFFilterDialog.d.ts} +0 -0
- /package/esm/shared/{MAFFilterDialog.js → components/MAFFilterDialog.js} +0 -0
- /package/esm/shared/{MultiVariantTooltip.d.ts → components/MultiVariantTooltip.d.ts} +0 -0
- /package/esm/shared/{MultiVariantTooltip.js → components/MultiVariantTooltip.js} +0 -0
- /package/esm/shared/{RectBg.d.ts → components/RectBg.d.ts} +0 -0
- /package/esm/shared/{RectBg.js → components/RectBg.js} +0 -0
- /package/esm/shared/{RowPalettizer.d.ts → components/RowPalettizer.d.ts} +0 -0
- /package/esm/shared/{RowPalettizer.js → components/RowPalettizer.js} +0 -0
- /package/esm/shared/{SetColorDialog.d.ts → components/SetColorDialog.d.ts} +0 -0
- /package/esm/shared/{SetColorDialog.js → components/SetColorDialog.js} +0 -0
- /package/esm/shared/{SetMinMaxDialog.d.ts → components/SetMinMaxDialog.d.ts} +0 -0
- /package/esm/shared/{SetMinMaxDialog.js → components/SetMinMaxDialog.js} +0 -0
- /package/esm/shared/{SetRowHeightDialog.d.ts → components/SetRowHeightDialog.d.ts} +0 -0
- /package/esm/shared/{SetRowHeightDialog.js → components/SetRowHeightDialog.js} +0 -0
- /package/esm/shared/{SourcesDataGrid.d.ts → components/SourcesDataGrid.d.ts} +0 -0
- /package/esm/shared/{SourcesDataGrid.js → components/SourcesDataGrid.js} +0 -0
- /package/esm/shared/{SourcesGrid.d.ts → components/SourcesGrid.d.ts} +0 -0
- /package/esm/shared/{SourcesGrid.js → components/SourcesGrid.js} +0 -0
- /package/esm/shared/{SourcesGridHeader.d.ts → components/SourcesGridHeader.d.ts} +0 -0
- /package/esm/{types.d.ts → shared/types.d.ts} +0 -0
- /package/esm/{types.js → shared/types.js} +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { set1 } from '@jbrowse/core/ui/colors';
|
|
2
1
|
import { colord } from '@jbrowse/core/util/colord';
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { f2 } from './constants';
|
|
3
|
+
function getColorAlleleCount(alleles, mostFrequentAlt) {
|
|
5
4
|
const total = alleles.length;
|
|
6
5
|
let alt = 0;
|
|
7
6
|
let uncalled = 0;
|
|
8
7
|
let alt2 = 0;
|
|
9
8
|
let ref = 0;
|
|
10
9
|
for (const allele of alleles) {
|
|
11
|
-
if (allele ===
|
|
10
|
+
if (allele === mostFrequentAlt) {
|
|
12
11
|
alt++;
|
|
13
12
|
}
|
|
14
13
|
else if (allele === '0') {
|
|
@@ -35,11 +34,7 @@ export function getColorAlleleCount(alleles) {
|
|
|
35
34
|
return a1.toHex();
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
export function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
export function getColorPhasedWithPhaseSet(alleles, HP, PS) {
|
|
43
|
-
const c = +alleles[HP];
|
|
44
|
-
return c ? colorify(+PS) || 'black' : '#ccc';
|
|
37
|
+
export function drawColorAlleleCount(alleles, ctx, x, y, w, h, mostFrequentAlt) {
|
|
38
|
+
ctx.fillStyle = getColorAlleleCount(alleles, mostFrequentAlt);
|
|
39
|
+
ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
|
|
45
40
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function drawPhased(alleles: string[], ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, HP: number, PS?: string): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { set1 } from '@jbrowse/core/ui/colors';
|
|
2
|
+
import { f2 } from './constants';
|
|
3
|
+
import { colorify } from './util';
|
|
4
|
+
function getColorPhased(alleles, HP) {
|
|
5
|
+
const c = +alleles[HP];
|
|
6
|
+
return c ? set1[c - 1] || 'black' : '#ccc';
|
|
7
|
+
}
|
|
8
|
+
function getColorPhasedWithPhaseSet(alleles, HP, PS) {
|
|
9
|
+
const c = +alleles[HP];
|
|
10
|
+
return c ? colorify(+PS) || 'black' : '#ccc';
|
|
11
|
+
}
|
|
12
|
+
export function drawPhased(alleles, ctx, x, y, w, h, HP, PS) {
|
|
13
|
+
ctx.fillStyle =
|
|
14
|
+
PS !== undefined
|
|
15
|
+
? getColorPhasedWithPhaseSet(alleles, HP, PS)
|
|
16
|
+
: getColorPhased(alleles, HP);
|
|
17
|
+
ctx.fillRect(x - f2, y - f2, w + f2, h + f2);
|
|
18
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Feature } from '@jbrowse/core/util';
|
|
2
|
+
export declare function findSecondLargestNumber(arr: Iterable<number>): number;
|
|
3
|
+
export declare function calculateAlleleCounts(feat: Feature): {
|
|
4
|
+
alleleCounts: Map<any, any>;
|
|
5
|
+
mostFrequentAlt: any;
|
|
6
|
+
};
|
|
7
|
+
export declare function calculateMinorAlleleFrequency(alleleCounts: Map<string, number>): number;
|
|
8
|
+
export declare function getFeaturesThatPassMinorAlleleFrequencyFilter(feats: Iterable<Feature>, minorAlleleFrequencyFilter: number): {
|
|
9
|
+
feature: Feature;
|
|
10
|
+
mostFrequentAlt: string;
|
|
11
|
+
}[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { sum } from '@jbrowse/core/util';
|
|
2
|
+
export function findSecondLargestNumber(arr) {
|
|
3
|
+
let firstMax = 0;
|
|
4
|
+
let secondMax = 0;
|
|
5
|
+
for (const num of arr) {
|
|
6
|
+
if (num > firstMax) {
|
|
7
|
+
secondMax = firstMax;
|
|
8
|
+
firstMax = num;
|
|
9
|
+
}
|
|
10
|
+
else if (num > secondMax && num !== firstMax) {
|
|
11
|
+
secondMax = num;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return secondMax;
|
|
15
|
+
}
|
|
16
|
+
export function calculateAlleleCounts(feat) {
|
|
17
|
+
const samp = feat.get('genotypes');
|
|
18
|
+
const alleleCounts = new Map();
|
|
19
|
+
for (const val of Object.values(samp)) {
|
|
20
|
+
const alleles = val.split(/[/|]/);
|
|
21
|
+
for (const allele of alleles) {
|
|
22
|
+
alleleCounts.set(allele, (alleleCounts.get(allele) || 0) + 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
let mostFrequentAlt;
|
|
26
|
+
let max = 0;
|
|
27
|
+
for (const [alt, altCount] of alleleCounts.entries()) {
|
|
28
|
+
if (alt !== '.' && alt !== '0') {
|
|
29
|
+
if (altCount > max) {
|
|
30
|
+
mostFrequentAlt = alt;
|
|
31
|
+
max = altCount;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { alleleCounts, mostFrequentAlt };
|
|
36
|
+
}
|
|
37
|
+
export function calculateMinorAlleleFrequency(alleleCounts) {
|
|
38
|
+
return (findSecondLargestNumber(alleleCounts.values()) /
|
|
39
|
+
(sum(alleleCounts.values()) || 1));
|
|
40
|
+
}
|
|
41
|
+
export function getFeaturesThatPassMinorAlleleFrequencyFilter(feats, minorAlleleFrequencyFilter) {
|
|
42
|
+
const results = [];
|
|
43
|
+
for (const feature of feats) {
|
|
44
|
+
if (feature.get('end') - feature.get('start') <= 10) {
|
|
45
|
+
const { mostFrequentAlt, alleleCounts } = calculateAlleleCounts(feature);
|
|
46
|
+
if (calculateMinorAlleleFrequency(alleleCounts) >=
|
|
47
|
+
minorAlleleFrequencyFilter) {
|
|
48
|
+
results.push({
|
|
49
|
+
feature,
|
|
50
|
+
mostFrequentAlt,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return results;
|
|
56
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function moveUp(arr, sel, by = 1) {
|
|
2
|
+
const idxs = sel
|
|
3
|
+
.map(l => arr.findIndex(v => v.name === l))
|
|
4
|
+
.sort((a, b) => a - b);
|
|
5
|
+
let lastIdx = 0;
|
|
6
|
+
for (const old of idxs) {
|
|
7
|
+
const idx = Math.max(lastIdx, old - by);
|
|
8
|
+
if (idx >= lastIdx) {
|
|
9
|
+
arr.splice(idx, 0, arr.splice(old, 1)[0]);
|
|
10
|
+
}
|
|
11
|
+
lastIdx = lastIdx + 1;
|
|
12
|
+
}
|
|
13
|
+
return arr;
|
|
14
|
+
}
|
|
15
|
+
export function moveDown(arr, sel, by = 1) {
|
|
16
|
+
const idxs = sel
|
|
17
|
+
.map(l => arr.findIndex(v => v.name === l))
|
|
18
|
+
.sort((a, b) => b - a);
|
|
19
|
+
let lastIdx = arr.length - 1;
|
|
20
|
+
for (const old of idxs) {
|
|
21
|
+
const idx = Math.min(lastIdx, old + by);
|
|
22
|
+
if (idx <= lastIdx) {
|
|
23
|
+
arr.splice(idx, 0, arr.splice(old, 1)[0]);
|
|
24
|
+
}
|
|
25
|
+
lastIdx = lastIdx - 1;
|
|
26
|
+
}
|
|
27
|
+
return arr;
|
|
28
|
+
}
|
package/esm/shared/util.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
name: string;
|
|
5
|
-
}[];
|
|
6
|
-
export declare function moveDown(arr: {
|
|
7
|
-
name: string;
|
|
8
|
-
}[], sel: string[], by?: number): {
|
|
9
|
-
name: string;
|
|
10
|
-
}[];
|
|
1
|
+
export declare function fillRectCtx(x: number, y: number, width: number, height: number, ctx: CanvasRenderingContext2D, color?: string): void;
|
|
2
|
+
export declare function randomColor(str: string): string;
|
|
3
|
+
export declare function colorify(n: number): string;
|
package/esm/shared/util.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
export function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let lastIdx = 0;
|
|
6
|
-
for (const old of idxs) {
|
|
7
|
-
const idx = Math.max(lastIdx, old - by);
|
|
8
|
-
if (idx >= lastIdx) {
|
|
9
|
-
arr.splice(idx, 0, arr.splice(old, 1)[0]);
|
|
10
|
-
}
|
|
11
|
-
lastIdx = lastIdx + 1;
|
|
1
|
+
export function fillRectCtx(x, y, width, height, ctx, color) {
|
|
2
|
+
if (width < 0) {
|
|
3
|
+
x += width;
|
|
4
|
+
width = -width;
|
|
12
5
|
}
|
|
13
|
-
|
|
6
|
+
if (height < 0) {
|
|
7
|
+
y += height;
|
|
8
|
+
height = -height;
|
|
9
|
+
}
|
|
10
|
+
if (color) {
|
|
11
|
+
ctx.fillStyle = color;
|
|
12
|
+
}
|
|
13
|
+
ctx.fillRect(x, y, width, height);
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
let lastIdx = arr.length - 1;
|
|
20
|
-
for (const old of idxs) {
|
|
21
|
-
const idx = Math.min(lastIdx, old + by);
|
|
22
|
-
if (idx <= lastIdx) {
|
|
23
|
-
arr.splice(idx, 0, arr.splice(old, 1)[0]);
|
|
24
|
-
}
|
|
25
|
-
lastIdx = lastIdx - 1;
|
|
15
|
+
export function randomColor(str) {
|
|
16
|
+
let sum = 0;
|
|
17
|
+
for (let i = 0; i < str.length; i++) {
|
|
18
|
+
sum += str.charCodeAt(i);
|
|
26
19
|
}
|
|
27
|
-
return
|
|
20
|
+
return colorify(sum * 10);
|
|
21
|
+
}
|
|
22
|
+
export function colorify(n) {
|
|
23
|
+
return `hsl(${n % 255}, 50%, 50%)`;
|
|
28
24
|
}
|
package/esm/util.d.ts
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Feature } from '@jbrowse/core/util';
|
|
2
|
-
export declare function fillRectCtx(x: number, y: number, width: number, height: number, ctx: CanvasRenderingContext2D, color?: string): void;
|
|
3
|
-
export declare function getCol(gt: string): "blue" | "teal" | "#ccc" | "#CBC3E3";
|
|
4
|
-
export declare function randomColor(str: string): string;
|
|
5
|
-
export declare function colorify(n: number): string;
|
|
6
|
-
export declare function findSecondLargest(arr: Iterable<number>): number;
|
|
7
|
-
export declare function calculateMinorAlleleFrequency(feat: Feature): number;
|
|
8
|
-
export declare function getFeaturesThatPassMinorAlleleFrequencyFilter(feats: Iterable<Feature>, minorAlleleFrequencyFilter: number): Feature[];
|
package/esm/util.js
CHANGED
|
@@ -1,77 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export function fillRectCtx(x, y, width, height, ctx, color) {
|
|
3
|
-
if (width < 0) {
|
|
4
|
-
x += width;
|
|
5
|
-
width = -width;
|
|
6
|
-
}
|
|
7
|
-
if (height < 0) {
|
|
8
|
-
y += height;
|
|
9
|
-
height = -height;
|
|
10
|
-
}
|
|
11
|
-
if (color) {
|
|
12
|
-
ctx.fillStyle = color;
|
|
13
|
-
}
|
|
14
|
-
ctx.fillRect(x, y, width, height);
|
|
15
|
-
}
|
|
16
|
-
export function getCol(gt) {
|
|
17
|
-
if (gt === '0|0' || gt === '0/0') {
|
|
18
|
-
return '#ccc';
|
|
19
|
-
}
|
|
20
|
-
else if (gt === '1|0' || gt === '0|1' || gt === '0/1' || gt === '1/0') {
|
|
21
|
-
return 'teal';
|
|
22
|
-
}
|
|
23
|
-
else if (gt === '1|1' || gt === '1/1') {
|
|
24
|
-
return 'blue';
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return '#CBC3E3';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export function randomColor(str) {
|
|
31
|
-
let sum = 0;
|
|
32
|
-
for (let i = 0; i < str.length; i++) {
|
|
33
|
-
sum += str.charCodeAt(i);
|
|
34
|
-
}
|
|
35
|
-
return `hsl(${colorify(sum * 10)}, 50%, 50%)`;
|
|
36
|
-
}
|
|
37
|
-
export function colorify(n) {
|
|
38
|
-
return `hsl(${n % 255}, 50%, 50%)`;
|
|
39
|
-
}
|
|
40
|
-
export function findSecondLargest(arr) {
|
|
41
|
-
let firstMax = 0;
|
|
42
|
-
let secondMax = 0;
|
|
43
|
-
for (const num of arr) {
|
|
44
|
-
if (num > firstMax) {
|
|
45
|
-
secondMax = firstMax;
|
|
46
|
-
firstMax = num;
|
|
47
|
-
}
|
|
48
|
-
else if (num > secondMax && num !== firstMax) {
|
|
49
|
-
secondMax = num;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return secondMax;
|
|
53
|
-
}
|
|
54
|
-
export function calculateMinorAlleleFrequency(feat) {
|
|
55
|
-
if (feat.get('end') - feat.get('start') <= 10) {
|
|
56
|
-
const samp = feat.get('genotypes');
|
|
57
|
-
const alleleCounts = new Map();
|
|
58
|
-
for (const val of Object.values(samp)) {
|
|
59
|
-
const alleles = val.split(/[/|]/);
|
|
60
|
-
for (const allele of alleles) {
|
|
61
|
-
alleleCounts.set(allele, (alleleCounts.get(allele) || 0) + 1);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return (findSecondLargest(alleleCounts.values()) /
|
|
65
|
-
(sum(alleleCounts.values()) || 1));
|
|
66
|
-
}
|
|
67
|
-
return -1;
|
|
68
|
-
}
|
|
69
|
-
export function getFeaturesThatPassMinorAlleleFrequencyFilter(feats, minorAlleleFrequencyFilter) {
|
|
70
|
-
const mafs = [];
|
|
71
|
-
for (const feat of feats) {
|
|
72
|
-
if (calculateMinorAlleleFrequency(feat) >= minorAlleleFrequencyFilter) {
|
|
73
|
-
mafs.push(feat);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return mafs;
|
|
77
|
-
}
|
|
1
|
+
"use strict";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -39,28 +39,28 @@
|
|
|
39
39
|
"@flatten-js/interval-tree": "^1.0.15",
|
|
40
40
|
"@gmod/bgzf-filehandle": "^2.0.1",
|
|
41
41
|
"@gmod/tabix": "^2.0.0",
|
|
42
|
-
"@gmod/vcf": "^6.0.
|
|
43
|
-
"@jbrowse/
|
|
42
|
+
"@gmod/vcf": "^6.0.8",
|
|
43
|
+
"@jbrowse/core": "^3.0.2",
|
|
44
|
+
"@jbrowse/plugin-circular-view": "^3.0.2",
|
|
45
|
+
"@jbrowse/plugin-linear-genome-view": "^3.0.2",
|
|
46
|
+
"@jbrowse/sv-core": "^3.0.2",
|
|
44
47
|
"@mui/icons-material": "^6.0.0",
|
|
45
|
-
"@mui/x-data-grid": "^7.0.0"
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"@jbrowse/core": "^2.0.0",
|
|
49
|
-
"@jbrowse/plugin-circular-view": "^2.0.0",
|
|
50
|
-
"@jbrowse/plugin-linear-genome-view": "^2.0.0",
|
|
51
48
|
"@mui/material": "^6.0.0",
|
|
49
|
+
"@mui/x-data-grid": "^7.0.0",
|
|
52
50
|
"mobx": "^6.0.0",
|
|
53
51
|
"mobx-react": "^9.0.0",
|
|
54
52
|
"mobx-state-tree": "^5.0.0",
|
|
55
|
-
"react": ">=16.8.0",
|
|
56
53
|
"rxjs": "^7.0.0",
|
|
57
54
|
"tss-react": "^4.0.0"
|
|
58
55
|
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": ">=18.0.0"
|
|
58
|
+
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"distModule": "esm/index.js",
|
|
63
63
|
"srcModule": "src/index.ts",
|
|
64
64
|
"module": "esm/index.js",
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c01a35edcb2612e94661af8793f09c95c0b13c75"
|
|
66
66
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|