@datagrok/curves 1.1.0 → 1.2.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/.vscode/tasks.json +1 -1
- package/CHANGELOG.md +25 -0
- package/README.md +89 -10
- package/detectors.js +2 -2
- package/dist/package-test.js +2764 -1099
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +2007 -1455
- package/dist/package.js.map +1 -1
- package/img/curves.gif +0 -0
- package/img/custom-fit-function.gif +0 -0
- package/package.json +5 -5
- package/src/fit/fit-demo.js +13 -7
- package/src/fit/fit-demo.js.map +1 -1
- package/src/fit/fit-demo.ts +14 -8
- package/src/fit/fit-grid-cell-handler.js +23 -11
- package/src/fit/fit-grid-cell-handler.js.map +1 -1
- package/src/fit/fit-grid-cell-handler.ts +33 -14
- package/src/fit/fit-parser.js +19 -16
- package/src/fit/fit-parser.js.map +1 -1
- package/src/fit/fit-parser.ts +22 -20
- package/src/fit/fit-renderer.js +279 -70
- package/src/fit/fit-renderer.js.map +1 -1
- package/src/fit/fit-renderer.ts +335 -72
- package/src/fit/multi-curve-viewer.js +4 -3
- package/src/fit/multi-curve-viewer.js.map +1 -1
- package/src/fit/multi-curve-viewer.ts +4 -10
- package/src/package-test.js +3 -0
- package/src/package-test.js.map +1 -1
- package/src/package-test.ts +3 -0
- package/src/package.js +2 -7
- package/src/package.js.map +1 -1
- package/src/package.ts +2 -9
- package/src/tests/curves-cell-renderer-tests.js +103 -0
- package/src/tests/curves-cell-renderer-tests.js.map +1 -0
- package/src/tests/curves-cell-renderer-tests.ts +107 -0
- package/src/tests/detector-tests.js +2 -1
- package/src/tests/detector-tests.js.map +1 -1
- package/src/tests/detector-tests.ts +2 -1
- package/src/tests/fit-tests.js +82 -0
- package/src/tests/fit-tests.js.map +1 -0
- package/src/tests/fit-tests.ts +95 -0
- package/src/tests/transform-tests.js +26 -0
- package/src/tests/transform-tests.js.map +1 -0
- package/src/tests/transform-tests.ts +21 -0
- package/tsconfig.json +1 -1
- package/webpack.config.js +1 -0
- package/src/fit/fit-data.js +0 -215
- package/src/fit/fit-data.js.map +0 -1
- package/src/fit/fit-data.ts +0 -328
- package/src/fit/transform.js +0 -73
- package/src/fit/transform.js.map +0 -1
- package/src/fit/transform.ts +0 -99
package/.vscode/tasks.json
CHANGED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Curves changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.0 (2023-07-21)
|
|
4
|
+
|
|
5
|
+
This release focuses on improving analysis stability and usability.
|
|
6
|
+
|
|
7
|
+
*Dependency: datagarok-api >= 1.16.0*
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Improved curve fitting and confidence intervals:
|
|
12
|
+
* Added a semantic type detector for "fit" to render fitted curves.
|
|
13
|
+
* Fixed performance issues during fitting.
|
|
14
|
+
* Automated data sorting during fitting.
|
|
15
|
+
* Implemented interactive parameter recalculating.
|
|
16
|
+
* Added different marker types.
|
|
17
|
+
* Improved axes cell rendering.
|
|
18
|
+
* Added the possibility to run curves by user-defined Javascript function.
|
|
19
|
+
* [#2100](https://github.com/datagrok-ai/public/issues/2100): Made cell renderer edit mode a resizeable window.
|
|
20
|
+
* [#2101](https://github.com/datagrok-ai/public/issues/2101): Improved curves properties and rendering:
|
|
21
|
+
* Don't render curves before the axes start.
|
|
22
|
+
* Changed margins in grid cell for axes
|
|
23
|
+
* Added the capability to control parameter bounds.
|
|
24
|
+
* Fixed curves rendering by inverting the y while converting the coordinates.
|
|
25
|
+
* [#2105](https://github.com/datagrok-ai/public/issues/2105): Outliers are now shown in red color and with a much bigger size.
|
package/README.md
CHANGED
|
@@ -1,19 +1,98 @@
|
|
|
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
|
-
|
|
7
|
+
- Uses the BFGS optimization algorithm (multi-threading for performance).
|
|
8
8
|
For dose-response curves, we are typically fitting the sigmoid function
|
|
9
|
-
|
|
10
|
-
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
- Either fitting on the fly or using the supplied function + parameters
|
|
15
|
+
- Multiple series in one cell
|
|
16
|
+
- Confidence intervals 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
|
-
|
|
17
|
-
|
|
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,
|
|
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
|
+
"fitLineColor": "#2ca02c",
|
|
33
|
+
"pointColor": "#2ca02c",
|
|
34
|
+
"showCurveConfidenceInterval": true,
|
|
35
|
+
"fitFunction": "sigmoid",
|
|
36
|
+
"parameters": [1.7391934768969721, -0.9451759934029763, 4.846020678949615, 0.15841886339211816],
|
|
37
|
+
"points": [
|
|
38
|
+
{ "x": 0.10000000149011612, "y": 0.04152340441942215 },
|
|
39
|
+
{ "x": 0.6000000238418579, "y": 0.11901605129241943 },
|
|
40
|
+
{ "x": 1.100000023841858, "y": 0.11143334954977036 },
|
|
41
|
+
{ "x": 1.600000023841858, "y": 0.0444009006023407 },
|
|
42
|
+
{ "x": 2.0999999046325684, "y": 0.22933608293533325 },
|
|
43
|
+
{ "x": 2.5999999046325684, "y": 0.3057132065296173 },
|
|
44
|
+
{ "x": 3.0999999046325684, "y": 0.28693410754203796 },
|
|
45
|
+
{ "x": 3.5999999046325684, "y": 0.3156140148639679 },
|
|
46
|
+
{ "x": 4.099999904632568, "y": 0.4246906042098999 },
|
|
47
|
+
{ "x": 4.599999904632568, "y": 0.6663704514503479 },
|
|
48
|
+
{ "x": 5.099999904632568, "y": 1.2085251808166504 },
|
|
49
|
+
{ "x": 5.599999904632568, "y": 1.4426130056381226 },
|
|
50
|
+
{ "x": 6.099999904632568, "y": 1.7591952085494995 },
|
|
51
|
+
{ "x": 6.599999904632568, "y": 1.702673077583313 },
|
|
52
|
+
{ "x": 7.099999904632568, "y": 1.6438066959381104 }
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"chartOptions": { "showStatistics": ["auc"] }
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Each series has its own `fit line color` and `point color` assigned. Additionally, each series has a boolean field
|
|
61
|
+
indicating whether or not to display the curve confidence intervals. The `fit function` for each series can be
|
|
62
|
+
either a sigmoid function or a [custom-defined function](/README.md#creating-custom-fit-function). Furthermore,
|
|
63
|
+
the `parameters` for the fit function can be explicitly set or left unset. If the parameters are set explicitly,
|
|
64
|
+
the fitting process won't be executed, and vice versa. The `data points` for each series are represented as
|
|
65
|
+
arrays of objects, with each object containing x and y coordinates.
|
|
66
|
+
|
|
67
|
+
Moreover, the user has the option to obtain various statistics, such as the area under the curve (`auc`) or the
|
|
68
|
+
coefficient of determination (`rSquared`).
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
## Creating custom fit function
|
|
73
|
+
|
|
74
|
+
To render a custom fit function, you need to write in the following JSON format:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
"fitFunction": {
|
|
78
|
+
"name": "Polynomial",
|
|
79
|
+
"function": "([p1, p2, p3, p4], x) => p1 * x * x * x + p2 * x * x + p3 * x + p4",
|
|
80
|
+
"getInitialParameters": "(xs, ys) => [0.1, -1, 4, 4]",
|
|
81
|
+
"parameterNames": ["Slope", "Intercept", "Parameter 3", "Parameter 4"]
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Each fitting function has its own `name`. This name is used to cache the created custom function, enabling
|
|
86
|
+
efficient retrieval and reuse. Additionally, the fit function has `parameter names`, which are stored as
|
|
87
|
+
an array of strings.
|
|
88
|
+
|
|
89
|
+
Also, there are two functions: `getInitialParameters`, which takes arrays of x and y and returns determined
|
|
90
|
+
initial parameters values, and `function`, which takes the array of parameters and given x coordinate and
|
|
91
|
+
returns the result of the fit function. These functions are written as JavaScript arrow function expressions.
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
See also:
|
|
96
|
+
|
|
97
|
+
- [Packages](../../help/develop/develop.md#packages)
|
|
98
|
+
- [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('
|
|
30
|
-
s.includes('
|
|
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;
|