@datagrok/curves 1.11.0 → 1.12.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.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,18 @@
1
1
  # Curves changelog
2
2
 
3
+ ## 1.12.0 (2026-04-02)
4
+
5
+ ### Features
6
+
7
+ * Added PZFX (GraphPad Prism) file viewer and handler
8
+ * Added dynamically extendable format support
9
+
3
10
  ## 1.11.0 (2026-03-13)
4
11
 
12
+ ### Features
13
+
14
+ * Added editable GridCellWidget support
15
+
5
16
  ## 1.10.15 (2025-12-02)
6
17
 
7
18
  * Png Renderer: Fix flickering and moved to PowerGrid
package/CLAUDE.md CHANGED
@@ -1,23 +1,11 @@
1
1
  # CLAUDE.md
2
2
 
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
3
  ## Overview
6
4
 
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 as JSON/XML 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.).
5
+ **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
6
 
9
7
  Category: **Visualizations**. Top menu: `Data | Curves | ...`.
10
8
 
11
- ## Build Commands
12
-
13
- ```bash
14
- npm install
15
- npm run build # grok api && grok check --soft && webpack
16
- npm run test # grok test
17
- npm run build-all # Builds js-api → utils → statistics → this package
18
- npm run link-all # Links datagrok-api, @datagrok-libraries/utils, @datagrok-libraries/statistics
19
- ```
20
-
21
9
  ## Key Dependencies
22
10
 
23
11
  - `@datagrok-libraries/statistics` — **core fitting engine**: defines `IFitChartData`, `IFitSeries`, `IFitChartOptions`, `IFitPoint`, `FitStatistics`, `FitCurve`, `FitFunction` classes, Nelder-Mead optimizer, sigmoid/linear/log-linear/exponential/4PL fit functions, confidence intervals, box-plot statistics, and `FitConstants` (tags, sizing, thresholds)
@@ -31,7 +19,7 @@ npm run link-all # Links datagrok-api, @datagrok-libraries/utils, @dat
31
19
 
32
20
  ### Data Model (from `@datagrok-libraries/statistics`)
33
21
 
34
- Cell values are JSON strings conforming to `IFitChartData`:
22
+ The **native format** for curve data in cells is JSON conforming to `IFitChartData`:
35
23
  ```
36
24
  IFitChartData {
37
25
  chartOptions?: IFitChartOptions // axes bounds, log scale, title, axis names, showStatistics
@@ -41,10 +29,52 @@ IFitChartData {
41
29
  ```
42
30
  Each `IFitSeries` has `points: IFitPoint[]` (x, y, outlier, color, marker, stdev) plus fit configuration (fitFunction, parameters, colors, showFitLine, clickToToggle, droplines, etc.).
43
31
 
44
- Legacy XML format (3DX `<chart>...</chart>`) is auto-detected and converted to JSON via `fit-parser.ts`.
45
-
46
32
  Options cascade: **DataFrame tags → Column tags → Cell JSON → Series defaults**, merged at render time.
47
33
 
