@datagrok/curves 1.12.2 → 1.13.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/CHANGELOG.md +77 -0
- package/CLAUDE.md +118 -15
- package/README.md +51 -4
- package/dist/package-test.js +11551 -8501
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +3368 -2022
- package/dist/package.js.map +1 -1
- package/files/demo/Assay_Curves.csv +43 -43
- package/package.json +2 -2
- package/scripts/calculateMSR.py +16 -7
- package/src/fit/data-to-curves.ts +10 -5
- package/src/fit/fit-chart-data.ts +323 -0
- package/src/fit/fit-grid-cell-handler.ts +98 -231
- package/src/fit/fit-inspection.ts +3 -3
- package/src/fit/fit-interaction.ts +181 -0
- package/src/fit/fit-layout.ts +64 -0
- package/src/fit/fit-legend.ts +292 -0
- package/src/fit/fit-options.ts +222 -0
- package/src/fit/fit-parser.ts +16 -5
- package/src/fit/fit-renderer.ts +180 -469
- package/src/fit/fit-statistics.ts +154 -0
- package/src/fit/multi-curve-viewer.ts +46 -20
- package/src/fit/render-utils.ts +208 -150
- package/src/package-api.ts +78 -0
- package/src/package-test.ts +6 -0
- package/src/package.g.ts +59 -11
- package/src/package.ts +97 -18
- package/src/tests/calculated-columns-tests.ts +299 -0
- package/src/tests/converter-tests.ts +23 -0
- package/src/tests/curve-data.ts +82 -0
- package/src/tests/fit-cache-tests.ts +128 -0
- package/src/tests/fit-tests.ts +310 -3
- package/src/tests/legend-tests.ts +243 -0
- package/src/tests/multi-curve-viewer-tests.ts +100 -0
- package/src/tests/panel-renderer-tests.ts +502 -0
- package/src/tests/project-tests.ts +99 -0
- package/src/tests/transform-tests.ts +3 -2
- package/test-console-output-1.log +347 -103
- package/test-record-1.mp4 +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,84 @@
|
|
|
2
2
|
|
|
3
3
|
## v.next
|
|
4
4
|
|
|
5
|
+
* Curves: Multi curve viewer: The axis names and the title are shown in the property panel, not left blank while the plot draws them. Clearing one now takes it off the plot, as it already did in the grid, rather than quietly falling back to what the data named
|
|
6
|
+
* Curves: Naming one axis draws that one. Both names were needed before either appeared, so clearing **X Axis Name** took the y name with it
|
|
7
|
+
* Curves: **Column Name** is no longer offered in the series options. The render stamps it on every paint so the legend can say which column a curve came from, so a name typed there was written into the cell and then overwritten before it was ever drawn
|
|
8
|
+
* Curves: A column whose `.%fit` tag is empty renders again - reading it parsed an empty string and threw on every cell
|
|
9
|
+
* GROK-20664: Curves: The statistics on a plot keep their font. They were drawn in whatever font the caller had last set on the canvas, since only the other parts of the chart named one - so opening the filter changed them, and scrolling the panel changed them back. Statistics and the labels that share their column are now written in the plot's own font
|
|
10
|
+
* GROK-20664: Curves: The statistics and droplines lists are shown whole in the property panel. A multi-choice is capped at 155px and always draws its scrollbar, which cut ten statistics down to six and put a second scrollbar inside a panel that already scrolls
|
|
11
|
+
* GROK-20662: Curves: **Fit function** names each function once, and no longer offers none. A custom JS function was listed twice - it registers itself the first time it is used, and the panel prepended it to that same registry - while the registry read by every other column was the one captured before any custom function had registered, so it could not be picked anywhere else. The list is now read where it is shown, so a function registered once can be used on any curve. The empty entry is gone with it: a series is fitted with what it names or with the default, so none was never a value to pick. Picking a custom function for another curve stores the notation that describes it rather than its name, so the curve still fits in a session that never loaded the column the function came from
|
|
12
|
+
* GROK-20662: Curves: Clearing the **Fit function** option no longer takes the column with it. A series left without one reached `getOrCreateFitFunction` as null, which read `.name` off it - so the cell renderer threw (a red cross in every cell of the column, blank in the next) and the property panel threw while listing the series options, leaving no way to set the function back. Naming none now names the default, as it does for data that never named one, and so does naming a function that no longer exists
|
|
13
|
+
* GROK-20659: Curves: Hovering `+N more` no longer lists every curve it stands for - 210 curves gave a tooltip 3882px tall in an 859px window, most of it off the screen. It lists as many rows as the window has room for (three quarters of its height) and counts the rest, and once it is listing several, a row is a label like the ones on the plot - a **Legend** column pointed at a curves column named every row with the cell's whole 1950-character JSON. Hovering a single row still says the whole of that name however long, since that is what it is for
|
|
14
|
+
* GROK-20661: Curves: Multi curve viewer: Adding a column widens the axes again. A range a cell declares for its own chart was merged into the overlay and then enforced, so `log min/max candlesticks` carrying `maxY: 8` capped every other column - `multiple prefit` reaches 8.12 and was drawn cut off. A declared range is now dropped when the combined series fall outside it; one that still contains them is kept, and the viewer's own **Min Y** / **Max Y** clamp as before
|
|
15
|
+
* GROK-20661: Curves: Setting one axis bound no longer un-pads the other three. Any bound at all made the whole rectangle exact, putting the opposite edge on the outermost point and cutting a curve that overshoots it - a fit peaking at 8.4 above points reaching 8.12. Each edge is now padded unless it is the one that was set
|
|
16
|
+
* GROK-20660: Curves: The axis names sit on the plot they name. The x name was drawn 5px left of centre and the y name 15px below it, both from constants added to the offset rather than to the margin. The same function also called `restore()` without a matching `save()`, so every cell that showed axis names leaked one canvas state - the cell clip was released before the legend was drawn, and the grid lost the state it had saved for the cell
|
|
17
|
+
* GROK-18886: Curves: A pipe inside a title survives. Every `|` was stripped from a cell before parsing, to rescue values a stray one breaks - which also ran identifiers together, so `compound_id 10||Collapse Assay||run_id 4` was drawn as `compound_id 10Collapse Assayrun_id 4`. The rescue now applies only to a value that yields nothing as it stands
|
|
18
|
+
* GROK-18886: Curves: Data to Curves names a group the way it reads - `compound_id 0 | Neuronal Health Assay | target_9` rather than `compound_id 0||Neuronal Health Assay||target_9||null`. Empty parts are dropped from the group column and the curve title; the key that identifies a group is untouched, so parent data still matches. The Assay Curves demo was regenerated to match
|
|
19
|
+
* GROK-18886: Curves: An outlier marker no longer swamps a small plot. At three times the point size it took an eighth of a trellis cell's height, so it is now capped against the plot it sits in
|
|
20
|
+
* GROK-18467: Curves: Multi curve viewer: A curve is fitted once instead of on every repaint. The viewer had no grid cell to key the fit cache on, so a trellis re-ran Nelder-Mead for every curve in every cell each time anything changed - on a 999-row table split into 25 cells, one option toggle blocked the browser for ~2.8s and cost the same again on the next toggle. Repeat interactions now take ~30ms. The viewer keeps its own cache, since its curves are not the grid's: it merges a cell's series and applies its own log options
|
|
21
|
+
* GROK-18467: Curves: A fit is no longer shared between a log plot and a linear one. The fit cache key named the cell but not the axes, so the same cell rendered in different spaces - a grid, a property panel and a trellis can differ - reused whichever fit was made first
|
|
22
|
+
* GROK-18166: Curves: Multi curve viewer: Declared the properties a trellis plot puts on its control panel - **Merge Column Series**, **Log X** and **Log Y**, the way a scatter plot offers X, Y, Color and Size. Editing them, or anything in the MultiCurveViewer tab of the property panel, now reaches every trellis cell and is kept in saved layouts
|
|
23
|
+
* GROK-20112: Curves: The legend picks the corner the curves leave freest, counting where points and fit lines actually landed and staying in the top right unless another corner is clearly emptier. Hovering a shortened name gives the whole of it, and hovering the `+N more` row gives every curve the legend could not fit, each in its own colour
|
|
24
|
+
* GROK-20112: Curves: The legend no longer buries the curves it names. A column holding a single curve gets no row of its own (the siRNA demo goes from eight rows to four), rows sit over a backdrop so they stay readable, a name too long for the corner is ellipsized and says the rest when hovered, and rows past the corner collapse into `+N more`. A name that two columns share is qualified with the column; two curves named alike in one column are left as the data has them. Legend code moved to `fit/fit-legend.ts`
|
|
25
|
+
* Curves: Added the **Show Legend** chart option - the curves can be left unnamed on any level, the way every other chart option cascades
|
|
26
|
+
* GROK-19028: Curves: Multi curve viewer: Merge Cell Series no longer rewrites the cells it reads. The viewer merged into the parsed chart data cached for the grid, so unchecking the box left the curves merged and the grid cell itself started rendering the merged series
|
|
27
|
+
* [#2101](https://github.com/datagrok-ai/public/issues/2101): Curves: Droplines accept the whole `ICxx` / `ECxx` family instead of `IC50` alone - a dropline marks the x at which the curve has travelled that fraction between its asymptotes. **IC10**, **IC20**, **IC50**, **IC80** and **IC90** are offered in the property panel, any other percentage works from the cell JSON. One that falls outside the plotted range is skipped, and several on one series are captioned
|
|
28
|
+
* [#2101](https://github.com/datagrok-ai/public/issues/2101): Curves: The statistics of a cell holding several curves can be summarised into one line, named as the extracted column is (`med ic50`). **Statistics mode** chooses between drawing them for each series, summarised, or both, and **Aggregation** picks the function. Both inputs are hidden for a single curve, which has nothing to summarise
|
|
29
|
+
* [#2101](https://github.com/datagrok-ai/public/issues/2101): Curves: Error bars now run from the marker's edge outwards with end caps, and are left out when the deviation is smaller than the marker rather than drawn inside it. Their line width is set explicitly instead of inheriting whatever the fit line or the droplines left behind
|
|
30
|
+
* [#2103](https://github.com/datagrok-ai/public/issues/2103), [#2101](https://github.com/datagrok-ai/public/issues/2101): Curves: Render custom labels on the plot and choose them in the property panel. A curve can carry values the fit cannot produce - a plate's Z prime, an assay name, a compound id - and they are drawn alongside the statistics: plot-level ones once in a neutral colour, per-curve ones with their series. The Labels input offers the names the cell actually carries, and plot-level labels combine across Dataframe, Column and Cell instead of the nearest level winning outright, so an assay name and a plate statistic can come from different levels
|
|
31
|
+
* Flow: Added Add Curve Statistic and Add Aggregated Curve Statistic, which take a real `column {semType: fit}` slot. The `addStatisticsColumn` / `addAggrStatisticsColumn` originals address the curve column by NAME — a free-text field with no picker and no filter — and stay as they are because the Fit pane and the Data to Curves pipeline call them by name as replayable transforms
|
|
32
|
+
* Curve statistics: The free-text `propName` and `aggrType` parameters now declare `choices:` and a default, on both the originals and the new twins
|
|
33
|
+
* Fit Dose-Response Curves: Constrained the column pickers by type (numerical for concentration/readout, categorical for the identifiers) and marked the seven mandatory columns `nullable: false` — a column parameter defaults to nullable, which read as optional and let a half-configured node run
|
|
34
|
+
* Calculate MSR: Added captions, descriptions, and column-type constraints to the five unconstrained mandatory column inputs
|
|
5
35
|
* GROK-20232: Fit renderer: degrade gracefully on malformed fit-cell JSON instead of throwing on every grid redraw
|
|
36
|
+
* GROK-17637: Statistics: A legacy x-space name (`interceptX`) that a fit function has no inflection field of its own for now reads as empty rather than as the raw parameter slot, which `toDataSpace` does not convert - a custom JS fit function with three or more parameters had reported it in log space under a logarithmic x axis. Every built-in resolves the name to a real field and is unaffected
|
|
37
|
+
* GROK-17637: Split the cell renderer: `fit/fit-layout.ts` holds the chart geometry and the size thresholds, `fit/fit-interaction.ts` the outlier toggle, tooltip, click handling and the editor dialog, leaving `fit/fit-renderer.ts` to assemble a chart onto a canvas
|
|
38
|
+
* GROK-17637: Statistics: An aggregation that is not converted back to data space keeps IC50/EC50 and reports them in fit space, as before this refactor - only pIC50, which is derived during the conversion, is dropped. They had been excluded outright, so a saved transform aggregating `interceptX` by stdev or count replayed into an empty column
|
|
39
|
+
* GROK-17637: Fit renderer: The IC50 dropline is located by the fit function's own parameter name rather than by parameter slot 2, so a two-parameter fit no longer draws it at NaN
|
|
40
|
+
* GROK-17637: Fit renderer: A series with `connectDots` and no explicit `showFitLine` is fitted before its statistics are drawn - the two sites disagreed on the default, so the statistics could be computed from unfitted parameters
|
|
41
|
+
* GROK-17637: Fit options: A malformed cell no longer aborts a Column or Dataframe level change after the option has been written; the option is refused outright when it is the edited cell itself
|
|
42
|
+
* GROK-17637: Fit options: The pre-`.%` `.fit` tag is removed once its value has been migrated, so only one of the two ever holds the options
|
|
43
|
+
* Fit options: A Column or Dataframe level option now outranks the value a curve declares for itself, instead of taking effect by deleting that value out of every cell. The setting was stored in a tag while its effect was stored in the data, so the two separated whenever the tag travelled and the data did not - applying a layout to a fresh table, or reopening a datasync project, brought the old values back. Each level now records which options were set there, the cells are left as the source produced them, and clearing a Column level option restores what each curve declared
|
|
44
|
+
* Fit options: Fixed a Column or Dataframe level change being lost on reopening a saved project. Clearing the per-cell overrides is how the change takes effect, and that rewrite is deliberately silent so a cosmetic option does not refit every statistic column - but nothing then marked the table modified, so the cleared overrides were never saved and the old cell-level value came back. The table is now notified at dataframe level, which the calculated columns ignore because it names no column
|
|
45
|
+
* Fit options: Fixed Column and Dataframe level options not surviving a reopened datasync project, and not being carried by layouts. They live in a tag, and only tags prefixed `.%` are serialized into a layout, so the options moved to `.%fit`; the old `.fit` tag is still read and migrated on first use
|
|
46
|
+
* Curve statistics: The statistic column is inserted directly after the curve column again, rather than appended to the end of the table - the platform adds it through the output's `join(table)` action, which has no position to declare
|
|
47
|
+
* Fit options: Fixed a Column or Dataframe level change having no effect on a cell where the same property had been set at cell level. Whether any cell overrode a property was detected once and never revisited, so a cell that gained an override afterwards was invisible to the pass that clears them
|
|
48
|
+
* Fit renderer: Fixed the legend drawing each label over its own marker. The legend positions text by measured width, but did not set its own `textAlign`, so it inherited the centred alignment the axis labels leave behind and every label shifted half its width left
|
|
49
|
+
* GROK-17637: Statistics: Changing a chart or series option at Column or Dataframe level now refreshes the extracted statistic columns, but only when the option can affect a statistic. The option lives in a tag, so nothing marked the curve column changed and the columns kept stale numbers while the plot updated; clearing the per-cell overrides is how the option takes effect, but that was itself announced as a data change, so a colour or a title refit every dependent column. `mergeSeries` does not affect a statistic, since the renderer merges on a copy and the statistics read the original series
|
|
50
|
+
* GROK-17637: Statistics: Fixed an aggregated `interceptX` being reported in log space while `ic50` was a concentration - it is the default statistic of both aggregation transforms, so a saved project replayed -6 into a column of 1e-6 values, and an outlier toggle mixed both scales into one column
|
|
51
|
+
* GROK-17637: Statistics: The y asymptotes are reported in the space they were fitted in, as before. A stored `bottom` of 0 has no finite logarithm, so a forward and inverse conversion could never be exact inverses - an unguarded inverse reported that bottom as 1
|
|
52
|
+
* GROK-17637: Statistics: A merged-series cell no longer leaks into its own statistics - the renderer merges on a copy instead of replacing the series of the cached chart data, and the merged series no longer caches its fit under the key the first real series uses. An extracted statistic used to depend on whether the row had been painted
|
|
53
|
+
* GROK-17637: Statistics: `Add Aggregated Curve Statistic` offers the same aggregations as the other two aggregation functions
|
|
54
|
+
* GROK-17637: Statistics: A legacy statistic a fit function has no field for (`top` on a linear fit) now reads the same aggregated as it does per series, instead of coming back empty
|
|
55
|
+
* GROK-17637: Statistics: `interceptY` has a descriptor for every fit function, so a custom JS fit renders it instead of holding a value the plot skips
|
|
56
|
+
* GROK-17637: XML 3DX: `logY` is emitted only when the export declares it - always emitting the key stopped a Column or Dataframe level option cascading onto the cell
|
|
57
|
+
* GROK-17637: Statistics: The aggregations *offered* are limited to the ones converted back to data space, on the transform functions as well as in the panel - the others still compute, in fit space. The new `curveStatistic`/`curveAggrStatistic` declare `semType: fit` and non-nullable inputs like their legacy twins
|
|
58
|
+
* GROK-17637: Tests: Saving a project from a table with a Column level option and reopening it restores that option and keeps it outranking the data, for a datasync project as well as a stored one. Both verified to fail when the explicit override is removed. The layout is captured with `saveLayout()` rather than `getInfo()` - only the former runs `saveSyncTags`, so a layout from `getInfo()` carries no column tags and a refetched table comes back without them
|
|
59
|
+
* GROK-17637: Tests: A layout saved from a table with a Column level option and applied to a fresh copy of the same data restores that option - the round trip the tag rename exists for, verified to fail when the tag loses its `.%` prefix
|
|
60
|
+
* GROK-17637: Tests: Added coverage for the renderer, the property panel and the calculated columns - a repaint leaving the cached parameters in data space, values-changed driving statistic-column recalculation, a Column level option overriding a cell level one, the statistic column's position, options read from the legacy tag, the panel constructing for a saved legacy statistic, legacy statistic names mapping onto the current ones, the 3DX parser not inventing `logY`, `interceptY` resolving to a descriptor on a custom fit, and the transform functions offering only aggregations that convert back to data space
|
|
61
|
+
* GROK-17637: XML 3DX: Fixed boolean attributes being read as strings - `drawLine="False"` and `logX="false"` both came back true, so a converted curve drew a fit line the source asks to hide, and would have been fitted in log space on a linear axis
|
|
62
|
+
* GROK-17637: XML 3DX: A declared fit function that is not registered now falls back to sigmoid instead of being passed through as an unknown name
|
|
63
|
+
* GROK-17637: XML 3DX: `logY` is read from the chart settings, where it was previously ignored
|
|
64
|
+
* GROK-17637: Statistics: Plot and property panel now show the statistics the series' own fit function produces, instead of a fixed list that rendered NaN for non-sigmoid fits
|
|
65
|
+
* GROK-17637: Behaviour change: Statistics are labelled with each fit function's own parameter names - `AUC`, `R²`, and `Max`/`Hill`/`IC50`/`Min` for dose-response. `Max Y` and `Min Y` now name the derived asymptote statistics rather than `top`/`bottom`
|
|
66
|
+
* GROK-17637: Behaviour change: `slope` on a linear or log-linear fit now reports the slope; it previously reported the intercept. `top` on those fits keeps its old value, so `top` and `slope` report the same number
|
|
67
|
+
* GROK-17637: Statistics: IC50 is reported as a concentration everywhere, so the plot and the property panel no longer disagree
|
|
68
|
+
* GROK-17637: Behaviour change: IC50 is converted out of log space whenever the x axis is logarithmic. The conversion was previously skipped for stored values >= 1, and for `4pl-dose-response` entirely, so nM/uM-scale curves and every dose-response curve now report a different number - by orders of magnitude in saved projects
|
|
69
|
+
* GROK-17637: Behaviour change: Statistics aggregated across series are averaged in fit space, so an averaged IC50 is now a geometric mean - 1e-7 and 1e-5 give 1e-6 rather than 5.05e-6. Counts, sums and shape statistics stay on their own scale
|
|
70
|
+
* GROK-17637: Added pIC50, derived as -log10(IC50). It assumes the concentration is molar, so it reads 6 too low on uM data and 9 too low on nM data
|
|
71
|
+
* GROK-17637: Options: A custom JS fit function is now named in the property panel instead of rendering a blank input
|
|
72
|
+
* GROK-17637: Options: Fixed the statistics and fit-function inputs binding to a throwaway copy of the options, so changing either did nothing
|
|
73
|
+
* GROK-17637: Statistics: Toggling an outlier refreshes extracted statistic columns by name off the typed fit, so columns named beyond the seven legacy statistics (`ic50`, `pIC50`, `maxY`) stay populated
|
|
74
|
+
* GROK-17637: Statistics: A cell mixing fit functions now aggregates only the statistics every series produces, instead of averaging one over the subset that has it
|
|
75
|
+
* GROK-17637: Statistics: Statistics that only carry meaning in data space (IC50/EC50 under a logarithmic x axis, and pIC50) are no longer offered for aggregations that are not converted back, where they would have been reported in log space or come back empty
|
|
76
|
+
* GROK-17637: Fixed the series colour type being widened to `string`, which disabled colour-option checking
|
|
77
|
+
* GROK-17637: Statistics: Added `curveStatistic` and `curveAggrStatistic` - the property panel now adds a statistic as a calculated column that recalculates when its curve changes and is recorded in the table's creation script
|
|
78
|
+
* GROK-17637: Statistics: Aggregation now covers every statistic the cell's fit functions produce rather than a fixed list, and the aggregated pane uses the same per-fit-function descriptors as the single-series one
|
|
79
|
+
* GROK-17637: Fixed confidence intervals reading a non-existent `series.dataPoints`, which discarded the cached points and recomputed them on every frame
|
|
80
|
+
* GROK-17637: Statistics: Moved the statistics calculation out of the property-panel handler and the package entry point into `fit/fit-statistics.ts`
|
|
81
|
+
* GROK-17637: Extracted the chart-data assembly and fit caches into `fit/fit-chart-data.ts`, breaking the `fit-renderer` <-> `fit-statistics` import cycle
|
|
82
|
+
* GROK-17637: Statistics: Fixed the reported IC50 of nM/uM-scale curves drifting (100 -> 2 -> 0.301). `IFitSeries.parameters` are now always in data space: neither the renderer nor the statistics convert them in place or write fitted parameters back onto the cached series
|
|
6
83
|
|
|
7
84
|
## 1.12.0 (2026-04-02)
|
|
8
85
|
|
package/CLAUDE.md
CHANGED
|
@@ -29,7 +29,22 @@ IFitChartData {
|
|
|
29
29
|
```
|
|
30
30
|
Each `IFitSeries` has `points: IFitPoint[]` (x, y, outlier, color, marker, stdev) plus fit configuration (fitFunction, parameters, colors, showFitLine, clickToToggle, droplines, etc.).
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Labels are values the fit cannot produce - a plate's Z prime, an assay name, a compound id.
|
|
33
|
+
`chartOptions.labels` describes the whole plot and renders once; `series.labels` describes one curve
|
|
34
|
+
and renders with it. `chartOptions.showLabels` picks which names to draw, exactly as `showStatistics`
|
|
35
|
+
does for statistics, so it inherits the cascade and the persistence below for free. Unlike every other
|
|
36
|
+
option, `chartOptions.labels` merges **per key** across levels - labels are data, not a setting.
|
|
37
|
+
|
|
38
|
+
Options precedence, applied at render time in `fit/fit-chart-data.ts`:
|
|
39
|
+
|
|
40
|
+
**value the curve declares → dataframe explicit → column explicit → cell explicit**
|
|
41
|
+
|
|
42
|
+
Every level stores what it holds in a tag (`FitConstants.TAG_FIT`, dataframe and column) or in the
|
|
43
|
+
cell JSON, alongside an `explicit` list naming the options a user actually set there. An option that
|
|
44
|
+
is merely present fills a gap (`mergeProperties`); only an **explicitly set** one overrides the value
|
|
45
|
+
a series declares for itself. Setting a level clears the claims of the narrower levels below it, so a
|
|
46
|
+
Column change reaches every cell and a Dataframe change reaches every column - without deleting the
|
|
47
|
+
data's own values, which is how a setting survives a layout applied to a fresh table.
|
|
33
48
|
|
|
34
49
|
## Curve Converter Architecture
|
|
35
50
|
|
|
@@ -57,6 +72,9 @@ The Curves package supports **multiple curve data formats** through a dynamic co
|
|
|
57
72
|
- `FitConstants.TAG_CURVE_FORMAT` = `'.%curve-format'` — column tag storing format name (e.g. `'3dx'`, `'compact-dr'`, `'pzfx'`)
|
|
58
73
|
- `FitConstants.FIT_SEM_TYPE` = `'fit'` — semantic type for fit curves
|
|
59
74
|
- `FitConstants.TAG_FIT_CHART_FORMAT` = `'.fitChartFormat'` — legacy tag for format identification
|
|
75
|
+
- `FitConstants.TAG_FIT` = `'.%fit'` — dataframe/column tag holding that level's options. The `.%`
|
|
76
|
+
prefix is what makes the platform serialize it into a layout; `TAG_FIT_LEGACY` (`'.fit'`) is read
|
|
77
|
+
and migrated once, then removed
|
|
60
78
|
|
|
61
79
|
### Supported Formats
|
|
62
80
|
|
|
@@ -114,10 +132,26 @@ Central module for the converter system:
|
|
|
114
132
|
3. `detectPzfxCurveChart` — matches PZFX XY table XML
|
|
115
133
|
4. `detectCompactDoseResponse` — matches compact DR JSON with `p` + `poi` fields
|
|
116
134
|
|
|
135
|
+
### Chart Data & Caches — `src/fit/fit-chart-data.ts`
|
|
136
|
+
|
|
137
|
+
A leaf module, so the renderer and the statistics do not import each other through it:
|
|
138
|
+
- **Caching**: four `DG.LruCache` instances: `parsedCurves` (parsed IFitChartData), `fittedCurves` (fitted
|
|
139
|
+
curve results), `curvesDataPoints` (extracted data points), and `viewerFits`. Nothing ever invalidates
|
|
140
|
+
them - correctness is entirely in the key, which is why the axes belong there alongside the cell: the
|
|
141
|
+
same curve fits differently on a log axis, and a grid, a property panel and a trellis can be showing
|
|
142
|
+
it in different spaces at once. `viewerFits` is separate on purpose: a viewer's curves are not the
|
|
143
|
+
grid's (it merges a cell's series and applies its own log options), so the two must never answer for
|
|
144
|
+
each other. It is keyed on `chartDataId()` - a short stand-in for the parsed cell's object identity,
|
|
145
|
+
so re-parsing a cell retires the fits made from it without any invalidation code
|
|
146
|
+
|
|
147
|
+
- `getOrCreateParsedChartData(cell)` — cached parse with the precedence above applied
|
|
148
|
+
- `getColumnChartOptions` / `getDataFrameChartOptions` — read a level's options, migrating `.fit` onto `.%fit`
|
|
149
|
+
- `mergeProperties` (gap filling) and the explicit overrides that outrank a series' own value
|
|
150
|
+
- `mergeSeries`, `substituteZeroes`, `sanitizeCellValue`
|
|
151
|
+
|
|
117
152
|
### Cell Renderer — `src/fit/fit-renderer.ts`
|
|
118
153
|
|
|
119
154
|
`FitChartCellRenderer` (extends `DG.GridCellRenderer`) — the main grid cell renderer for `fit` cells:
|
|
120
|
-
- **Caching**: three `DG.LruCache` instances: `parsedCurves` (parsed IFitChartData), `fittedCurves` (fitted curve results), `curvesDataPoints` (extracted data points)
|
|
121
155
|
- **render()**: parses cell via `parseCellValue()` → renders axes, fit lines, points, confidence intervals, droplines, statistics, title, legend
|
|
122
156
|
- **onClick()**: toggles outlier status on points (native format only), updates dependent statistics columns
|
|
123
157
|
- **onDoubleClick()**: opens `inspectCurve` dialog (resizable chart editor)
|
|
@@ -125,11 +159,34 @@ Central module for the converter system:
|
|
|
125
159
|
- Outlier toggling is only available for native format columns (`isNativeFormat()`)
|
|
126
160
|
|
|
127
161
|
Key helper functions:
|
|
128
|
-
- `
|
|
129
|
-
- `
|
|
130
|
-
|
|
131
|
-
- `setOutlier
|
|
132
|
-
-
|
|
162
|
+
- `getOrCreateCachedFitCurve(series, ...)` — cached Nelder-Mead fit (in `fit-chart-data.ts`)
|
|
163
|
+
- `layoutChart(rect, ...)` and the `*Shown` predicates — geometry and what a cell of a given size has
|
|
164
|
+
room for, in `fit-layout.ts`
|
|
165
|
+
- `setOutlier`, `inspectCurve`, `handleClick`, `handleMouseMove` — what a user does to a curve, in
|
|
166
|
+
`fit-interaction.ts`. The renderer's `onClick`/`onMouseMove` delegate to them; `handleMouseMove`
|
|
167
|
+
takes the renderer as the base `DG.GridCellRenderer` type so the two modules do not import each other
|
|
168
|
+
|
|
169
|
+
Parameters stored in a cell are **always data space**; `seriesInFitSpace()` hands the renderer a copy
|
|
170
|
+
in the optimizer's coordinates for the curve, the confidence band and the droplines, and everything
|
|
171
|
+
shown as a number goes through `toDataSpace()` instead. See "Fit statistics" below.
|
|
172
|
+
|
|
173
|
+
### Fit statistics
|
|
174
|
+
|
|
175
|
+
Statistics come from the typed fit, not positional parameter indices: `getSeriesFit()` → a `Fit`
|
|
176
|
+
subclass, read by name with `getStatistic(fit, name)`. Each fit function advertises its own set via
|
|
177
|
+
`statisticsProperties`, so a linear fit has no `ic50` and asking returns `undefined`, not `NaN`.
|
|
178
|
+
`toDataSpace()` converts log-fitted statistics back to data space exactly once — **aggregate before
|
|
179
|
+
calling it**, so an averaged IC50 stays a geometric mean.
|
|
180
|
+
|
|
181
|
+
Legacy names (`interceptX`, `top`, …) are persisted in `showStatistics`, in the `.statistics` column
|
|
182
|
+
tag and in recorded transforms; `LEGACY_FIT_STATISTICS` is append-only and resolved through an alias
|
|
183
|
+
table. `addStatisticsColumn` and the `.sourceColumn` sweep in `setOutlier` are the legacy path, kept
|
|
184
|
+
so existing projects keep working.
|
|
185
|
+
|
|
186
|
+
`curveStatistic` / `curveAggrStatistic` add statistics as **calculated columns** (`meta.vectorFunc` +
|
|
187
|
+
`action: join(table)`, called with `processed: false`). Three traps there fail silently — a parameter
|
|
188
|
+
must not be named after the package module global, the result column name must be stable, and on
|
|
189
|
+
recalculation the function gets a detached column. See `src/tests/calculated-columns-tests.ts`.
|
|
133
190
|
|
|
134
191
|
### Property Panel — `src/fit/fit-grid-cell-handler.ts`
|
|
135
192
|
|
|
@@ -137,7 +194,18 @@ Key helper functions:
|
|
|
137
194
|
- **Options pane**: switch level (Dataframe/Column/Cell), series and chart options
|
|
138
195
|
- **Chart pane**: enlarged `GridCellWidget` rendering
|
|
139
196
|
- **Fit pane**: per-series or aggregated statistics with "+" buttons to extract stats as columns
|
|
140
|
-
-
|
|
197
|
+
- `addStatisticColumn()` runs `curveStatistic`/`curveAggrStatistic` and puts the result right after
|
|
198
|
+
the curve column, in the dataframe and in the grid, which keep their order separately
|
|
199
|
+
|
|
200
|
+
### Options — `src/fit/fit-options.ts`
|
|
201
|
+
|
|
202
|
+
Writing an option at any level, kept apart from the panel that renders it:
|
|
203
|
+
- `changeCurvesOptions(gridCell, input, section, level)` — the single entry point
|
|
204
|
+
- `claim`/`unclaim` — record or drop "the user set this here", which is what outranks the data
|
|
205
|
+
- `chartPropertiesFor` / `seriesPropertiesFor` / `normalizeStatisticNames` — the property lists the
|
|
206
|
+
panel binds to, built from the cell's own fit functions rather than a fixed legacy list
|
|
207
|
+
- `STATISTIC_AFFECTING_OPTIONS` gates the notification: only these refit dependent statistic columns,
|
|
208
|
+
everything else notifies at dataframe level, which marks the table modified without recalculating
|
|
141
209
|
|
|
142
210
|
### Rendering Utilities — `src/fit/render-utils.ts`
|
|
143
211
|
|
|
@@ -149,11 +217,26 @@ Low-level canvas drawing functions using `CanvasRenderingContext2D`:
|
|
|
149
217
|
| `renderFitLine` | Fitted curve line (solid/dotted/dashed/dashdotted) |
|
|
150
218
|
| `renderConfidenceIntervals` | Shaded confidence bands |
|
|
151
219
|
| `renderConnectDots` | Direct point-to-point line connections |
|
|
152
|
-
| `renderDroplines` |
|
|
220
|
+
| `renderDroplines` | ICxx / ECxx droplines, resolved through `FitFunction.inverse` |
|
|
153
221
|
| `renderStatistics` | In-chart text labels for selected statistics |
|
|
154
222
|
| `renderTitle` | Chart title |
|
|
155
223
|
| `renderAxesLabels` | X and Y axis name labels |
|
|
156
|
-
|
|
224
|
+
|
|
225
|
+
### Legend — `src/fit/fit-legend.ts`
|
|
226
|
+
|
|
227
|
+
The legend annotates the plot from a corner, over a backdrop, taking at most 40% of the width and
|
|
228
|
+
half the height. `chooseLegendCorner()` picks the corner: `renderPoints` and `renderFitLine` report
|
|
229
|
+
where they put ink (`drawnAt`), each corner is scored by how much of it falls within a clearance ring,
|
|
230
|
+
ties go to the corner the ink keeps furthest away, and the top right one stays unless another is less
|
|
231
|
+
than half as crowded - otherwise the legend would hop about as rows are hovered or the grid scrolls.
|
|
232
|
+
|
|
233
|
+
A column that holds a single curve gets no row of its own; a name that two columns share is qualified
|
|
234
|
+
with the column, while the same name twice in one column is left alone (the prefix would be identical);
|
|
235
|
+
a name too long is ellipsized; rows past the corner collapse into `+N more`. `legendTooltip()` answers
|
|
236
|
+
the hover - the whole of a shortened name, or every row when the pointer is on `+N more` - reading the
|
|
237
|
+
layout the render recorded, since only the render knows which corner it chose. `isLegendVisible()` is
|
|
238
|
+
the single gate (the `showLegend` chart option and the size thresholds), used by the renderer and the
|
|
239
|
+
hover alike. Rows are measured on a canvas context of its own, since hit testing has none to draw on.
|
|
157
240
|
|
|
158
241
|
### Converters — `src/fit/converters/`
|
|
159
242
|
|
|
@@ -191,8 +274,13 @@ Test entry point: `src/package-test.ts` — imports all test files.
|
|
|
191
274
|
| `converter-tests.ts` | All converters (XML, compact DR, PZFX), caching, format detection, rendering integration |
|
|
192
275
|
| `fit-tests.ts` | Core fitting algorithms (sigmoid, linear, log-linear, exponential, polynomial) |
|
|
193
276
|
| `curves-cell-renderer-tests.ts` | Cell renderer creation and rendering performance |
|
|
277
|
+
| `calculated-columns-tests.ts` | `curveStatistic`/`curveAggrStatistic` as calculated columns, statistic-space round trips, aggregation |
|
|
278
|
+
| `panel-renderer-tests.ts` | Property panel construction, option precedence between levels, notification gating |
|
|
194
279
|
| `transform-tests.ts` | Viewport coordinate transformations |
|
|
195
280
|
| `pzfx-tests.ts` | PZFX file parser |
|
|
281
|
+
| `legend-tests.ts` | Legend rows, the reserved strip, ellipsis and overflow |
|
|
282
|
+
| `multi-curve-viewer-tests.ts` | The viewer works on copies of the cached cell data |
|
|
283
|
+
| `curve-data.ts` | Shared sigmoid data and `renderedTexts()` used by the suites above (not a suite) |
|
|
196
284
|
|
|
197
285
|
## Source Structure
|
|
198
286
|
|
|
@@ -204,9 +292,15 @@ src/
|
|
|
204
292
|
package-test.ts — Test entry point
|
|
205
293
|
fit/
|
|
206
294
|
curve-converter.ts — Converter registry, LRU cache, parseCellValue() entry point
|
|
207
|
-
fit-
|
|
208
|
-
fit-
|
|
209
|
-
|
|
295
|
+
fit-chart-data.ts — Options precedence, parsed-chart-data and fit caches (leaf module)
|
|
296
|
+
fit-layout.ts — Chart geometry, and what fits in a cell of a given size
|
|
297
|
+
fit-legend.ts — Legend rows, the strip they are given, and their drawing
|
|
298
|
+
fit-renderer.ts — FitChartCellRenderer: assembling a chart onto a canvas
|
|
299
|
+
fit-interaction.ts — Outlier toggle, tooltip, click handling, the chart editor dialog
|
|
300
|
+
fit-grid-cell-handler.ts — FitGridCellHandler (property panel), stat column extraction
|
|
301
|
+
fit-options.ts — changeCurvesOptions, claims, panel property lists
|
|
302
|
+
fit-statistics.ts — Per-series and aggregated statistics calculation
|
|
303
|
+
render-utils.ts — Canvas drawing functions (points, lines, CIs, droplines, statistics)
|
|
210
304
|
fit-parser.ts — XML 3DX → IFitChartData parser (used by xml-converter)
|
|
211
305
|
data-to-curves.ts — Data to Curves pipeline (UI dialog + conversion logic)
|
|
212
306
|
multi-curve-viewer.ts — MultiCurveViewer (overlay viewer)
|
|
@@ -220,6 +314,7 @@ src/
|
|
|
220
314
|
pzfx/
|
|
221
315
|
pzfx-parser.ts — PZFX file parser
|
|
222
316
|
tests/
|
|
317
|
+
curve-data.ts — Shared sigmoid test data
|
|
223
318
|
detector-tests.ts — Semantic type detector tests (all formats)
|
|
224
319
|
converter-tests.ts — Converter tests (all formats, caching, integration)
|
|
225
320
|
fit-tests.ts — Fitting algorithm tests
|
|
@@ -241,13 +336,21 @@ detectors.js — Semantic type detectors (all curve formats)
|
|
|
241
336
|
| Converter infrastructure | `src/fit/curve-converter.ts` |
|
|
242
337
|
| Existing converters | `src/fit/converters/` |
|
|
243
338
|
| Function/demo/init registration | `src/package.ts` |
|
|
244
|
-
| Cell renderer (
|
|
339
|
+
| Cell renderer (drawing) | `src/fit/fit-renderer.ts` |
|
|
340
|
+
| Click, tooltip, outlier toggle, editor dialog | `src/fit/fit-interaction.ts` |
|
|
341
|
+
| Chart geometry, size thresholds | `src/fit/fit-layout.ts` |
|
|
342
|
+
| Legend rows, width and drawing | `src/fit/fit-legend.ts` |
|
|
343
|
+
| Options precedence, parse and fit caches | `src/fit/fit-chart-data.ts` |
|
|
245
344
|
| Property panel (options, stats, chart) | `src/fit/fit-grid-cell-handler.ts` |
|
|
246
|
-
|
|
|
345
|
+
| Writing an option at a level, claims | `src/fit/fit-options.ts` |
|
|
346
|
+
| Statistics calculation (per-series, aggregated) | `src/fit/fit-statistics.ts` |
|
|
347
|
+
| Canvas drawing (points, lines, axes, statistics, labels) | `src/fit/render-utils.ts` |
|
|
247
348
|
| Data to Curves dialog & conversion | `src/fit/data-to-curves.ts` |
|
|
248
349
|
| Multi-curve overlay viewer | `src/fit/multi-curve-viewer.ts` |
|
|
249
350
|
| XML 3DX format parsing | `src/fit/fit-parser.ts` |
|
|
250
351
|
| Fit data types (IFitChartData, etc.) | `@datagrok-libraries/statistics/src/fit/fit-curve.ts` |
|
|
352
|
+
| Fit functions, typed fits, optimizer | `.../fit/fit-engine.ts` |
|
|
353
|
+
| Series-level API (getSeriesFit, toDataSpace) | `.../fit/fit-data.ts` |
|
|
251
354
|
| Constants (tags, sizes, thresholds) | `@datagrok-libraries/statistics/src/fit/const.ts` |
|
|
252
355
|
| Semantic type detection | `detectors.js` |
|
|
253
356
|
| Test entry point | `src/package-test.ts` |
|
package/README.md
CHANGED
|
@@ -101,11 +101,18 @@ Each series has its own parameters, such as:
|
|
|
101
101
|
- `fitFunction` - controls the series fit function, which could be either a sigmoid, linear, log-linear function or a
|
|
102
102
|
[custom-defined function](#creating-a-custom-fit-function).
|
|
103
103
|
- `parameters` - controls the series parameters, if set explicitly - the fitting process won't be executed. The parameter order of the
|
|
104
|
-
sigmoid function is: `max, tan, IC50, min`.
|
|
104
|
+
sigmoid function is: `max, tan, IC50, min`. Parameters are always in data space, never logarithms,
|
|
105
|
+
whatever `logX` and `logY` are set to.
|
|
105
106
|
- `parameterBounds` - defines the acceptable range of each parameter, which is taken into account during the fitting. See also `parameters`
|
|
106
107
|
- `showPoints` - defines the data display mode, which could be either `points`, `candlesticks`, `both`, or none
|
|
107
108
|
- `clickToToggle` - defines whether clicking on the point toggles its outlier status and causes curve refitting or not
|
|
108
|
-
- `droplines` -
|
|
109
|
+
- `droplines` - names of the droplines to draw. Any `ICxx` or `ECxx` works (`IC50`, `IC90`, `EC55`):
|
|
110
|
+
the dropline marks the x at which the curve has travelled that fraction from its low-x asymptote to
|
|
111
|
+
its high-x one - percent inhibition on a descending curve, percent of maximal effect on an ascending
|
|
112
|
+
one. Available on the fits that have asymptotes (sigmoid, 4PL dose-response, 4PL regression); one
|
|
113
|
+
that lands outside the plotted range is not drawn, and names are captioned when a series asks for
|
|
114
|
+
more than one
|
|
115
|
+
- `labels` - values drawn with this curve, in its colour, for facts the fit cannot produce (a compound id)
|
|
109
116
|
- `points` - an array of objects with each object containing `x` and `y` coordinates and its own parameters:
|
|
110
117
|
- `outlier` - if true, renders as 'x' and gets ignored for curve fitting
|
|
111
118
|
- `color` - overrides the marker color defined in series `pointColor`
|
|
@@ -122,12 +129,52 @@ Each chart has its own parameters as well, such as:
|
|
|
122
129
|
- `logX`, `logY` - defines whether the x and y data should be logarithmic or not
|
|
123
130
|
- `allowXZeroes` - defines whether x zeroes allowed for logarithmic data or not. If the flag is true, it will calculate the approximate log(0) that will fit the chart
|
|
124
131
|
- `mergeSeries` - defines whether to merge series or not
|
|
132
|
+
- `showLegend` - whether the curves are named on the plot, `true` by default. The legend takes at most
|
|
133
|
+
a corner of the plot, shortening a name that does not fit and collapsing the rest into `+N more`
|
|
125
134
|
- `showColumnLabel` - defines whether to show the column label in the legend or not
|
|
126
135
|
- `showStatistics` - defines the statistics that would be shown on the plot (such as the area under the curve
|
|
127
|
-
(`auc`) or the coefficient of determination (`rSquared`))
|
|
136
|
+
(`auc`) or the coefficient of determination (`rSquared`)). The available names come from each series'
|
|
137
|
+
fit function, and a statistic a series does not produce is skipped rather than drawn as `NaN`
|
|
138
|
+
- `labels` - values describing the whole plot, drawn once in a neutral colour (a plate's Z prime).
|
|
139
|
+
Unlike other options, labels combine per key across levels
|
|
140
|
+
- `showLabels` - defines which label names are drawn
|
|
141
|
+
- `statisticsMode` - whether `showStatistics` is drawn for each `series`, `aggregated` into one line
|
|
142
|
+
above them, or `both`. Only applies to a cell holding several curves
|
|
143
|
+
- `aggrType` - the aggregation used when summarising, `med` by default
|
|
128
144
|
|
|
129
145
|

|
|
130
146
|
|
|
147
|
+
## Options
|
|
148
|
+
|
|
149
|
+
Chart and series options can be set at four levels:
|
|
150
|
+
|
|
151
|
+
| Level | Stored in | Applies to |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| Dataframe | the `.%fit` tag on the table | every curve column |
|
|
154
|
+
| Column | the `.%fit` tag on the column | every cell of the column |
|
|
155
|
+
| Cell | the cell's JSON | every series in the cell |
|
|
156
|
+
| Series | the `series` entry in the cell's JSON | one curve |
|
|
157
|
+
|
|
158
|
+
To change one, click a curve cell, set **Level** on the **Context Panel**, and edit the option.
|
|
159
|
+
|
|
160
|
+
Setting an option at a level clears it on the narrower ones, so a **Column** change reaches every
|
|
161
|
+
cell. Where nothing was set explicitly, the nearest declared value wins; an option you set explicitly
|
|
162
|
+
outranks the value a curve declares for itself:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
value declared by the curve < dataframe < column < cell
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
That is why turning confidence intervals off on a column works even when every cell of it declares
|
|
169
|
+
`showCurveConfidenceInterval: true`.
|
|
170
|
+
|
|
171
|
+
Dataframe and column options live in a tag, so they travel with layouts and return when a project
|
|
172
|
+
reopens - including a datasync project, whose table is refetched rather than restored. Cell and
|
|
173
|
+
series options are part of the table data, so a layout cannot carry them to another table.
|
|
174
|
+
|
|
175
|
+
Labels and statistics share the plot's space: a grid cell has room for about five lines and drops the
|
|
176
|
+
rest. Widen the cell, or open the chart from the **Context Panel**, to see them all.
|
|
177
|
+
|
|
131
178
|
## Creating a custom fit function
|
|
132
179
|
|
|
133
180
|
To render a custom fit function, you need to write in the following JSON format:
|
|
@@ -152,7 +199,7 @@ returns the result of the fit function. These functions are written as JavaScrip
|
|
|
152
199
|
|
|
153
200
|
## Multi Curve Viewer
|
|
154
201
|
|
|
155
|
-
To compare dose-response curves from multiple cells, put them on the Multi Curve Viewer
|
|
202
|
+
To compare dose-response curves from multiple cells, put them on the Multi Curve Viewer:
|
|
156
203
|
|
|
157
204
|

|
|
158
205
|
|