@datagrok/curves 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.vscode/tasks.json +1 -1
  2. package/CHANGELOG.md +62 -0
  3. package/README.md +116 -10
  4. package/detectors.js +2 -2
  5. package/dist/package-test.js +2791 -1099
  6. package/dist/package-test.js.map +1 -1
  7. package/dist/package.js +2037 -1458
  8. package/dist/package.js.map +1 -1
  9. package/img/curves.gif +0 -0
  10. package/img/custom-fit-function.gif +0 -0
  11. package/package.json +5 -5
  12. package/src/fit/fit-demo.js +13 -7
  13. package/src/fit/fit-demo.js.map +1 -1
  14. package/src/fit/fit-demo.ts +14 -8
  15. package/src/fit/fit-grid-cell-handler.js +23 -11
  16. package/src/fit/fit-grid-cell-handler.js.map +1 -1
  17. package/src/fit/fit-grid-cell-handler.ts +33 -14
  18. package/src/fit/fit-parser.js +23 -19
  19. package/src/fit/fit-parser.js.map +1 -1
  20. package/src/fit/fit-parser.ts +26 -21
  21. package/src/fit/fit-renderer.js +299 -70
  22. package/src/fit/fit-renderer.js.map +1 -1
  23. package/src/fit/fit-renderer.ts +354 -72
  24. package/src/fit/multi-curve-viewer.js +4 -3
  25. package/src/fit/multi-curve-viewer.js.map +1 -1
  26. package/src/fit/multi-curve-viewer.ts +4 -10
  27. package/src/package-test.js +3 -0
  28. package/src/package-test.js.map +1 -1
  29. package/src/package-test.ts +3 -0
  30. package/src/package.js +2 -7
  31. package/src/package.js.map +1 -1
  32. package/src/package.ts +2 -9
  33. package/src/tests/curves-cell-renderer-tests.js +103 -0
  34. package/src/tests/curves-cell-renderer-tests.js.map +1 -0
  35. package/src/tests/curves-cell-renderer-tests.ts +107 -0
  36. package/src/tests/detector-tests.js +2 -1
  37. package/src/tests/detector-tests.js.map +1 -1
  38. package/src/tests/detector-tests.ts +2 -1
  39. package/src/tests/fit-tests.js +82 -0
  40. package/src/tests/fit-tests.js.map +1 -0
  41. package/src/tests/fit-tests.ts +95 -0
  42. package/src/tests/transform-tests.js +26 -0
  43. package/src/tests/transform-tests.js.map +1 -0
  44. package/src/tests/transform-tests.ts +21 -0
  45. package/tsconfig.json +1 -1
  46. package/webpack.config.js +1 -0
  47. package/src/fit/fit-data.js +0 -215
  48. package/src/fit/fit-data.js.map +0 -1
  49. package/src/fit/fit-data.ts +0 -328
  50. package/src/fit/transform.js +0 -73
  51. package/src/fit/transform.js.map +0 -1
  52. package/src/fit/transform.ts +0 -99
@@ -3,7 +3,7 @@
3
3
  "tasks": [
4
4
  {
5
5
  "type": "shell",
6
- "command": "(cmd.exe /c \"webpack) -and (grok publish dev\")",
6
+ "command": "(cmd.exe /c \"npm run build) -and (grok publish dev\")",
7
7
  "label": "rebuild"
8
8
  }
9
9
  ]
package/CHANGELOG.md ADDED
@@ -0,0 +1,62 @@
1
+ # Curves changelog
2
+
3
+ ## 1.2.1 (2023-08-02)
4
+
5
+ This release focuses on adding new functionality and improving stability.
6
+
7
+ *Dependency: datagrok-api >= 1.16.0*
8
+
9
+ ### Features
10
+
11
+ * [#2101](https://github.com/datagrok-ai/public/issues/2101): Improved curves properties and rendering:
12
+ * Added dropline rendering for IC50
13
+ * Added empty cell value handling
14
+ * [#2106](https://github.com/datagrok-ai/public/issues/2106): Wrote TS docs and extended the documentation
15
+ * Added error handling in JnJ parser
16
+
17
+ ## 1.2.0 (2023-07-21)
18
+
19
+ This release focuses on adding new functionality and improving the existing one.
20
+
21
+ *Dependency: datagarok-api >= 1.16.0*
22
+
23
+ ### Features
24
+
25
+ * Added outliers switching in grid cells.
26
+ * Added different modes of rendering: candlesticks (with box plot statistics) and both (with candlesticks outliers).
27
+ * Improved fit detector.
28
+ * Improved curves and confidence intervals rendering for better smooth.
29
+ * Added the capability to run curves by user-defined Javascript function with caching.
30
+ * Improved rendering in the small cells.
31
+ * Added different marker types.
32
+ * Improved axes cell rendering.
33
+ * Implemented interactive parameter recalculation.
34
+ * [#2105](https://github.com/datagrok-ai/public/issues/2105): Outliers are now shown in red color and with a much bigger size.
35
+ * [#2101](https://github.com/datagrok-ai/public/issues/2101): Improved curves properties and rendering:
36
+ * Curves now don't render before the axes start.
37
+ * Changed margins in grid cell for axes.
38
+ * Added the capability to control parameter bounds.
39
+ * [#2100](https://github.com/datagrok-ai/public/issues/2100): Made cell renderer edit mode a resizeable window.
40
+
41
+ ### Bug Fixes
42
+
43
+ * [#2101](https://github.com/datagrok-ai/public/issues/2101): Improved curves properties and rendering:
44
+ * Fixed points rendering in logarithmic data.
45
+ * Fixed curves rendering by inverting the y while converting the coordinates.
46
+
47
+ ## 1.1.0 (2023-05-19)
48
+
49
+ This release focuses on improving the analysis stability and usability.
50
+
51
+ *Dependency: datagarok-api >= 1.15.0*
52
+
53
+ ### Features
54
+
55
+ * Added support for log transform and axis inverse.
56
+ * Improved curve fitting and confidence intervals:
57
+ * Added a semantic type detector for "fit" to render fitted curves.
58
+ * Automated data sorting during fitting.
59
+
60
+ ### Bug Fixes
61
+
62
+ * Fixed performance issues during fitting.
package/README.md CHANGED
@@ -1,19 +1,125 @@
1
1
  # Curves
2
2
 
3
- **Curves** provides support for fitted curves (such as dose-response curves),
3
+ **Curves** provides support for fitted curves (such as dose-response curves),
4
4
  including in-grid rendering, storing charts in cells, interactivity, and automatic fitting.
5
5
 
6
6
  - Fitting: computing parameters of the specified function to best fit the data
7
- - Uses BFGS optimization algorithm (multi-threading for performance).
7
+ - Uses the BFGS optimization algorithm (multi-threading for performance).
8
8
  For dose-response curves, we are typically fitting the sigmoid function
9
- - Ability to dynamically register custom fitting functions
10
- - Ability to get fitting performance characteristics (r-squared, classification, etc)
9
+ - Ability to dynamically register custom fitting functions
10
+ - Automatic fit function determination
11
+ - Caching of custom fitting functions
12
+ - Ability to get fitting performance characteristics (r-squared, classification, etc.)
11
13
  - Deep integration with the Datagrok grid
12
- - Either fitting on the fly, or using the supplied function + parameters
13
- - Multiple series in one cell
14
- - Ability to define chart, marker, or fitting options (such as fit function or marker color)
14
+ - Either fitting on the fly or using the supplied function + parameters
15
+ - Multiple series in one cell
16
+ - Candlesticks, confidence intervals, and droplines drawing
17
+ - Ability to define chart, marker, or fitting options (such as fit function or marker color)
15
18
  on the column level, with the ability to override it on a grid cell or point level
16
- - Clicking a point in a chart within a grid makes it an outlier -> curve is re-fitted on the fly
17
- - Ability to specify a chart as "reference" so that it is shown on every other chart for comparison
19
+ - Clicking a point in a chart within a grid makes it an outlier -> curve is re-fitted on the fly
20
+ - Ability to specify a chart as a "reference" so that it is shown on every other chart for comparison
18
21
  - Ability to overlay curves from multiple grid cells (special viewer)
19
- - Work with series stored in multiple formats (binary for performance, json for flexibility, etc)
22
+ - Work with series stored in multiple formats (binary for performance, JSON for flexibility, etc.)
23
+
24
+ ## Rendering fitted curves using JSON format
25
+
26
+ To render a fitted curve based on series points, you need to write it in the following JSON format:
27
+
28
+ ```json
29
+ {
30
+ "series": [
31
+ {
32
+ "name": "Test series",
33
+ "pointColor": "#2ca02c",
34
+ "fitLineColor": "#2ca02c",
35
+ "confidenceIntervalColor": "#fbec5d",
36
+ "markerType": "circle",
37
+ "showFitLine": true,
38
+ "showCurveConfidenceInterval": true,
39
+ "fitFunction": "sigmoid",
40
+ "parameters": [1.7391934768969721, -0.9451759934029763, 4.846020678949615, 0.15841886339211816],
41
+ "parameterBounds": [
42
+ {"minBound": 1.739193476892, "maxBound": 1.739193476898},
43
+ {"maxBound": -0.9451759934029},
44
+ {},
45
+ {"minBound": 0.158418863392114}
46
+ ],
47
+ "showPoints": "points",
48
+ "clickToToggle": true,
49
+ "droplines": ["IC50"],
50
+ "points": [
51
+ { "x": 0.10000000149011612, "y": 0.04152340441942215 },
52
+ { "x": 0.6000000238418579, "y": 0.11901605129241943, "outlier": true },
53
+ { "x": 1.100000023841858, "y": 0.11143334954977036, "outlier": false },
54
+ // ...
55
+ ]
56
+ }
57
+ ],
58
+ "chartOptions": {
59
+ "showStatistics": ["auc", "rSquared"],
60
+ "minX": 0.10000000149011612,
61
+ "minY": 0.04152340441942215,
62
+ "maxX": 7.099999904632568,
63
+ "maxY": 1.7591952085494995,
64
+ "xAxisName": "Concentration",
65
+ "yAxisName": "Activity",
66
+ "logX": true,
67
+ "logY": false,
68
+ }
69
+ }
70
+ ```
71
+
72
+ Each series has its own parameters, such as:
73
+
74
+ - `name` - controls the series name
75
+ - `pointColor` - overrides the standardized series point color
76
+ - `fitLineColor` - overrides the standardized series fit line color
77
+ - `confidenceIntervalColor` - overrides the standardized series confidence interval color
78
+ - `markerType` - defines the series marker type, which could be `circle`, `asterisk`, `square`, etc.
79
+ - `showFitLine` - defines whether to show the fit line or not
80
+ - `showCurveConfidenceInterval` - defines whether to show the confidence intervals or not
81
+ - `fitFunction` - controls the series fit function, which could be either a sigmoid function or a
82
+ [custom-defined function](/README.md#creating-custom-fit-function).
83
+ - `parameters` - controls the series parameters, if set explicitly - the fitting process won't be executed
84
+ - `parameterBounds` - defines the series parameter bounds during the fit
85
+ - `showPoints` - defines the data display mode, which could be either `points`, `candlesticks`, `both`, or none
86
+ - `clickToToggle` - defines whether clicking on the point toggles its outlier status and causes curve refitting or not
87
+ - `droplines` - defines the droplines that would be shown on the plot (for instance, IC50)
88
+ - `points` - an array of objects with each object containing x and y coordinates and a boolean outlier value
89
+
90
+ Each chart has its own parameters as well, such as:
91
+
92
+ - `minX`, `minY`, `maxX`, `maxY` - controls the minimum x and y values of the plot
93
+ - `xAxisName`, `yAxisName` - defines the x and y axis names. If the plot size is enough, will render it
94
+ - `logX`, `logY` - defines whether the x and y data should be logarithmic or not
95
+ - `showStatistics` - defines the statistics that would be shown on the plot (such as the area under the curve
96
+ (`auc`) or the coefficient of determination (`rSquared`))
97
+
98
+ ![curves](./img/curves.gif)
99
+
100
+ ## Creating a custom fit function
101
+
102
+ To render a custom fit function, you need to write in the following JSON format:
103
+
104
+ ```json
105
+ "fitFunction": {
106
+ "name": "Polynomial",
107
+ "function": "([p1, p2, p3, p4], x) => p1 * x * x * x + p2 * x * x + p3 * x + p4",
108
+ "getInitialParameters": "(xs, ys) => [0.1, -1, 4, 4]",
109
+ "parameterNames": ["Slope", "Intercept", "Parameter 3", "Parameter 4"]
110
+ }
111
+ ```
112
+
113
+ Each fitting function has its own `name`, which is used to cache the created custom function, enabling
114
+ efficient retrieval and reuse, and `parameterNames`, which are stored as an array of strings.
115
+
116
+ Also, there are two functions: `getInitialParameters`, which takes arrays of x and y and returns determined
117
+ initial parameter values, and `function`, which takes the array of parameters and the given x coordinate and
118
+ returns the result of the fit function. These functions are written as JavaScript arrow function expressions.
119
+
120
+ ![custom-fit-function](./img/custom-fit-function.gif)
121
+
122
+ See also:
123
+
124
+ - [Packages](../../help/develop/develop.md#packages)
125
+ - [JavaScript API](../../help/develop/js-api.md)
package/detectors.js CHANGED
@@ -26,8 +26,8 @@ class CurvesPackageDetectors extends DG.Package {
26
26
  //output: string semType
27
27
  detectFit(col) {
28
28
  if (DG.Detector.sampleCategories(col, (s) => {
29
- return s.includes('series') && s.includes('points') && s.includes('parameters') &&
30
- s.includes('fitLineColor') && s.includes('pointColor') && s.includes('showCurveConfidenceInterval');
29
+ return s.includes('series') && s.includes('points') && s.includes('fitLineColor') &&
30
+ s.includes('pointColor') && s.includes('showCurveConfidenceInterval');
31
31
  }, 1)) {
32
32
  col.semType = FIT_SEM_TYPE;
33
33
  return col.semType;