34
+ ## Curve Converter Architecture
35
+
36
+ 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.
37
+
38
+ ### How It Works
39
+
40
+ 1. **Detection**: Semantic type detectors in `detectors.js` identify curve data in columns. Each detector:
41
+ - Sets `col.semType = 'fit'`
42
+ - For non-native formats, sets column tag `.%curve-format` to a friendly format name (e.g. `3dx`, `compact-dr`, `pzfx`)
43
+ - If no format tag is set, the data is assumed to be in native IFitChartData JSON format
44
+
45
+ 2. **Conversion**: When a cell value needs to be parsed, `parseCellValue()` in `curve-converter.ts`:
46
+ - Checks the column's `.%curve-format` tag for the format name
47
+ - If present, looks up the converter function by format name in the registry and applies it
48
+ - If absent, parses the value directly as JSON
49
+ - Results are cached in a value-based `DG.LruCache` keyed by `formatName||cellValue`
50
+
51
+ 3. **Registration**: Converters are registered in `_initCurves()` via `registerCurveConverter(formatName, fn)`:
52
+ - Local converters (in this package) are registered directly by format name to avoid circular dependencies
53
+ - External converters (from other packages) are discovered via `initExternalConverters()` which finds DG functions tagged with `meta.role: curveConverter` and `meta.curveFormat: '<name>'`
54
+
55
+ ### Key Constants
56
+
57
+ - `FitConstants.TAG_CURVE_FORMAT` = `'.%curve-format'` — column tag storing format name (e.g. `'3dx'`, `'compact-dr'`, `'pzfx'`)
58
+ - `FitConstants.FIT_SEM_TYPE` = `'fit'` — semantic type for fit curves
59
+ - `FitConstants.TAG_FIT_CHART_FORMAT` = `'.fitChartFormat'` — legacy tag for format identification
60
+
61
+ ### Supported Formats
62
+
63
+ | Format | Detector | Format Name | File |
64
+ |--------|----------|-------------|------|
65
+ | **Native JSON** (IFitChartData) | `detectFit` — looks for `series` + `points` | None (native) | — |
66
+ | **XML 3DX** (`<chart>...</chart>`) | `detectXMLCurveChart` | `3dx` | `fit/converters/xml-converter.ts` |
67
+ | **Compact Dose-Response** (`{"p":..., "poi":...}`) | `detectCompactDoseResponse` | `compact-dr` | `fit/converters/compact-dr-converter.ts` |
68
+ | **PZFX** (GraphPad Prism XY) | `detectPzfxCurveChart` | `pzfx` | `fit/converters/pzfx-converter.ts` |
69
+
70
+ ### Adding a New Format
71
+
72
+ To add support for a new curve format, use the `/add-curve-format` skill. In summary:
73
+ 1. Create a converter function in `src/fit/converters/` that converts the format to native JSON
74
+ 2. Add a detector in `detectors.js` that identifies the format and sets the converter tag
75
+ 3. Register the converter in `_initCurves()` in `package.ts`
76
+ 4. Add tests in `src/tests/converter-tests.ts`
77
+
48
78
  ## Architecture
49
79
 
50
80
  ### Entry Point — `src/package.ts`
@@ -52,122 +82,104 @@ Options cascade: **DataFrame tags → Column tags → Cell JSON → Series defau
52
82
  `PackageFunctions` class registers all platform-visible functions via `@grok.decorators`:
53
83
 
54
84
  **Initialization:**
55
- - `_initCurves` — `@init`: registers `FitGridCellHandler` as an `ObjectHandler` for grid cell property panels
85
+ - `_initCurves` — `@init`: registers `FitGridCellHandler`, registers all local curve converters, discovers external converters
56
86
 
57
87
  **Registered Functions:**
58
88
 
59
89
  | Function | Decorator / Meta | Purpose |
60
90
  |---|---|---|
61
91
  | `curveFitDemo` | `@demo`, `demoPath: Curves \| Curve Fitting` | Loads demo CSV and opens table view |
62
- | `dataToCurves` | `@func` | Programmatic API: converts well-level data (concentration, readout, batch/compound/assay/run IDs) into a DataFrame with fitted curve JSON column. Supports parent-table join for pre-fit parameters, reported IC50s, etc. |
92
+ | `dataToCurves` | `@func` | Programmatic API: converts well-level data into a DataFrame with fitted curve JSON column |
63
93
  | `dataToCurvesTopMenu` | `@func`, `top-menu: Data \| Curves \| Data to Curves` | Opens the Data to Curves dialog UI |
64
- | `addStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Extracts a single fit statistic (e.g., IC50, AUC, R²) from a specific series into a new float column |
65
- | `addAggrStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Same but aggregates across all series using a DG.Stats aggregation (min, max, avg, med, etc.) |
94
+ | `addStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Extracts a fit statistic from a specific series into a new float column |
95
+ | `addAggrStatisticsColumn` | `@func`, `vectorFunc`, `role: transform` | Aggregates statistics across all series |
96
+ | `convertXmlCurveToJsonFunc` | `@func`, `role: curveConverter` | Returns XML 3DX converter function |
97
+ | `convertCompactDrToJsonFunc` | `@func`, `role: curveConverter` | Returns compact dose-response converter function |
98
+ | `convertPzfxToJsonFunc` | `@func`, `role: curveConverter` | Returns PZFX converter function |
99
+
100
+ ### Converter Infrastructure — `src/fit/curve-converter.ts`
66
101
 
67
- **Exports**: `_package`, `Sync` (sequential promise runner), auto-generated wrappers from `package.g.ts`
102
+ Central module for the converter system:
103
+ - `registerCurveConverter(nqName, fn)` — registers a converter function
104
+ - `initExternalConverters()` — discovers converters from external packages via `DG.Func.find({meta: {role: 'curveConverter'}})`
105
+ - `parseCellValue(cellValue, column)` — **the single entry point** for parsing any cell value; applies converter if needed
106
+ - `convertCellValue(cellValue, column)` — converts using registered converter, with value-based LRU caching
107
+ - `isNativeFormat(column)` / `hasConverter(column)` — check whether a column uses native or converted format
68
108
 
69
- ### Semantic Type Detector — `detectors.js`
109
+ ### Semantic Type Detectors — `detectors.js`
70
110
 
71
111
  `CurvesPackageDetectors` detects columns with semantic type `fit`:
72
- 1. `detectXMLCurveChart` — matches strings starting with `<chart>` and ending with `</chart>`, sets tag `.fitChartFormat = '3dx'`
73
- 2. `detectFit` — matches JSON strings containing both `series` and `points` keywords
112
+ 1. `detectXMLCurveChart` — matches `<chart>...</chart>`, sets converter tag
113
+ 2. `detectFit` — matches native JSON with `series` + `points`
114
+ 3. `detectPzfxCurveChart` — matches PZFX XY table XML
115
+ 4. `detectCompactDoseResponse` — matches compact DR JSON with `p` + `poi` fields
74
116
 
75
117
  ### Cell Renderer — `src/fit/fit-renderer.ts`
76
118
 
77
119
  `FitChartCellRenderer` (extends `DG.GridCellRenderer`) — the main grid cell renderer for `fit` cells:
78
- - **Caching**: three `DG.LruCache` instances: `parsedCurves` (parsed JSON), `fittedCurves` (fitted curve results), `curvesDataPoints` (extracted data points)
79
- - **render()**: parses cell → gets chart data → renders axes, fit lines, points, confidence intervals, droplines, statistics, title, legend
80
- - **onClick()**: toggles outlier status on points (if `clickToToggle` is enabled), updates dependent statistics columns
120
+ - **Caching**: three `DG.LruCache` instances: `parsedCurves` (parsed IFitChartData), `fittedCurves` (fitted curve results), `curvesDataPoints` (extracted data points)
121
+ - **render()**: parses cell via `parseCellValue()` → renders axes, fit lines, points, confidence intervals, droplines, statistics, title, legend
122
+ - **onClick()**: toggles outlier status on points (native format only), updates dependent statistics columns
81
123
  - **onDoubleClick()**: opens `inspectCurve` dialog (resizable chart editor)
82
- - **onMouseMove()**: shows tooltip with x/y values on point hover; shows enlarged chart tooltip for small cells
83
- - **Visibility thresholds**: axes, labels, title, legend, points, droplines each have minimum pixel-size thresholds from `FitConstants`
124
+ - **onMouseMove()**: shows tooltip with x/y values on point hover
125
+ - Outlier toggling is only available for native format columns (`isNativeFormat()`)
84
126
 
85
127
  Key helper functions:
86
- - `getOrCreateParsedChartData(cell)` — cached JSON parse with options merge (DF → Column → Cell cascade)
128
+ - `getOrCreateParsedChartData(cell)` — cached parse with options merge (DF → Column → Cell cascade)
87
129
  - `getOrCreateCachedFitCurve(series, ...)` — cached Nelder-Mead fit
88
130
  - `substituteZeroes(data)` — replaces x=0 with calculated substitute when logX is enabled
89
- - `setOutlier(gridCell, point, ...)` — toggles outlier, updates cell JSON, fires custom event, recalculates stats columns
90
- - `inspectCurve(gridCell)` — opens a dialog with a `GridCellWidget` for interactive chart editing
131
+ - `setOutlier(gridCell, point, ...)` — toggles outlier, updates cell JSON, fires custom event
91
132
  - `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
133
 
95
134
  ### Property Panel — `src/fit/fit-grid-cell-handler.ts`
96
135
 
97
136
  `FitGridCellHandler` (extends `DG.ObjectHandler`) — renders the context panel when a fit cell is selected:
98
- - **Options pane**: switch level (Dataframe/Column/Cell), series options (fit function, colors, markers, line style, confidence intervals), chart options (log scale, axes bounds, zeroes handling)
137
+ - **Options pane**: switch level (Dataframe/Column/Cell), series and chart options
99
138
  - **Chart pane**: enlarged `GridCellWidget` rendering
100
- - **Fit pane**: displays per-series or aggregated statistics (R², AUC, IC50, slope, top, bottom) with "+" buttons to extract each stat as a new column
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
139
+ - **Fit pane**: per-series or aggregated statistics with "+" buttons to extract stats as columns
140
+ - Uses `parseCellValue()` for format-agnostic cell parsing
107
141
 
108
142
  ### Rendering Utilities — `src/fit/render-utils.ts`
109
143
 
110
- Low-level canvas drawing functions, all using `CanvasRenderingContext2D`:
144
+ Low-level canvas drawing functions using `CanvasRenderingContext2D`:
111
145
 
112
146
  | Function | What it renders |
113
147
  |---|---|
114
- | `renderPoints` | Data points (circles, markers) and error bars (stdev whiskers) |
115
- | `renderFitLine` | Fitted curve line (with line style: solid/dotted/dashed/dashdotted) |
116
- | `renderConfidenceIntervals` | Shaded confidence bands around fit line |
148
+ | `renderPoints` | Data points (circles, markers) and error bars |
149
+ | `renderFitLine` | Fitted curve line (solid/dotted/dashed/dashdotted) |
150
+ | `renderConfidenceIntervals` | Shaded confidence bands |
117
151
  | `renderConnectDots` | Direct point-to-point line connections |
118
- | `renderDroplines` | IC50 droplines (dashed lines from axis to curve) |
152
+ | `renderDroplines` | IC50 droplines |
119
153
  | `renderStatistics` | In-chart text labels for selected statistics |
120
- | `renderTitle` | Chart title above the plot area |
154
+ | `renderTitle` | Chart title |
121
155
  | `renderAxesLabels` | X and Y axis name labels |
122
- | `renderLegend` | Color-coded legend with series names, markers, and optional column labels |
156
+ | `renderLegend` | Color-coded legend |
123
157
 
124
- Also: `getSeriesColor()`, candlestick/box-plot rendering (for replicate data visualization).
158
+ ### Converters — `src/fit/converters/`
125
159
 
126
- ### XML Parser — `src/fit/fit-parser.ts`
160
+ Each converter is a pure function: `(value: string) => string` (raw cell value → native JSON string).
127
161
 
128
- `convertXMLToIFitChartData(xmlText)` — parses legacy 3DX XML format `<chart>` documents into `IFitChartData`. Extracts grid bounds, axis labels, series parameters (reorders from `[IC50, tan, max, min]` to `[max, tan, IC50, min]`), points, and outlier masks.
162
+ | File | Function | Source Format |
163
+ |------|----------|---------------|
164
+ | `xml-converter.ts` | `convertXmlCurveToJson` | XML 3DX `<chart>` documents |
165
+ | `compact-dr-converter.ts` | `convertCompactDrToJson` | Compact dose-response JSON (`{p, poi, mxr, mnr, hs, ...}`) |
166
+ | `pzfx-converter.ts` | `convertPzfxToJson` | GraphPad Prism PZFX XY tables |
129
167
 
130
- ### Data to Curves — `src/fit/data-to-curves.ts`
168
+ ### XML Parser — `src/fit/fit-parser.ts`
131
169
 
132
- The main data transformation pipeline:
170
+ `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
171
 
134
- **`dataToCurvesUI()`** — dialog with two forms:
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
172
+ ### Data to Curves — `src/fit/data-to-curves.ts`
139
173
 
140
- **`convertDataToCurves()`** — core logic:
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
174
+ The main data transformation pipeline. `convertDataToCurves()` groups well-level assay data by compound|assay|target|run and builds fitted curve JSON.
148
175
 
149
176
  ### Multi-Curve Viewer — `src/fit/multi-curve-viewer.ts`
150
177
 
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
178
+ `MultiCurveViewer` (extends `DG.JsViewer`) — superimposes curves from multiple rows/columns on one chart. Supports trellis mode, selection/current/mouseover tracking, and legend columns.
167
179
 
168
- ### Python Script — `scripts/calculateMSR.py`
180
+ ### PZFX Parser — `src/formats/pzfx/pzfx-parser.ts`
169
181
 
170
- `Calculate MSR` — computes Minimum Significant Ratio using mixed-effects linear models (statsmodels). Groups by compound, assay, target entity; uses log10(IC50) with run dates as random effects. Falls back to simple variance calculation for small sample sizes. Top menu: `Data | Curves | Calculate MSR...`.
182
+ Parses GraphPad Prism `.pzfx` files. Also used by the PZFX converter and the file viewer/handler.
171
183
 
172
184
  ## Tests — `src/tests/`
173
185
 
@@ -175,59 +187,67 @@ Test entry point: `src/package-test.ts` — imports all test files.
175
187
 
176
188
  | File | What it tests |
177
189
  |---|---|
178
- | `fit-tests.ts` | Core fitting: `getSeriesFitFunction`, `getCurve`, `fitSeries` (sigmoid, linear, log-linear, exponential, polynomial), confidence intervals, statistics, benchmarks |
179
- | `detector-tests.ts` | Semantic type detection for JSON fit data and XML 3DX format |
180
- | `curves-cell-renderer-tests.ts` | Cell renderer creation and rendering performance benchmarks |
181
- | `transform-tests.ts` | Viewport coordinate transformations (world↔screen) |
190
+ | `detector-tests.ts` | Semantic type detection for all formats (JSON, XML, compact DR, PZFX) |
191
+ | `converter-tests.ts` | All converters (XML, compact DR, PZFX), caching, format detection, rendering integration |
192
+ | `fit-tests.ts` | Core fitting algorithms (sigmoid, linear, log-linear, exponential, polynomial) |
193
+ | `curves-cell-renderer-tests.ts` | Cell renderer creation and rendering performance |
194
+ | `transform-tests.ts` | Viewport coordinate transformations |
195
+ | `pzfx-tests.ts` | PZFX file parser |
182
196
 
183
197
  ## Source Structure
184
198
 
185
199
  ```
186
200
  src/
187
- package.ts — Entry point, PackageFunctions, Sync helper
201
+ package.ts — Entry point, PackageFunctions, converter registration
188
202
  package.g.ts — Auto-generated function wrappers (DO NOT EDIT)
189
- package-api.ts — Auto-generated API namespace (scripts, funcs)
203
+ package-api.ts — Auto-generated API namespace (DO NOT EDIT)
190
204
  package-test.ts — Test entry point
191
205
  fit/
206
+ curve-converter.ts — Converter registry, LRU cache, parseCellValue() entry point
192
207
  fit-renderer.ts — FitChartCellRenderer, caching, chart layout, merging
193
208
  fit-grid-cell-handler.ts — FitGridCellHandler (property panel), stats calculation
194
209
  render-utils.ts — Canvas drawing functions (points, lines, CIs, droplines, legend)
195
- fit-parser.ts — XML 3DX → IFitChartData converter
210
+ fit-parser.ts — XML 3DX → IFitChartData parser (used by xml-converter)
196
211
  data-to-curves.ts — Data to Curves pipeline (UI dialog + conversion logic)
197
212
  multi-curve-viewer.ts — MultiCurveViewer (overlay viewer)
198
213
  fit-inspection.ts — inspectSeries helper
199
214
  fit-demo.ts — Demo data generation and demo entry point
215
+ converters/
216
+ xml-converter.ts — XML 3DX format converter
217
+ compact-dr-converter.ts — Compact dose-response JSON converter
218
+ pzfx-converter.ts — PZFX (GraphPad Prism) format converter
219
+ formats/
220
+ pzfx/
221
+ pzfx-parser.ts — PZFX file parser
200
222
  tests/
223
+ detector-tests.ts — Semantic type detector tests (all formats)
224
+ converter-tests.ts — Converter tests (all formats, caching, integration)
201
225
  fit-tests.ts — Fitting algorithm tests
202
- detector-tests.ts — Semantic type detector tests
203
226
  curves-cell-renderer-tests.ts — Renderer benchmarks
204
227
  transform-tests.ts — Viewport transform tests
228
+ pzfx-tests.ts — PZFX parser tests
205
229
  scripts/
206
230
  calculateMSR.py — MSR calculation (Python, statsmodels)
207
231
  files/
208
232
  curves-demo.csv — Demo data
209
- detectors.js — Semantic type detectors (XML and JSON fit formats)
233
+ detectors.js — Semantic type detectors (all curve formats)
210
234
  ```
211
235
 
212
236
  ## Quick Lookups
213
237
 
214
238
  | Looking for... | Check first |
215
239
  |---|---|
240
+ | Adding a new curve format | Use `/add-curve-format` skill |
241
+ | Converter infrastructure | `src/fit/curve-converter.ts` |
242
+ | Existing converters | `src/fit/converters/` |
216
243
  | Function/demo/init registration | `src/package.ts` |
217
- | Cell renderer (render, click, tooltip) | `src/fit/fit-renderer.ts` (`FitChartCellRenderer`) |
218
- | Property panel (options, stats, chart) | `src/fit/fit-grid-cell-handler.ts` (`FitGridCellHandler`) |
244
+ | Cell renderer (render, click, tooltip) | `src/fit/fit-renderer.ts` |
245
+ | Property panel (options, stats, chart) | `src/fit/fit-grid-cell-handler.ts` |
219
246
  | Canvas drawing (points, lines, axes) | `src/fit/render-utils.ts` |
220
247
  | Data to Curves dialog & conversion | `src/fit/data-to-curves.ts` |
221
248
  | Multi-curve overlay viewer | `src/fit/multi-curve-viewer.ts` |
222
249
  | 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
250
  | 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
251
  | 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
252
  | 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
253
  | Test entry point | `src/package-test.ts` |
233
- | Demo data | `files/curves-demo.csv` |
package/CREDITS.md ADDED
@@ -0,0 +1,79 @@
1
+ # Curves — Third-Party Libraries
2
+
3
+ The `@datagrok/curves` package is distributed under the MIT license that
4
+ covers the rest of the `public/` repository (see [`../../LICENSE.md`](../../LICENSE.md)).
5
+ It incorporates the open-source components listed below; this file reproduces
6
+ the attribution and notices required by their respective licenses.
7
+
8
+ All runtime JavaScript dependencies bundled into the published artifact are
9
+ under permissive licenses (MIT). No copyleft (GPL/LGPL/MPL) component is
10
+ bundled into the published Curves plugin.
11
+
12
+ ---
13
+
14
+ ## 1. Bundled in the published artifact (`dist/`)
15
+
16
+ ### jStat (1.9.x)
17
+
18
+ Statistical distributions library used for confidence-interval and goodness-of-fit
19
+ calculations on dose-response curves.
20
+
21
+ - Upstream: https://github.com/jstat/jstat
22
+ - License: **MIT**
23
+
24
+ ```
25
+ Copyright (c) 2013 jStat
26
+
27
+ Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ of this software and associated documentation files (the "Software"), to deal
29
+ in the Software without restriction, including without limitation the rights
30
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ copies of the Software, and to permit persons to whom the Software is
32
+ furnished to do so, subject to the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be included in
35
+ all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
43
+ THE SOFTWARE.
44
+ ```
45
+
46
+ (`@types/wu` is a TypeScript-only types stub for the `wu` external — no
47
+ runtime code is shipped from it. `eslint`, `eslint-config-google`, and the
48
+ `@typescript-eslint/*` packages are listed in `dependencies` but are
49
+ build-time-only and produce no bundled output.)
50
+
51
+ ---
52
+
53
+ ## 2. Linked at runtime via the Datagrok platform (webpack externals)
54
+
55
+ These libraries are not bundled into Curves's `dist/` — they are provided
56
+ once by the platform host and shared across all packages.
57
+
58
+ | Component | Version | License | Upstream |
59
+ |----------------------------------|---------|--------------|---------------------------------------------------|
60
+ | datagrok-api | 1.x | MIT | https://github.com/datagrok-ai/public |
61
+ | RxJS | 6.x | Apache-2.0 | https://github.com/ReactiveX/rxjs |
62
+ | cash-dom | 8.x | MIT | https://github.com/fabiospampinato/cash |
63
+ | Day.js | 1.x | MIT | https://github.com/iamkun/dayjs |
64
+ | ExcelJS | 4.x | MIT | https://github.com/exceljs/exceljs |
65
+
66
+ ---
67
+
68
+ ## 3. Development-only dependencies
69
+
70
+ Tools used during the build/test cycle (not in the runtime tree, not bundled):
71
+ the `datagrok-tools` CLI transitively pulls in `puppeteer-screen-recorder`,
72
+ which references `@ffmpeg-installer/ffmpeg` (LGPL-2.1) and
73
+ `@ffmpeg-installer/win32-x64` (GPLv3). These binaries are **not** redistributed
74
+ as part of the published Curves plugin and impose no obligation on users of
75
+ the plugin.
76
+
77
+ The `scripts/calculateMSR.py` Python script depends on `statsmodels` (BSD-3-Clause)
78
+ and runs on the Datagrok server's managed Python environment — it is not part
79
+ of the JavaScript bundle.
@@ -0,0 +1,29 @@
1
+ packageName: Curves
2
+ description: Dose-response curve fitting and statistics — fits 4PL/sigmoidal curves to concentration-readout data, extracts IC50/Hill/AUC/top/bottom per row, renders inline curve cells, and provides assay-plate and well-level workflows.
3
+ keywords:
4
+ - dose-response
5
+ - dose response
6
+ - curve fitting
7
+ - 4PL
8
+ - sigmoidal
9
+ - IC50
10
+ - EC50
11
+ - hill slope
12
+ - AUC
13
+ - intercept
14
+ - top
15
+ - bottom
16
+ - r-squared
17
+ - fit chart
18
+ - fit statistics
19
+ - assay plate
20
+ - assay readout
21
+ - well level
22
+ - data to curves
23
+ - pzfx
24
+ - prism
25
+ - 3dx
26
+ - compact-dr
27
+ - curve renderer
28
+ apiRef: src/package-api.ts
29
+ docsRef: README.md
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
  }