@jbrowse/plugin-variants 3.0.1 → 3.0.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.
Files changed (155) hide show
  1. package/dist/MultiLinearVariantDisplay/components/Crosshair.js +1 -1
  2. package/dist/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +1 -1
  3. package/dist/MultiLinearVariantDisplay/model.d.ts +7 -7
  4. package/dist/MultiLinearVariantDisplay/renderSvg.js +1 -1
  5. package/dist/MultiLinearVariantMatrixDisplay/components/Crosshair.js +1 -1
  6. package/dist/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +1 -1
  7. package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +7 -7
  8. package/dist/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
  9. package/dist/MultiLinearVariantMatrixRenderer/LinearVariantMatrixRenderer.js +5 -5
  10. package/dist/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +6 -3
  11. package/dist/MultiLinearVariantMatrixRenderer/makeImageData.js +58 -67
  12. package/dist/MultiLinearVariantMatrixRenderer/types.d.ts +2 -1
  13. package/dist/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +1 -1
  14. package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.d.ts +22 -0
  15. package/dist/MultiLinearVariantRenderer/components/MultiVariantRendering.js +52 -0
  16. package/dist/MultiLinearVariantRenderer/index.js +1 -1
  17. package/dist/MultiLinearVariantRenderer/makeImageData.js +13 -21
  18. package/dist/MultiLinearVariantRenderer/types.d.ts +1 -1
  19. package/dist/MultiVariantBaseRenderer.d.ts +5 -5
  20. package/dist/VariantRPC/MultiVariantGetGenotypeMatrix.js +4 -4
  21. package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +1 -1
  22. package/dist/VariantRPC/MultiVariantGetSimplifiedFeatures.js +9 -9
  23. package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +6 -3
  24. package/dist/VcfTabixAdapter/VcfTabixAdapter.js +13 -13
  25. package/dist/getMultiVariantFeaturesAutorun.d.ts +1 -1
  26. package/dist/getMultiVariantSourcesAutorun.d.ts +1 -1
  27. package/dist/shared/MultiVariantBaseModel.d.ts +1 -1
  28. package/dist/shared/MultiVariantBaseModel.js +4 -4
  29. package/dist/shared/{SourcesGridHeader.js → components/SourcesGridHeader.js} +5 -5
  30. package/dist/shared/constants.d.ts +2 -0
  31. package/dist/shared/constants.js +5 -0
  32. package/dist/shared/drawAlleleCount.d.ts +1 -0
  33. package/dist/shared/{multiVariantColor.js → drawAlleleCount.js} +7 -14
  34. package/dist/shared/drawPhased.d.ts +1 -0
  35. package/dist/shared/drawPhased.js +21 -0
  36. package/dist/shared/findSecondLargestNumber.d.ts +0 -0
  37. package/dist/shared/findSecondLargestNumber.js +1 -0
  38. package/dist/shared/minorAlleleFrequencyUtils.d.ts +11 -0
  39. package/dist/shared/minorAlleleFrequencyUtils.js +62 -0
  40. package/dist/shared/sourcesGridUtils.d.ts +10 -0
  41. package/dist/shared/sourcesGridUtils.js +32 -0
  42. package/dist/shared/util.d.ts +3 -10
  43. package/dist/shared/util.js +23 -26
  44. package/dist/util.d.ts +0 -8
  45. package/dist/util.js +0 -85
  46. package/esm/MultiLinearVariantDisplay/components/Crosshair.js +1 -1
  47. package/esm/MultiLinearVariantDisplay/components/VariantDisplayComponent.js +1 -1
  48. package/esm/MultiLinearVariantDisplay/model.d.ts +7 -7
  49. package/esm/MultiLinearVariantDisplay/renderSvg.js +1 -1
  50. package/esm/MultiLinearVariantMatrixDisplay/components/Crosshair.js +1 -1
  51. package/esm/MultiLinearVariantMatrixDisplay/components/VariantDisplayComponent.js +1 -1
  52. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +7 -7
  53. package/esm/MultiLinearVariantMatrixDisplay/renderSvg.js +1 -1
  54. package/esm/MultiLinearVariantMatrixRenderer/LinearVariantMatrixRenderer.js +5 -5
  55. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.d.ts +6 -3
  56. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +56 -65
  57. package/esm/MultiLinearVariantMatrixRenderer/types.d.ts +2 -1
  58. package/esm/MultiLinearVariantRenderer/MultiVariantRendering.d.ts +1 -1
  59. package/esm/MultiLinearVariantRenderer/components/MultiVariantRendering.d.ts +22 -0
  60. package/esm/MultiLinearVariantRenderer/components/MultiVariantRendering.js +47 -0
  61. package/esm/MultiLinearVariantRenderer/index.js +1 -1
  62. package/esm/MultiLinearVariantRenderer/makeImageData.js +6 -14
  63. package/esm/MultiLinearVariantRenderer/types.d.ts +1 -1
  64. package/esm/MultiVariantBaseRenderer.d.ts +5 -5
  65. package/esm/VariantRPC/MultiVariantGetGenotypeMatrix.js +3 -3
  66. package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.d.ts +1 -1
  67. package/esm/VariantRPC/MultiVariantGetSimplifiedFeatures.js +8 -8
  68. package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +6 -3
  69. package/esm/VcfTabixAdapter/VcfTabixAdapter.js +13 -13
  70. package/esm/getMultiVariantFeaturesAutorun.d.ts +1 -1
  71. package/esm/getMultiVariantSourcesAutorun.d.ts +1 -1
  72. package/esm/shared/MultiVariantBaseModel.d.ts +1 -1
  73. package/esm/shared/MultiVariantBaseModel.js +4 -4
  74. package/esm/shared/{SourcesGridHeader.js → components/SourcesGridHeader.js} +1 -1
  75. package/esm/shared/constants.d.ts +2 -0
  76. package/esm/shared/constants.js +2 -0
  77. package/esm/shared/drawAlleleCount.d.ts +1 -0
  78. package/esm/shared/{multiVariantColor.js → drawAlleleCount.js} +6 -11
  79. package/esm/shared/drawPhased.d.ts +1 -0
  80. package/esm/shared/drawPhased.js +18 -0
  81. package/esm/shared/findSecondLargestNumber.d.ts +0 -0
  82. package/esm/shared/findSecondLargestNumber.js +1 -0
  83. package/esm/shared/minorAlleleFrequencyUtils.d.ts +11 -0
  84. package/esm/shared/minorAlleleFrequencyUtils.js +56 -0
  85. package/esm/shared/sourcesGridUtils.d.ts +10 -0
  86. package/esm/shared/sourcesGridUtils.js +28 -0
  87. package/esm/shared/util.d.ts +3 -10
  88. package/esm/shared/util.js +20 -24
  89. package/esm/util.d.ts +0 -8
  90. package/esm/util.js +1 -77
  91. package/package.json +7 -7
  92. package/dist/shared/multiVariantColor.d.ts +0 -3
  93. package/esm/shared/multiVariantColor.d.ts +0 -3
  94. /package/dist/shared/{BulkEditPanel.d.ts → components/BulkEditPanel.d.ts} +0 -0
  95. /package/dist/shared/{BulkEditPanel.js → components/BulkEditPanel.js} +0 -0
  96. /package/dist/shared/{ClusterDialog.d.ts → components/ClusterDialog.d.ts} +0 -0
  97. /package/dist/shared/{ClusterDialog.js → components/ClusterDialog.js} +0 -0
  98. /package/dist/shared/{ColorLegend.d.ts → components/ColorLegend.d.ts} +0 -0
  99. /package/dist/shared/{ColorLegend.js → components/ColorLegend.js} +0 -0
  100. /package/dist/shared/{HelpfulTips.d.ts → components/HelpfulTips.d.ts} +0 -0
  101. /package/dist/shared/{HelpfulTips.js → components/HelpfulTips.js} +0 -0
  102. /package/dist/shared/{LegendBar.d.ts → components/LegendBar.d.ts} +0 -0
  103. /package/dist/shared/{LegendBar.js → components/LegendBar.js} +0 -0
  104. /package/dist/shared/{MAFFilterDialog.d.ts → components/MAFFilterDialog.d.ts} +0 -0
  105. /package/dist/shared/{MAFFilterDialog.js → components/MAFFilterDialog.js} +0 -0
  106. /package/dist/shared/{MultiVariantTooltip.d.ts → components/MultiVariantTooltip.d.ts} +0 -0
  107. /package/dist/shared/{MultiVariantTooltip.js → components/MultiVariantTooltip.js} +0 -0
  108. /package/dist/shared/{RectBg.d.ts → components/RectBg.d.ts} +0 -0
  109. /package/dist/shared/{RectBg.js → components/RectBg.js} +0 -0
  110. /package/dist/shared/{RowPalettizer.d.ts → components/RowPalettizer.d.ts} +0 -0
  111. /package/dist/shared/{RowPalettizer.js → components/RowPalettizer.js} +0 -0
  112. /package/dist/shared/{SetColorDialog.d.ts → components/SetColorDialog.d.ts} +0 -0
  113. /package/dist/shared/{SetColorDialog.js → components/SetColorDialog.js} +0 -0
  114. /package/dist/shared/{SetMinMaxDialog.d.ts → components/SetMinMaxDialog.d.ts} +0 -0
  115. /package/dist/shared/{SetMinMaxDialog.js → components/SetMinMaxDialog.js} +0 -0
  116. /package/dist/shared/{SetRowHeightDialog.d.ts → components/SetRowHeightDialog.d.ts} +0 -0
  117. /package/dist/shared/{SetRowHeightDialog.js → components/SetRowHeightDialog.js} +0 -0
  118. /package/dist/shared/{SourcesDataGrid.d.ts → components/SourcesDataGrid.d.ts} +0 -0
  119. /package/dist/shared/{SourcesDataGrid.js → components/SourcesDataGrid.js} +0 -0
  120. /package/dist/shared/{SourcesGrid.d.ts → components/SourcesGrid.d.ts} +0 -0
  121. /package/dist/shared/{SourcesGrid.js → components/SourcesGrid.js} +0 -0
  122. /package/dist/shared/{SourcesGridHeader.d.ts → components/SourcesGridHeader.d.ts} +0 -0
  123. /package/dist/{types.d.ts → shared/types.d.ts} +0 -0
  124. /package/dist/{types.js → shared/types.js} +0 -0
  125. /package/esm/shared/{BulkEditPanel.d.ts → components/BulkEditPanel.d.ts} +0 -0
  126. /package/esm/shared/{BulkEditPanel.js → components/BulkEditPanel.js} +0 -0
  127. /package/esm/shared/{ClusterDialog.d.ts → components/ClusterDialog.d.ts} +0 -0
  128. /package/esm/shared/{ClusterDialog.js → components/ClusterDialog.js} +0 -0
  129. /package/esm/shared/{ColorLegend.d.ts → components/ColorLegend.d.ts} +0 -0
  130. /package/esm/shared/{ColorLegend.js → components/ColorLegend.js} +0 -0
  131. /package/esm/shared/{HelpfulTips.d.ts → components/HelpfulTips.d.ts} +0 -0
  132. /package/esm/shared/{HelpfulTips.js → components/HelpfulTips.js} +0 -0
  133. /package/esm/shared/{LegendBar.d.ts → components/LegendBar.d.ts} +0 -0
  134. /package/esm/shared/{LegendBar.js → components/LegendBar.js} +0 -0
  135. /package/esm/shared/{MAFFilterDialog.d.ts → components/MAFFilterDialog.d.ts} +0 -0
  136. /package/esm/shared/{MAFFilterDialog.js → components/MAFFilterDialog.js} +0 -0
  137. /package/esm/shared/{MultiVariantTooltip.d.ts → components/MultiVariantTooltip.d.ts} +0 -0
  138. /package/esm/shared/{MultiVariantTooltip.js → components/MultiVariantTooltip.js} +0 -0
  139. /package/esm/shared/{RectBg.d.ts → components/RectBg.d.ts} +0 -0
  140. /package/esm/shared/{RectBg.js → components/RectBg.js} +0 -0
  141. /package/esm/shared/{RowPalettizer.d.ts → components/RowPalettizer.d.ts} +0 -0
  142. /package/esm/shared/{RowPalettizer.js → components/RowPalettizer.js} +0 -0
  143. /package/esm/shared/{SetColorDialog.d.ts → components/SetColorDialog.d.ts} +0 -0
  144. /package/esm/shared/{SetColorDialog.js → components/SetColorDialog.js} +0 -0
  145. /package/esm/shared/{SetMinMaxDialog.d.ts → components/SetMinMaxDialog.d.ts} +0 -0
  146. /package/esm/shared/{SetMinMaxDialog.js → components/SetMinMaxDialog.js} +0 -0
  147. /package/esm/shared/{SetRowHeightDialog.d.ts → components/SetRowHeightDialog.d.ts} +0 -0
  148. /package/esm/shared/{SetRowHeightDialog.js → components/SetRowHeightDialog.js} +0 -0
  149. /package/esm/shared/{SourcesDataGrid.d.ts → components/SourcesDataGrid.d.ts} +0 -0
  150. /package/esm/shared/{SourcesDataGrid.js → components/SourcesDataGrid.js} +0 -0
  151. /package/esm/shared/{SourcesGrid.d.ts → components/SourcesGrid.d.ts} +0 -0
  152. /package/esm/shared/{SourcesGrid.js → components/SourcesGrid.js} +0 -0
  153. /package/esm/shared/{SourcesGridHeader.d.ts → components/SourcesGridHeader.d.ts} +0 -0
  154. /package/esm/{types.d.ts → shared/types.d.ts} +0 -0
  155. /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 { colorify } from '../util';
