@weng-lab/genomebrowser-ui 0.4.0 → 0.4.1

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 (33) hide show
  1. package/dist/TrackSelect/Folders/biosamples/data/{human_with_wgbs.json.d.ts → humans_fixed.json.d.ts} +511 -511
  2. package/dist/TrackSelect/Folders/biosamples/shared/types.d.ts +1 -1
  3. package/dist/TrackSelect/Folders/index.d.ts +2 -0
  4. package/dist/TrackSelect/Folders/psychscreen/data/human.json.d.ts +815 -0
  5. package/dist/TrackSelect/Folders/psychscreen/human.d.ts +1 -0
  6. package/dist/TrackSelect/Folders/psychscreen/shared/PsychscreenGroupingCell.d.ts +2 -0
  7. package/dist/TrackSelect/Folders/psychscreen/shared/columns.d.ts +7 -0
  8. package/dist/TrackSelect/Folders/psychscreen/shared/createFolder.d.ts +9 -0
  9. package/dist/TrackSelect/Folders/psychscreen/shared/toTrack.d.ts +5 -0
  10. package/dist/TrackSelect/Folders/psychscreen/shared/types.d.ts +12 -0
  11. package/dist/TrackSelect/trackContext.d.ts +2 -1
  12. package/dist/TrackSelect/types.d.ts +1 -1
  13. package/dist/genomebrowser-ui.es.js +1408 -1263
  14. package/dist/genomebrowser-ui.es.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/TrackSelect/DataGrid/DataGridWrapper.tsx +9 -5
  17. package/src/TrackSelect/Folders/biosamples/data/fix-human-collections.mjs +119 -0
  18. package/src/TrackSelect/Folders/biosamples/data/humans_fixed.json +59909 -0
  19. package/src/TrackSelect/Folders/biosamples/human.ts +1 -1
  20. package/src/TrackSelect/Folders/biosamples/shared/columns.tsx +2 -2
  21. package/src/TrackSelect/Folders/biosamples/shared/types.ts +1 -1
  22. package/src/TrackSelect/Folders/index.ts +4 -0
  23. package/src/TrackSelect/Folders/psychscreen/data/human.json +812 -0
  24. package/src/TrackSelect/Folders/psychscreen/human.ts +10 -0
  25. package/src/TrackSelect/Folders/psychscreen/shared/PsychscreenGroupingCell.tsx +78 -0
  26. package/src/TrackSelect/Folders/psychscreen/shared/columns.tsx +52 -0
  27. package/src/TrackSelect/Folders/psychscreen/shared/createFolder.ts +45 -0
  28. package/src/TrackSelect/Folders/psychscreen/shared/toTrack.ts +48 -0
  29. package/src/TrackSelect/Folders/psychscreen/shared/types.ts +14 -0
  30. package/src/TrackSelect/TreeView/CustomTreeItem.tsx +10 -2
  31. package/src/TrackSelect/TreeView/TreeViewWrapper.tsx +4 -1
  32. package/src/TrackSelect/trackContext.ts +2 -0
  33. package/src/TrackSelect/types.ts +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weng-lab/genomebrowser-ui",
3
3
  "private": false,
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -5,6 +5,8 @@ import {
5
5
  GridAutosizeOptions,
6
6
  GridColDef,
7
7
  GridColumnVisibilityModel,
8
+ GridRenderCellParams,
9
+ GridRowSelectionModel,
8
10
  useGridApiRef,
9
11
  } from "@mui/x-data-grid-premium";
10
12
  import { useEffect, useMemo, useState } from "react";
@@ -88,7 +90,7 @@ export function DataGridWrapper(props: DataGridProps) {
88
90
  apiRef={apiRef}
89
91
  rows={rows}
90
92
  columns={columns}
91
- getRowId={(row) => row.id}
93
+ getRowId={(row: { id: string }) => row.id}
92
94
  autosizeOptions={autosizeOptions}
93
95
  rowGroupingModel={groupingModel}
94
96
  groupingColDef={{
@@ -97,13 +99,15 @@ export function DataGridWrapper(props: DataGridProps) {
97
99
  minWidth: 300,
98
100
  maxWidth: 500,
99
101
  flex: 2,
100
- renderCell: (params) => <GroupingCell {...params} />,
102
+ renderCell: (params: GridRenderCellParams) => (
103
+ <GroupingCell {...params} />
104
+ ),
101
105
  }}
102
106
  columnVisibilityModel={columnVisibilityModel}
103
107
  onColumnVisibilityModelChange={setColumnVisibilityModel}
104
- onRowSelectionModelChange={(selection) => {
105
- const ids = (selection as any)?.ids ?? new Set<string>();
106
- onSelectionChange(new Set(ids));
108
+ onRowSelectionModelChange={(selection: GridRowSelectionModel) => {
109
+ const ids = selection.ids ?? new Set<string>();
110
+ onSelectionChange(new Set([...ids].map(String)));
107
111
  }}
108
112
  rowSelectionPropagation={{ descendants: true, parents: false }}
109
113
  disableRowGrouping={false}
@@ -0,0 +1,119 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ const inputPath = join(__dirname, "human_with_wgbs.json");
7
+ const outputPath = join(__dirname, "humans_fixed.json");
8
+
9
+ const expectedCounts = {
10
+ Core: 170,
11
+ Partial: 1155,
12
+ Ancillary: 562,
13
+ };
14
+
15
+ const counts = {
16
+ Core: 0,
17
+ Partial: 0,
18
+ Ancillary: 0,
19
+ NA: 0,
20
+ };
21
+
22
+ const specialCases = {
23
+ GM12866_ENCDO000ABQ: "NA",
24
+ neural_crest_cell_ENCDO222AAA: "Partial",
25
+ };
26
+
27
+ const specialCaseFound = Object.fromEntries(
28
+ Object.keys(specialCases).map((name) => [name, false]),
29
+ );
30
+
31
+ function classifyTrack(track) {
32
+ const specialCollection = specialCases[track.name];
33
+ if (specialCollection) {
34
+ specialCaseFound[track.name] = true;
35
+ return specialCollection;
36
+ }
37
+
38
+ const assays = new Set(
39
+ track.assays.map((assay) => assay.assay.toLowerCase()),
40
+ );
41
+
42
+ if (!assays.has("dnase")) {
43
+ return "Ancillary";
44
+ }
45
+
46
+ if (
47
+ assays.has("h3k4me3") &&
48
+ assays.has("h3k27ac") &&
49
+ assays.has("ctcf")
50
+ ) {
51
+ return "Core";
52
+ }
53
+
54
+ return "Partial";
55
+ }
56
+
57
+ function isAggregate(track) {
58
+ return track.name === "aggregate-biosample-data" || track.ontology === "aggregate";
59
+ }
60
+
61
+ function validateCounts() {
62
+ const mismatches = Object.entries(expectedCounts).filter(
63
+ ([collection, expected]) => counts[collection] !== expected,
64
+ );
65
+
66
+ if (mismatches.length === 0) {
67
+ return;
68
+ }
69
+
70
+ console.error("Classification count validation failed.");
71
+ console.error("Expected:", expectedCounts);
72
+ console.error("Actual:", counts);
73
+ process.exit(1);
74
+ }
75
+
76
+ const input = JSON.parse(await readFile(inputPath, "utf8"));
77
+ const changes = [];
78
+
79
+ const fixedTracks = input.tracks.map((track) => {
80
+ const collection = classifyTrack(track);
81
+
82
+ if (!isAggregate(track)) {
83
+ counts[collection] += 1;
84
+ }
85
+
86
+ if (track.collection !== collection) {
87
+ changes.push({
88
+ name: track.name,
89
+ displayName: track.displayName,
90
+ from: track.collection,
91
+ to: collection,
92
+ });
93
+ }
94
+
95
+ return {
96
+ ...track,
97
+ collection,
98
+ };
99
+ });
100
+
101
+ validateCounts();
102
+
103
+ await writeFile(
104
+ outputPath,
105
+ `${JSON.stringify({ ...input, tracks: fixedTracks }, null, 2)}\n`,
106
+ );
107
+
108
+ console.log("Wrote", outputPath);
109
+ console.log("Counts excluding aggregate:", counts);
110
+ console.log("Changed tracks:", changes.length);
111
+ console.log("Special cases found:", specialCaseFound);
112
+
113
+ const changeCounts = changes.reduce((acc, change) => {
114
+ const key = `${change.from} -> ${change.to}`;
115
+ acc[key] = (acc[key] ?? 0) + 1;
116
+ return acc;
117
+ }, {});
118
+
119
+ console.log("Change counts:", changeCounts);