@datagrok/curves 1.11.0 → 1.12.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/CLAUDE.md +123 -91
- package/detectors.js +37 -0
- package/dist/package-test.js +1160 -109
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +634 -101
- package/dist/package.js.map +1 -1
- package/files/dose-response-4pl.pzfx +178 -0
- package/files/exponential-decay.pzfx +81 -0
- package/files/mixed-tables.pzfx +64 -0
- package/package.json +4 -4
- package/src/fit/converters/compact-dr-converter.ts +73 -0
- package/src/fit/converters/pzfx-converter.ts +13 -0
- package/src/fit/converters/xml-converter.ts +9 -0
- package/src/fit/curve-converter.ts +83 -0
- package/src/fit/data-to-curves.ts +1 -0
- package/src/fit/fit-demo.ts +1 -0
- package/src/fit/fit-grid-cell-handler.ts +7 -14
- package/src/fit/fit-inspection.ts +1 -1
- package/src/fit/fit-parser.ts +1 -1
- package/src/fit/fit-renderer.ts +8 -15
- package/src/formats/pzfx/pzfx-parser.ts +251 -0
- package/src/package-api.ts +29 -0
- package/src/package-test.ts +2 -0
- package/src/package.g.ts +42 -2
- package/src/package.ts +70 -8
- package/src/tests/converter-tests.ts +305 -0
- package/src/tests/detector-tests.ts +38 -0
- package/src/tests/pzfx-tests.ts +178 -0
- package/test-console-output-1.log +132 -28
- package/test-record-1.mp4 +0 -0
package/CLAUDE.md
CHANGED
|
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
**Curves** (`@datagrok/curves`) is a Datagrok plugin for **fitted curves** — dose-response curves, sigmoid fits, and general curve fitting. It provides in-grid cell rendering of charts stored
|
|
7
|
+
**Curves** (`@datagrok/curves`) is a Datagrok plugin for **fitted curves** — dose-response curves, sigmoid fits, and general curve fitting. It provides in-grid cell rendering of charts stored in various formats in cells, interactive editing (outlier toggling, property panels), automatic curve fitting, a "Data to Curves" pipeline that converts well-level assay data into fitted curve summaries, a multi-curve overlay viewer, and statistics extraction (IC50, AUC, R², etc.).
|
|
8
8
|
|
|
9
9
|
Category: **Visualizations**. Top menu: `Data | Curves | ...`.
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ npm run link-all # Links datagrok-api, @datagrok-libraries/utils, @dat
|
|
|
31
31
|
|
|
32
32
|
### Data Model (from `@datagrok-libraries/statistics`)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
The **native format** for curve data in cells is JSON conforming to `IFitChartData`:
|
|
35
35
|
```
|
|
36
36
|
IFitChartData {
|
|
37
37
|
chartOptions?: IFitChartOptions // axes bounds, log scale, title, axis names, showStatistics
|
|
@@ -41,10 +41,52 @@ IFitChartData {
|
|
|
41
41
|
```
|
|
42
42
|
Each `IFitSeries` has `points: IFitPoint[]` (x, y, outlier, color, marker, stdev) plus fit configuration (fitFunction, parameters, colors, showFitLine, clickToToggle, droplines, etc.).
|
|
43
43
|
|
|
44
|
-
Legacy XML format (3DX `<chart>...</chart>`) is auto-detected and converted to JSON via `fit-parser.ts`.
|
|
45
|
-
|
|
46
44
|
Options cascade: **DataFrame tags → Column tags → Cell JSON → Series defaults**, merged at render time.
|
|
47
45
|
|
|
46
|
+
## Curve Converter Architecture
|
|
47
|
+
|
|
48
|
+
The Curves package supports **multiple curve data formats** through a dynamic converter system. The central format is the native IFitChartData JSON. Other formats (XML 3DX, compact dose-response, PZFX, etc.) are converted to native format on-the-fly via registered converters.
|
|
49
|
+
|
|
50
|
+
### How It Works
|
|
51
|
+
|
|
52
|
+
1. **Detection**: Semantic type detectors in `detectors.js` identify curve data in columns. Each detector:
|
|
53
|
+
- Sets `col.semType = 'fit'`
|
|
54
|
+
- For non-native formats, sets column tag `.%curve-format` to a friendly format name (e.g. `3dx`, `compact-dr`, `pzfx`)
|
|
55
|
+
- If no format tag is set, the data is assumed to be in native IFitChartData JSON format
|
|
56
|
+
|
|
57
|
+
2. **Conversion**: When a cell value needs to be parsed, `parseCellValue()` in `curve-converter.ts`:
|
|
58
|
+
- Checks the column's `.%curve-format` tag for the format name
|
|
59
|
+
- If present, looks up the converter function by format name in the registry and applies it
|
|
60
|
+
- If absent, parses the value directly as JSON
|
|
61
|
+
- Results are cached in a value-based `DG.LruCache` keyed by `formatName||cellValue`
|
|
62
|
+
|
|
63
|
+
3. **Registration**: Converters are registered in `_initCurves()` via `registerCurveConverter(formatName, fn)`:
|
|
64
|
+
- Local converters (in this package) are registered directly by format name to avoid circular dependencies
|
|
65
|
+
- External converters (from other packages) are discovered via `initExternalConverters()` which finds DG functions tagged with `meta.role: curveConverter` and `meta.curveFormat: '<name>'`
|
|
66
|
+
|
|
67
|
+
### Key Constants
|
|
68
|
+
|
|
69
|
+
- `FitConstants.TAG_CURVE_FORMAT` = `'.%curve-format'` — column tag storing format name (e.g. `'3dx'`, `'compact-dr'`, `'pzfx'`)
|
|
70
|
+
- `FitConstants.FIT_SEM_TYPE` = `'fit'` — semantic type for fit curves
|
|
71
|
+
- `FitConstants.TAG_FIT_CHART_FORMAT` = `'.fitChartFormat'` — legacy tag for format identification
|
|
72
|
+
|
|
73
|
+
### Supported Formats
|
|
74
|
+
|
|
75
|
+
| Format | Detector | Format Name | File |
|
|
76
|
+
|--------|----------|-------------|------|
|
|
77
|
+
| **Native JSON** (IFitChartData) | `detectFit` — looks for `series` + `points` | None (native) | — |
|
|
78
|
+
| **XML 3DX** (`<chart>...</chart>`) | `detectXMLCurveChart` | `3dx` | `fit/converters/xml-converter.ts` |
|
|
79
|
+
| **Compact Dose-Response** (`{"p":..., "poi":...}`) | `detectCompactDoseResponse` | `compact-dr` | `fit/converters/compact-dr-converter.ts` |
|
|
80
|
+
| **PZFX** (GraphPad Prism XY) | `detectPzfxCurveChart` | `pzfx` | `fit/converters/pzfx-converter.ts` |
|
|
81
|
+
|
|
82
|
+
### Adding a New Format
|
|
83
|
+
|
|
84
|
+
To add support for a new curve format, use the `/add-curve-format` skill. In summary:
|
|
85
|
+
1. Create a converter function in `src/fit/converters/` that converts the format to native JSON
|
|
86
|
+
2. Add a detector in `detectors.js` that identifies the format and sets the converter tag
|
|
87
|
+
3. Register the converter in `_initCurves()` in `package.ts`
|
|
88
|
+
4. Add tests in `src/tests/converter-tests.ts`
|
|
89
|
+
|
|
48
90
|
## Architecture
|
|
49
91
|
|
|
50
92
|
### Entry Point — `src/package.ts`
|
|
@@ -52,122 +94,104 @@ Options cascade: **DataFrame tags → Column tags → Cell JSON → Series defau
|
|
|
52
94
|
`PackageFunctions` class registers all platform-visible functions via `@grok.decorators`:
|
|
53
95
|
|
|
54
96
|
**Initialization:**
|
|
55
|
-
- `_initCurves` — `@init`: registers `FitGridCellHandler
|
|
97
|
+
- `_initCurves` — `@init`: registers `FitGridCellHandler`, registers all local curve converters, discovers external converters
|
|
56
98
|
|
|
57
99
|
**Registered Functions:**
|
|
58
100
|
|
|
59
101
|
| Function | Decorator / Meta | Purpose |
|
|
60
102
|
|---|---|---|
|
|
61
103
|
| `curveFitDemo` | `@demo`, `demoPath: Curves \| Curve Fitting` | Loads demo CSV and opens table view |
|
|
62
|
-
| `dataToCurves` | `@func` | Programmatic API: converts well-level data
|
|
104
|
+
| `dataToCurves` | `@func` | Programmatic API: converts well-level data into a DataFrame with fitted curve JSON column |
|
|
63
105
|
| `dataToCurvesTopMenu` | `@func`, `top-menu: Data \| Curves \| Data to Curves` | Opens the Data to Curves dialog UI |
|
|
64
|
-
| `addStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Extracts a
|
|
65
|
-
| `addAggrStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` |
|
|
106
|
+
| `addStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Extracts a fit statistic from a specific series into a new float column |
|
|
107
|
+
| `addAggrStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Aggregates statistics across all series |
|
|
108
|
+
| `convertXmlCurveToJsonFunc` | `@func`, `role: curveConverter` | Returns XML 3DX converter function |
|
|
109
|
+
| `convertCompactDrToJsonFunc` | `@func`, `role: curveConverter` | Returns compact dose-response converter function |
|
|
110
|
+
| `convertPzfxToJsonFunc` | `@func`, `role: curveConverter` | Returns PZFX converter function |
|
|
111
|
+
|
|
112
|
+
### Converter Infrastructure — `src/fit/curve-converter.ts`
|
|
66
113
|
|
|
67
|
-
|
|
114
|
+
Central module for the converter system:
|
|
115
|
+
- `registerCurveConverter(nqName, fn)` — registers a converter function
|
|
116
|
+
- `initExternalConverters()` — discovers converters from external packages via `DG.Func.find({meta: {role: 'curveConverter'}})`
|
|
117
|
+
- `parseCellValue(cellValue, column)` — **the single entry point** for parsing any cell value; applies converter if needed
|
|
118
|
+
- `convertCellValue(cellValue, column)` — converts using registered converter, with value-based LRU caching
|
|
119
|
+
- `isNativeFormat(column)` / `hasConverter(column)` — check whether a column uses native or converted format
|
|
68
120
|
|
|
69
|
-
### Semantic Type
|
|
121
|
+
### Semantic Type Detectors — `detectors.js`
|
|
70
122
|
|
|
71
123
|
`CurvesPackageDetectors` detects columns with semantic type `fit`:
|
|
72
|
-
1. `detectXMLCurveChart` — matches
|
|
73
|
-
2. `detectFit` — matches JSON
|
|
124
|
+
1. `detectXMLCurveChart` — matches `<chart>...</chart>`, sets converter tag
|
|
125
|
+
2. `detectFit` — matches native JSON with `series` + `points`
|
|
126
|
+
3. `detectPzfxCurveChart` — matches PZFX XY table XML
|
|
127
|
+
4. `detectCompactDoseResponse` — matches compact DR JSON with `p` + `poi` fields
|
|
74
128
|
|
|
75
129
|
### Cell Renderer — `src/fit/fit-renderer.ts`
|
|
76
130
|
|
|
77
131
|
`FitChartCellRenderer` (extends `DG.GridCellRenderer`) — the main grid cell renderer for `fit` cells:
|
|
78
|
-
- **Caching**: three `DG.LruCache` instances: `parsedCurves` (parsed
|
|
79
|
-
- **render()**: parses cell
|
|
80
|
-
- **onClick()**: toggles outlier status on points (
|
|
132
|
+
- **Caching**: three `DG.LruCache` instances: `parsedCurves` (parsed IFitChartData), `fittedCurves` (fitted curve results), `curvesDataPoints` (extracted data points)
|
|
133
|
+
- **render()**: parses cell via `parseCellValue()` → renders axes, fit lines, points, confidence intervals, droplines, statistics, title, legend
|
|
134
|
+
- **onClick()**: toggles outlier status on points (native format only), updates dependent statistics columns
|
|
81
135
|
- **onDoubleClick()**: opens `inspectCurve` dialog (resizable chart editor)
|
|
82
|
-
- **onMouseMove()**: shows tooltip with x/y values on point hover
|
|
83
|
-
-
|
|
136
|
+
- **onMouseMove()**: shows tooltip with x/y values on point hover
|
|
137
|
+
- Outlier toggling is only available for native format columns (`isNativeFormat()`)
|
|
84
138
|
|
|
85
139
|
Key helper functions:
|
|
86
|
-
- `getOrCreateParsedChartData(cell)` — cached
|
|
140
|
+
- `getOrCreateParsedChartData(cell)` — cached parse with options merge (DF → Column → Cell cascade)
|
|
87
141
|
- `getOrCreateCachedFitCurve(series, ...)` — cached Nelder-Mead fit
|
|
88
142
|
- `substituteZeroes(data)` — replaces x=0 with calculated substitute when logX is enabled
|
|
89
|
-
- `setOutlier(gridCell, point, ...)` — toggles outlier, updates cell JSON, fires custom event
|
|
90
|
-
- `inspectCurve(gridCell)` — opens a dialog with a `GridCellWidget` for interactive chart editing
|
|
143
|
+
- `setOutlier(gridCell, point, ...)` — toggles outlier, updates cell JSON, fires custom event
|
|
91
144
|
- `layoutChart(rect, ...)` — computes viewport, xAxis, yAxis rectangles with margins
|
|
92
|
-
- `mergeChartOptions(...)` / `mergeSeries(...)` — combine options/series from multiple cells
|
|
93
|
-
- `mergeProperties(properties, source, target)` — cascading property merge
|
|
94
145
|
|
|
95
146
|
### Property Panel — `src/fit/fit-grid-cell-handler.ts`
|
|
96
147
|
|
|
97
148
|
`FitGridCellHandler` (extends `DG.ObjectHandler`) — renders the context panel when a fit cell is selected:
|
|
98
|
-
- **Options pane**: switch level (Dataframe/Column/Cell), series
|
|
149
|
+
- **Options pane**: switch level (Dataframe/Column/Cell), series and chart options
|
|
99
150
|
- **Chart pane**: enlarged `GridCellWidget` rendering
|
|
100
|
-
- **Fit pane**:
|
|
101
|
-
|
|
102
|
-
Also contains:
|
|
103
|
-
- `calculateSeriesStats()` — computes `FitStatistics` for a single series (uses cached fit curve)
|
|
104
|
-
- `getChartDataAggrStats()` — aggregates statistics across all series using DG.Stats
|
|
105
|
-
- `changeCurvesOptions()` — applies property changes at Dataframe/Column/Cell level
|
|
106
|
-
- `detectSettings()` — scans column to detect which options are custom per-cell vs default
|
|
151
|
+
- **Fit pane**: per-series or aggregated statistics with "+" buttons to extract stats as columns
|
|
152
|
+
- Uses `parseCellValue()` for format-agnostic cell parsing
|
|
107
153
|
|
|
108
154
|
### Rendering Utilities — `src/fit/render-utils.ts`
|
|
109
155
|
|
|
110
|
-
Low-level canvas drawing functions
|
|
156
|
+
Low-level canvas drawing functions using `CanvasRenderingContext2D`:
|
|
111
157
|
|
|
112
158
|
| Function | What it renders |
|
|
113
159
|
|---|---|
|
|
114
|
-
| `renderPoints` | Data points (circles, markers) and error bars
|
|
115
|
-
| `renderFitLine` | Fitted curve line (
|
|
116
|
-
| `renderConfidenceIntervals` | Shaded confidence bands
|
|
160
|
+
| `renderPoints` | Data points (circles, markers) and error bars |
|
|
161
|
+
| `renderFitLine` | Fitted curve line (solid/dotted/dashed/dashdotted) |
|
|
162
|
+
| `renderConfidenceIntervals` | Shaded confidence bands |
|
|
117
163
|
| `renderConnectDots` | Direct point-to-point line connections |
|
|
118
|
-
| `renderDroplines` | IC50 droplines
|
|
164
|
+
| `renderDroplines` | IC50 droplines |
|
|
119
165
|
| `renderStatistics` | In-chart text labels for selected statistics |
|
|
120
|
-
| `renderTitle` | Chart title
|
|
166
|
+
| `renderTitle` | Chart title |
|
|
121
167
|
| `renderAxesLabels` | X and Y axis name labels |
|
|
122
|
-
| `renderLegend` | Color-coded legend
|
|
168
|
+
| `renderLegend` | Color-coded legend |
|
|
123
169
|
|
|
124
|
-
|
|
170
|
+
### Converters — `src/fit/converters/`
|
|
125
171
|
|
|
126
|
-
|
|
172
|
+
Each converter is a pure function: `(value: string) => string` (raw cell value → native JSON string).
|
|
127
173
|
|
|
128
|
-
|
|
174
|
+
| File | Function | Source Format |
|
|
175
|
+
|------|----------|---------------|
|
|
176
|
+
| `xml-converter.ts` | `convertXmlCurveToJson` | XML 3DX `<chart>` documents |
|
|
177
|
+
| `compact-dr-converter.ts` | `convertCompactDrToJson` | Compact dose-response JSON (`{p, poi, mxr, mnr, hs, ...}`) |
|
|
178
|
+
| `pzfx-converter.ts` | `convertPzfxToJson` | GraphPad Prism PZFX XY tables |
|
|
129
179
|
|
|
130
|
-
###
|
|
180
|
+
### XML Parser — `src/fit/fit-parser.ts`
|
|
131
181
|
|
|
132
|
-
|
|
182
|
+
`convertXMLToIFitChartData(xmlText)` — parses legacy 3DX XML format `<chart>` documents into `IFitChartData`. Used by the XML converter. Reorders parameters from `[IC50, tan, max, min]` to `[max, tan, IC50, min]`.
|
|
133
183
|
|
|
134
|
-
|
|
135
|
-
- **Well Table Form**: table, assay, concentration, readout, batch ID, run ID, compound ID, target entity, outliers, additional columns (auto-detects columns by name heuristics)
|
|
136
|
-
- **Parent Table Form**: optional table with pre-fit parameters (Max/Hill/Inflection/Min), reported IC50, qualified IC50, experiment ID, qualifier, fit function selection (4PL dose-response or 4PL regression), use-prefit-params toggle
|
|
137
|
-
- **Join Editor**: columns to join well-level and parent-level data
|
|
138
|
-
- Supports dialog history for re-running with same settings
|
|
184
|
+
### Data to Curves — `src/fit/data-to-curves.ts`
|
|
139
185
|
|
|
140
|
-
|
|
141
|
-
1. Groups well-level rows by compound|assay|target|run (or custom join column)
|
|
142
|
-
2. Builds `IFitSeries` per curve with points sorted by x, outlier flags, per-run marker types, categorical colors
|
|
143
|
-
3. Assigns pre-fit parameters from parent table if available
|
|
144
|
-
4. Creates result DataFrame with: `Fitted Curve` column (JSON, semType=fit), `Compound|Assay|Target` grouping column, info columns (assay, batch, compound, target, run, reported IC50, etc.)
|
|
145
|
-
5. Computes aggregated stats: max percent inhibition, geomean IC50, standard deviation, total/reported result counts
|
|
146
|
-
6. Auto-adds calculated statistics columns (IC50, Max, Min, Hill, AUC) if no parent table
|
|
147
|
-
7. Sets up layout: trellis plot with MultiCurveViewer, selected curves grid, overlay viewer
|
|
186
|
+
The main data transformation pipeline. `convertDataToCurves()` groups well-level assay data by compound|assay|target|run and builds fitted curve JSON.
|
|
148
187
|
|
|
149
188
|
### Multi-Curve Viewer — `src/fit/multi-curve-viewer.ts`
|
|
150
189
|
|
|
151
|
-
`MultiCurveViewer` (extends `DG.JsViewer`) — superimposes curves from multiple rows/columns on one chart
|
|
152
|
-
- Properties: `curvesColumnNames` (column list), `legendColumnName`, `showSelectedRowsCurves`, `showCurrentRowCurve`, `showMouseOverRowCurve`, `mergeColumnSeries`, `showOutliers`, plus all `IFitChartOptions` properties
|
|
153
|
-
- Reacts to: current cell change, mouse-over row, selection change (debounced 50ms)
|
|
154
|
-
- Merges chart options from all visible cells, assigns categorical colors, adjusts opacity for large selections
|
|
155
|
-
- Supports trellis mode (uses filter instead of selection/current)
|
|
156
|
-
- `fromChartData(chartData)` — static factory for standalone use
|
|
157
|
-
|
|
158
|
-
### Fit Inspection — `src/fit/fit-inspection.ts`
|
|
159
|
-
|
|
160
|
-
`inspectSeries(series, fitFunctionName)` — creates a temporary single-row DataFrame with the series as a fit cell, opens it in the inspect dialog with click-to-toggle and IC50 droplines. Used for programmatic curve inspection.
|
|
161
|
-
|
|
162
|
-
### Demo — `src/fit/fit-demo.ts`
|
|
163
|
-
|
|
164
|
-
- `createSigmoidPoints(length, step, pointsPerX)` — generates random sigmoid data with noise
|
|
165
|
-
- `createDemoDataFrame(rowCount, chartsCount, chartsPerCell)` — builds a full demo DataFrame with multiple fit columns
|
|
166
|
-
- `curveDemo()` — loads `files/curves-demo.csv` and opens it
|
|
190
|
+
`MultiCurveViewer` (extends `DG.JsViewer`) — superimposes curves from multiple rows/columns on one chart. Supports trellis mode, selection/current/mouseover tracking, and legend columns.
|
|
167
191
|
|
|
168
|
-
###
|
|
192
|
+
### PZFX Parser — `src/formats/pzfx/pzfx-parser.ts`
|
|
169
193
|
|
|
170
|
-
|
|
194
|
+
Parses GraphPad Prism `.pzfx` files. Also used by the PZFX converter and the file viewer/handler.
|
|
171
195
|
|
|
172
196
|
## Tests — `src/tests/`
|
|
173
197
|
|
|
@@ -175,59 +199,67 @@ Test entry point: `src/package-test.ts` — imports all test files.
|
|
|
175
199
|
|
|
176
200
|
| File | What it tests |
|
|
177
201
|
|---|---|
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
202
|
+
| `detector-tests.ts` | Semantic type detection for all formats (JSON, XML, compact DR, PZFX) |
|
|
203
|
+
| `converter-tests.ts` | All converters (XML, compact DR, PZFX), caching, format detection, rendering integration |
|
|
204
|
+
| `fit-tests.ts` | Core fitting algorithms (sigmoid, linear, log-linear, exponential, polynomial) |
|
|
205
|
+
| `curves-cell-renderer-tests.ts` | Cell renderer creation and rendering performance |
|
|
206
|
+
| `transform-tests.ts` | Viewport coordinate transformations |
|
|
207
|
+
| `pzfx-tests.ts` | PZFX file parser |
|
|
182
208
|
|
|
183
209
|
## Source Structure
|
|
184
210
|
|
|
185
211
|
```
|
|
186
212
|
src/
|
|
187
|
-
package.ts — Entry point, PackageFunctions,
|
|
213
|
+
package.ts — Entry point, PackageFunctions, converter registration
|
|
188
214
|
package.g.ts — Auto-generated function wrappers (DO NOT EDIT)
|
|
189
|
-
package-api.ts — Auto-generated API namespace (
|
|
215
|
+
package-api.ts — Auto-generated API namespace (DO NOT EDIT)
|
|
190
216
|
package-test.ts — Test entry point
|
|
191
217
|
fit/
|
|
218
|
+
curve-converter.ts — Converter registry, LRU cache, parseCellValue() entry point
|
|
192
219
|
fit-renderer.ts — FitChartCellRenderer, caching, chart layout, merging
|
|
193
220
|
fit-grid-cell-handler.ts — FitGridCellHandler (property panel), stats calculation
|
|
194
221
|
render-utils.ts — Canvas drawing functions (points, lines, CIs, droplines, legend)
|
|
195
|
-
fit-parser.ts — XML 3DX → IFitChartData converter
|
|
222
|
+
fit-parser.ts — XML 3DX → IFitChartData parser (used by xml-converter)
|
|
196
223
|
data-to-curves.ts — Data to Curves pipeline (UI dialog + conversion logic)
|
|
197
224
|
multi-curve-viewer.ts — MultiCurveViewer (overlay viewer)
|
|
198
225
|
fit-inspection.ts — inspectSeries helper
|
|
199
226
|
fit-demo.ts — Demo data generation and demo entry point
|
|
227
|
+
converters/
|
|
228
|
+
xml-converter.ts — XML 3DX format converter
|
|
229
|
+
compact-dr-converter.ts — Compact dose-response JSON converter
|
|
230
|
+
pzfx-converter.ts — PZFX (GraphPad Prism) format converter
|
|
231
|
+
formats/
|
|
232
|
+
pzfx/
|
|
233
|
+
pzfx-parser.ts — PZFX file parser
|
|
200
234
|
tests/
|
|
235
|
+
detector-tests.ts — Semantic type detector tests (all formats)
|
|
236
|
+
converter-tests.ts — Converter tests (all formats, caching, integration)
|
|
201
237
|
fit-tests.ts — Fitting algorithm tests
|
|
202
|
-
detector-tests.ts — Semantic type detector tests
|
|
203
238
|
curves-cell-renderer-tests.ts — Renderer benchmarks
|
|
204
239
|
transform-tests.ts — Viewport transform tests
|
|
240
|
+
pzfx-tests.ts — PZFX parser tests
|
|
205
241
|
scripts/
|
|
206
242
|
calculateMSR.py — MSR calculation (Python, statsmodels)
|
|
207
243
|
files/
|
|
208
244
|
curves-demo.csv — Demo data
|
|
209
|
-
detectors.js — Semantic type detectors (
|
|
245
|
+
detectors.js — Semantic type detectors (all curve formats)
|
|
210
246
|
```
|
|
211
247
|
|
|
212
248
|
## Quick Lookups
|
|
213
249
|
|
|
214
250
|
| Looking for... | Check first |
|
|
215
251
|
|---|---|
|
|
252
|
+
| Adding a new curve format | Use `/add-curve-format` skill |
|
|
253
|
+
| Converter infrastructure | `src/fit/curve-converter.ts` |
|
|
254
|
+
| Existing converters | `src/fit/converters/` |
|
|
216
255
|
| Function/demo/init registration | `src/package.ts` |
|
|
217
|
-
| Cell renderer (render, click, tooltip) | `src/fit/fit-renderer.ts`
|
|
218
|
-
| Property panel (options, stats, chart) | `src/fit/fit-grid-cell-handler.ts`
|
|
256
|
+
| Cell renderer (render, click, tooltip) | `src/fit/fit-renderer.ts` |
|
|
257
|
+
| Property panel (options, stats, chart) | `src/fit/fit-grid-cell-handler.ts` |
|
|
219
258
|
| Canvas drawing (points, lines, axes) | `src/fit/render-utils.ts` |
|
|
220
259
|
| Data to Curves dialog & conversion | `src/fit/data-to-curves.ts` |
|
|
221
260
|
| Multi-curve overlay viewer | `src/fit/multi-curve-viewer.ts` |
|
|
222
261
|
| XML 3DX format parsing | `src/fit/fit-parser.ts` |
|
|
223
|
-
| Inspect/edit a single curve | `src/fit/fit-inspection.ts` + `inspectCurve` in `fit-renderer.ts` |
|
|
224
262
|
| Fit data types (IFitChartData, etc.) | `@datagrok-libraries/statistics/src/fit/fit-curve.ts` |
|
|
225
|
-
| Fit functions & optimizer | `@datagrok-libraries/statistics/src/fit/fit-data.ts` |
|
|
226
263
|
| Constants (tags, sizes, thresholds) | `@datagrok-libraries/statistics/src/fit/const.ts` |
|
|
227
|
-
| New fit API (FitFunction classes) | `@datagrok-libraries/statistics/src/fit/new-fit-API.ts` |
|
|
228
|
-
| Viewport (coordinate transforms) | `@datagrok-libraries/utils/src/transform.ts` |
|
|
229
264
|
| Semantic type detection | `detectors.js` |
|
|
230
|
-
| MSR calculation (Python) | `scripts/calculateMSR.py` |
|
|
231
|
-
| Auto-generated function wrappers | `src/package.g.ts` / `src/package-api.ts` |
|
|
232
265
|
| Test entry point | `src/package-test.ts` |
|
|
233
|
-
| Demo data | `files/curves-demo.csv` |
|
package/detectors.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const FIT_SEM_TYPE = 'fit';
|
|
9
9
|
const TAG_FIT_CHART_FORMAT = '.fitChartFormat';
|
|
10
10
|
const TAG_FIT_CHART_FORMAT_3DX = '3dx';
|
|
11
|
+
const TAG_CURVE_FORMAT = '.%curve-format';
|
|
11
12
|
const likelyPNGColNames = ['image', 'png', 'thumbnail', 'img', 'glyph', 'icon', 'picture', 'photo'];
|
|
12
13
|
/// <reference path="../../globals.d.ts" />
|
|
13
14
|
class CurvesPackageDetectors extends DG.Package {
|
|
@@ -17,6 +18,7 @@ class CurvesPackageDetectors extends DG.Package {
|
|
|
17
18
|
detectXMLCurveChart(col) {
|
|
18
19
|
if (DG.Detector.sampleCategories(col, (s) => s.startsWith('<chart>') && s.endsWith('</chart>'), 1)) {
|
|
19
20
|
col.setTag(TAG_FIT_CHART_FORMAT, TAG_FIT_CHART_FORMAT_3DX);
|
|
21
|
+
col.setTag(TAG_CURVE_FORMAT, '3dx');
|
|
20
22
|
col.semType = FIT_SEM_TYPE;
|
|
21
23
|
return col.semType;
|
|
22
24
|
}
|
|
@@ -35,4 +37,39 @@ class CurvesPackageDetectors extends DG.Package {
|
|
|
35
37
|
}
|
|
36
38
|
return null;
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
//meta.role: semTypeDetector
|
|
42
|
+
//input: column col
|
|
43
|
+
//output: string semType
|
|
44
|
+
detectPzfxCurveChart(col) {
|
|
45
|
+
if (DG.Detector.sampleCategories(col, (s) => {
|
|
46
|
+
return s.includes('<Table') && s.includes('TableType="XY"') && s.includes('<XColumn');
|
|
47
|
+
}, 1)) {
|
|
48
|
+
col.setTag(TAG_CURVE_FORMAT, 'pzfx');
|
|
49
|
+
col.semType = FIT_SEM_TYPE;
|
|
50
|
+
return col.semType;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//meta.role: semTypeDetector
|
|
56
|
+
//input: column col
|
|
57
|
+
//output: string semType
|
|
58
|
+
detectCompactDoseResponse(col) {
|
|
59
|
+
if (DG.Detector.sampleCategories(col, (s) => {
|
|
60
|
+
try {
|
|
61
|
+
if (!s.includes('"p"') || !s.includes('"poi"'))
|
|
62
|
+
return false;
|
|
63
|
+
const obj = JSON.parse(s);
|
|
64
|
+
return obj.p !== undefined && Array.isArray(obj.p) && obj.poi !== undefined;
|
|
65
|
+
} catch (_e) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}, 1)) {
|
|
69
|
+
col.setTag(TAG_CURVE_FORMAT, 'compact-dr');
|
|
70
|
+
col.semType = FIT_SEM_TYPE;
|
|
71
|
+
return col.semType;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
38
75
|
}
|