4
- export function getColorAlleleCount(alleles) {
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 === '1') {
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 getColorPhased(alleles, HP) {
39
- const c = +alleles[HP];
40
- return c ? set1[c - 1] || 'black' : '#ccc';
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,10 @@
1
+ export declare function moveUp(arr: {
2
+ name: string;
3
+ }[], sel: string[], by?: number): {
4
+ name: string;
5
+ }[];
6
+ export declare function moveDown(arr: {
7
+ name: string;
8
+ }[], sel: string[], by?: number): {
9
+ name: string;
10
+ }[];
@@ -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
+ }
@@ -1,10 +1,3 @@
1
- export declare function moveUp(arr: {
2
- name: string;
3
- }[], sel: string[], by?: number): {
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;
@@ -1,28 +1,24 @@
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;
1
+ export function fillRectCtx(x, y, width, height, ctx, color) {
2
+ if (width < 0) {
3
+ x += width;
4
+ width = -width;
12
5
  }
13
- return arr;
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 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;
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 arr;
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
- import { sum } from '@jbrowse/core/util';
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.1",
3
+ "version": "3.0.3",
4
4
  "description": "JBrowse 2 variant adapters, tracks, etc.",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -39,11 +39,11 @@
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.0",
43
- "@jbrowse/core": "^3.0.1",
44
- "@jbrowse/plugin-circular-view": "^3.0.1",
45
- "@jbrowse/plugin-linear-genome-view": "^3.0.1",
46
- "@jbrowse/sv-core": "^3.0.1",
42
+ "@gmod/vcf": "^6.0.8",
43
+ "@jbrowse/core": "^3.0.3",
44
+ "@jbrowse/plugin-circular-view": "^3.0.3",
45
+ "@jbrowse/plugin-linear-genome-view": "^3.0.3",
46
+ "@jbrowse/sv-core": "^3.0.3",
47
47
  "@mui/icons-material": "^6.0.0",
48
48
  "@mui/material": "^6.0.0",
49
49
  "@mui/x-data-grid": "^7.0.0",
@@ -62,5 +62,5 @@
62
62
  "distModule": "esm/index.js",
63
63
  "srcModule": "src/index.ts",
64
64
  "module": "esm/index.js",
65
- "gitHead": "aa2f1d1a89d2361c7fd1a93fe29506fa4554f5cc"
65
+ "gitHead": "f516540428282351d26e46743e69a724651bfb2c"
66
66
  }
@@ -1,3 +0,0 @@
1
- export declare function getColorAlleleCount(alleles: string[]): string;
2
- export declare function getColorPhased(alleles: string[], HP: number): string;
3
- export declare function getColorPhasedWithPhaseSet(alleles: string[], HP: number, PS: string): string;
@@ -1,3 +0,0 @@
1
- export declare function getColorAlleleCount(alleles: string[]): string;
2
- export declare function getColorPhased(alleles: string[], HP: number): string;
3
- export declare function getColorPhasedWithPhaseSet(alleles: string[], HP: number, PS: string): string;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes