@datagrok/curves 1.8.0 → 1.9.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/.eslintrc.json +39 -0
- package/.vscode/launch.json +10 -9
- package/.vscode/tasks.json +14 -0
- package/CHANGELOG.md +33 -0
- package/databases/plates/0000_init.sql +167 -0
- package/detectors.js +2 -2
- package/dist/package-test.js +15930 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +13750 -1
- package/dist/package.js.map +1 -1
- package/package.json +12 -8
- package/queries/plates-crud.sql +148 -0
- package/src/fit/const.ts +60 -60
- package/src/fit/data-to-curves.ts +220 -0
- package/src/fit/fit-demo.ts +6 -6
- package/src/fit/fit-grid-cell-handler.ts +48 -44
- package/src/fit/fit-renderer.ts +56 -55
- package/src/fit/multi-curve-viewer.ts +38 -18
- package/src/fit/render-utils.ts +315 -315
- package/src/package-api.ts +167 -0
- package/src/package-test.ts +1 -1
- package/src/package.g.ts +133 -3
- package/src/package.ts +198 -299
- package/src/plate/excel-plates.ts +1 -1
- package/src/plate/plate-cell-renderer.ts +20 -12
- package/src/plate/plate-drc-analysis.ts +262 -0
- package/src/plate/plate-reader.ts +5 -5
- package/src/plate/plate-well-validators.ts +41 -0
- package/src/plate/plate-widget.ts +132 -368
- package/src/plate/plate.ts +168 -57
- package/src/plate/plates-folder-preview.ts +63 -0
- package/src/plate/readers/bmg-pherastar-96.ts +7 -7
- package/src/plate/readers/delfia-envision-96-max-rlu.ts +4 -3
- package/src/plate/readers/delfia-envision-by-row.ts +3 -3
- package/src/plate/readers/spectramax.ts +7 -8
- package/src/plate/utils.ts +22 -10
- package/src/plates/numeric_matcher.ts +191 -0
- package/src/plates/objects/plate-template-handler.ts +48 -0
- package/src/plates/plates-app.ts +64 -0
- package/src/plates/plates-crud.ts +502 -0
- package/src/plates/plates-demo.ts +107 -0
- package/src/plates/plates.sql +169 -0
- package/src/plates/views/plates-create-view.ts +123 -0
- package/src/plates/views/plates-schema-view.ts +58 -0
- package/src/plates/views/plates-search-view.ts +137 -0
- package/src/plates/views/plates-templates-view.ts +38 -0
- package/src/tests/curves-cell-renderer-tests.ts +93 -92
- package/src/tests/detector-tests.ts +3 -2
- package/src/tests/fit-tests.ts +199 -198
- package/src/tests/plate-tests.ts +6 -7
- package/src/tests/transform-tests.ts +4 -4
- package/test-console-output-1.log +435 -0
- package/test-record-1.mp4 +0 -0
- package/tsconfig.json +1 -1
package/src/tests/fit-tests.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
getSeriesFitFunction,
|
|
4
|
+
getCurve,
|
|
5
|
+
fitSeries,
|
|
6
|
+
getSeriesConfidenceInterval,
|
|
7
|
+
getSeriesStatistics,
|
|
8
|
+
getPointsArrays,
|
|
8
9
|
} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
sigmoid,
|
|
12
|
+
FIT_FUNCTION_SIGMOID,
|
|
13
|
+
IFitSeries,
|
|
14
|
+
FIT_FUNCTION_LINEAR, FIT_FUNCTION_LOG_LINEAR, FIT_FUNCTION_EXPONENTIAL, linear, logLinear, exponential
|
|
14
15
|
} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
15
16
|
import {calculateBoxPlotStatistics} from '@datagrok-libraries/statistics/src/box-plot-statistics';
|
|
16
17
|
import {category, test, expect, expectArray} from '@datagrok-libraries/utils/src/test';
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
const sigmoidSeries: IFitSeries = {
|
|
20
|
-
const linearSeries: IFitSeries = {
|
|
21
|
-
const logLinearSeries: IFitSeries = {
|
|
22
|
-
const exponentialSeries: IFitSeries = {
|
|
23
|
-
const polynomialSeries: IFitSeries = {
|
|
20
|
+
const sigmoidSeries: IFitSeries = {'fitLineColor': '#1f77b4', 'pointColor': '#1f77b4', 'showCurveConfidenceInterval': false, 'points': [{'x': 0.10000000149011612, 'y': 1.7412786483764648}, {'x': 0.6000000238418579, 'y': 1.8561450242996216}, {'x': 1.100000023841858, 'y': 1.6065685749053955}, {'x': 1.600000023841858, 'y': 1.70476496219635}, {'x': 2.0999999046325684, 'y': 1.5737264156341553}, {'x': 2.5999999046325684, 'y': 1.6007002592086792}, {'x': 3.0999999046325684, 'y': 1.6796687841415405}, {'x': 3.5999999046325684, 'y': 1.656104326248169}, {'x': 4.099999904632568, 'y': 1.782997488975525}, {'x': 4.599999904632568, 'y': 1.530208945274353}, {'x': 5.099999904632568, 'y': 1.1572397947311401}, {'x': 5.599999904632568, 'y': 0.8691964745521545}, {'x': 6.099999904632568, 'y': 0.3228665590286255}, {'x': 6.599999904632568, 'y': 0.2990703880786896}, {'x': 7.099999904632568, 'y': 0.23361243307590485}], 'fitFunction': 'sigmoid', 'clickToToggle': false, 'showFitLine': true, 'showPoints': 'points', 'parameters': [1.6914372095641517, 1.1536998642628853, 5.410173358224149, 0.2089689354045083]};
|
|
21
|
+
const linearSeries: IFitSeries = {'fitLineColor': '#1f77b4', 'pointColor': '#1f77b4', 'showCurveConfidenceInterval': false, 'points': [{'x': 0.10000000149011612, 'y': 1.5412786483764648}, {'x': 0.6000000238418579, 'y': 1.9261450242996216}, {'x': 1.100000023841858, 'y': 1.6065685749053955}, {'x': 1.600000023841858, 'y': 1.70476496219635}, {'x': 2.0999999046325684, 'y': 1.5737264156341553}, {'x': 2.5999999046325684, 'y': 1.6007002592086792}, {'x': 3.0999999046325684, 'y': 1.6796687841415405}, {'x': 3.5999999046325684, 'y': 1.656104326248169}, {'x': 4.099999904632568, 'y': 1.782997488975525}, {'x': 4.599999904632568, 'y': 1.530208945274353}, {'x': 5.099999904632568, 'y': 1.1572397947311401}, {'x': 5.599999904632568, 'y': 0.8691964745521545}, {'x': 6.099999904632568, 'y': 0.3228665590286255}, {'x': 6.599999904632568, 'y': 0.2990703880786896}, {'x': 7.099999904632568, 'y': 0.23361243307590485}], 'fitFunction': 'linear', 'clickToToggle': false, 'showFitLine': true, 'showPoints': 'points', 'parameters': [-5.45641324, 10.456486765]};
|
|
22
|
+
const logLinearSeries: IFitSeries = {'fitLineColor': '#1f77b4', 'pointColor': '#1f77b4', 'showCurveConfidenceInterval': false, 'points': [{'x': 0.10000000149011612, 'y': 1.789712786483764648}, {'x': 0.6000000238418579, 'y': 1.210161450242996216}, {'x': 1.100000023841858, 'y': 1.7895685749053955}, {'x': 1.600000023841858, 'y': 1.82476496219635}, {'x': 2.0999999046325684, 'y': 1.5737264156341553}, {'x': 2.5999999046325684, 'y': 1.6007002592086792}, {'x': 3.0999999046325684, 'y': 1.6796687841415405}, {'x': 3.5999999046325684, 'y': 1.656104326248169}, {'x': 4.099999904632568, 'y': 1.782997488975525}, {'x': 4.599999904632568, 'y': 1.530208945274353}, {'x': 5.099999904632568, 'y': 1.1572397947311401}, {'x': 5.599999904632568, 'y': 0.8691964745521545}, {'x': 6.099999904632568, 'y': 0.3228665590286255}, {'x': 6.599999904632568, 'y': 0.2990703880786896}, {'x': 7.099999904632568, 'y': 0.23361243307590485}], 'fitFunction': 'log-linear', 'clickToToggle': false, 'showFitLine': true, 'showPoints': 'points', 'parameters': [-8.45641324, 90.4456456486765]};
|
|
23
|
+
const exponentialSeries: IFitSeries = {'fitLineColor': '#1f77b4', 'pointColor': '#1f77b4', 'showCurveConfidenceInterval': false, 'points': [{'x': 0.10000000149011612, 'y': 1.789712786483764648}, {'x': 0.6000000238418579, 'y': 1.210161450242996216}, {'x': 1.100000023841858, 'y': 1.7895685749053955}, {'x': 1.600000023841858, 'y': 1.82476496219635}, {'x': 2.0999999046325684, 'y': 1.5737264156341553}, {'x': 2.5999999046325684, 'y': 1.6007002592086792}, {'x': 3.0999999046325684, 'y': 1.6796687841415405}, {'x': 3.5999999046325684, 'y': 1.656104326248169}, {'x': 4.099999904632568, 'y': 1.782997488975525}, {'x': 4.599999904632568, 'y': 1.530208945274353}, {'x': 5.099999904632568, 'y': 1.1572397947311401}, {'x': 5.599999904632568, 'y': 0.8691964745521545}, {'x': 6.099999904632568, 'y': 0.3228665590286255}, {'x': 6.599999904632568, 'y': 0.2990703880786896}, {'x': 7.099999904632568, 'y': 0.23361243307590485}], 'fitFunction': 'exponential', 'clickToToggle': false, 'showFitLine': true, 'showPoints': 'points', 'parameters': [88.45641324, -10.4456456486765]};
|
|
24
|
+
const polynomialSeries: IFitSeries = {'fitLineColor': '#2ca02c', 'pointColor': '#2ca02c', 'showCurveConfidenceInterval': true, 'fitFunction': {'name': 'Polynomial', 'function': '([p1, p2, p3, p4], x) => p1 * x * x * x + p2 * x * x + p3 * x + p4', 'getInitialParameters': '(xs, ys) => [0.1, -1, 4, 4]', 'parameterNames': ['Slope', 'Intercept', 'Parameter3', 'Parameter4']}, 'points': [{'x': 0.10000000149011612, 'y': 7.365033149719238}, {'x': 0.6000000238418579, 'y': 6.595034599304199}, {'x': 1.100000023841858, 'y': 7.05179500579834}, {'x': 1.600000023841858, 'y': 7.251461982727051}, {'x': 2.0999999046325684, 'y': 7.775498867034912}, {'x': 2.5999999046325684, 'y': 7.748039722442627}, {'x': 3.0999999046325684, 'y': 6.8391804695129395}, {'x': 3.5999999046325684, 'y': 7.570991516113281}, {'x': 4.099999904632568, 'y': 6.387666702270508}, {'x': 4.599999904632568, 'y': 6.464827537536621}, {'x': 5.099999904632568, 'y': 3.932436227798462}, {'x': 5.599999904632568, 'y': 1.4741199016571045}, {'x': 6.099999904632568, 'y': 0.47604307532310486}, {'x': 6.599999904632568, 'y': 0.5836760401725769}, {'x': 7.099999904632568, 'y': 1.0317600965499878}], 'clickToToggle': false, 'showFitLine': true, 'showPoints': 'points', 'parameters': [0.07070206940832963, -1.138666933634074, 3.947509109407932, 3.9947960440506685]};
|
|
24
25
|
const sigmoidFitFunc = getSeriesFitFunction(sigmoidSeries);
|
|
25
26
|
const linearFitFunc = getSeriesFitFunction(linearSeries);
|
|
26
27
|
const logLinearFitFunc = getSeriesFitFunction(logLinearSeries);
|
|
@@ -29,187 +30,187 @@ const polynomialFitFunc = getSeriesFitFunction(polynomialSeries);
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
category('fit', () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
33
|
+
test('getSeriesFitFunction', async () => {
|
|
34
|
+
const {xs: sigmoidXs, ys: sigmoidYs} = getPointsArrays(sigmoidSeries.points);
|
|
35
|
+
const {xs: linearXs, ys: linearYs} = getPointsArrays(linearSeries.points);
|
|
36
|
+
const {xs: logLinearXs, ys: logLinearYs} = getPointsArrays(logLinearSeries.points);
|
|
37
|
+
const {xs: exponentialXs, ys: exponentialYs} = getPointsArrays(exponentialSeries.points);
|
|
38
|
+
const {xs: polynomialXs, ys: polynomialYs} = getPointsArrays(polynomialSeries.points);
|
|
39
|
+
|
|
40
|
+
expect(sigmoidFitFunc.name, FIT_FUNCTION_SIGMOID);
|
|
41
|
+
expect(linearFitFunc.name, FIT_FUNCTION_LINEAR);
|
|
42
|
+
expect(logLinearFitFunc.name, FIT_FUNCTION_LOG_LINEAR);
|
|
43
|
+
expect(exponentialFitFunc.name, FIT_FUNCTION_EXPONENTIAL);
|
|
44
|
+
expect(polynomialFitFunc.name, 'Polynomial');
|
|
45
|
+
expectArray(sigmoidFitFunc.parameterNames, ['Top', 'Slope', 'IC50', 'Bottom']);
|
|
46
|
+
expectArray(linearFitFunc.parameterNames, ['Slope', 'Intercept']);
|
|
47
|
+
expectArray(logLinearFitFunc.parameterNames, ['Slope', 'Intercept']);
|
|
48
|
+
expectArray(exponentialFitFunc.parameterNames, ['Mantissa', 'Power']);
|
|
49
|
+
expectArray(polynomialFitFunc.parameterNames, ['Slope', 'Intercept', 'Parameter3', 'Parameter4']);
|
|
50
|
+
expectArray(sigmoidFitFunc.getInitialParameters(sigmoidXs, sigmoidYs), [1.8561450242996216, 1, 5.099999904632568, 0.23361243307590485]);
|
|
51
|
+
expectArray(linearFitFunc.getInitialParameters(linearXs, linearYs), [-0.1868094652891159, 1.5599596500396729]);
|
|
52
|
+
expectArray(logLinearFitFunc.getInitialParameters(logLinearXs, logLinearYs), [-5, 100]);
|
|
53
|
+
expectArray(exponentialFitFunc.getInitialParameters(exponentialXs, exponentialYs), [100, -2]);
|
|
54
|
+
expectArray(polynomialFitFunc.getInitialParameters(polynomialXs, polynomialYs), [0.1, -1, 4, 4]);
|
|
55
|
+
const params = new Float32Array(sigmoidSeries.parameters?.length!);
|
|
56
|
+
params.set(sigmoidSeries.parameters!);
|
|
57
|
+
expect(sigmoidFitFunc.y(params, 1.1), 1.6914214561555851);
|
|
58
|
+
expect(linearFitFunc.y(linearFitFunc.getInitialParameters(linearXs, linearYs), 1.1), 1.3544692382216454);
|
|
59
|
+
expect(logLinearFitFunc.y(logLinearFitFunc.getInitialParameters(logLinearXs, logLinearYs), 1.1), 96.29031327635312);
|
|
60
|
+
expect(exponentialFitFunc.y(exponentialFitFunc.getInitialParameters(exponentialXs, exponentialYs), 1.1), 11.080315836233387);
|
|
61
|
+
expect(polynomialFitFunc.y(polynomialFitFunc.getInitialParameters(polynomialXs, polynomialYs), 1.1), 7.3231);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('getCurve', async () => {
|
|
65
|
+
const sigmoidCurve = getCurve(sigmoidSeries, sigmoidFitFunc);
|
|
66
|
+
const linearCurve = getCurve(linearSeries, linearFitFunc);
|
|
67
|
+
const logLinearCurve = getCurve(logLinearSeries, logLinearFitFunc);
|
|
68
|
+
const exponentialCurve = getCurve(exponentialSeries, exponentialFitFunc);
|
|
69
|
+
const polynomialCurve = getCurve(polynomialSeries, polynomialFitFunc);
|
|
70
|
+
|
|
71
|
+
expect(sigmoidCurve(2.5), 1.690786623428712);
|
|
72
|
+
expect(sigmoidCurve(5.8858), 0.5356638447565519);
|
|
73
|
+
expect(linearCurve(2.5), -3.18454647064209);
|
|
74
|
+
expect(linearCurve(5.8858), -21.658870516967774);
|
|
75
|
+
expect(logLinearCurve(2.5), 79.85176680360948);
|
|
76
|
+
expect(logLinearCurve(5.8858), 74.12932588432805);
|
|
77
|
+
expect(exponentialCurve(0.01), 79.68277758636006);
|
|
78
|
+
expect(exponentialCurve(0.00001345), 88.4439865528934);
|
|
79
|
+
expect(polynomialCurve(1.56), 7.650264639782428);
|
|
80
|
+
expect(polynomialCurve(3.99876), 6.093284856699922);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('fitSeries', async () => {
|
|
84
|
+
const start = Date.now();
|
|
85
|
+
const sigmoidFitSeries = fitSeries(sigmoidSeries, sigmoidFitFunc);
|
|
86
|
+
const linearFitSeries = fitSeries(linearSeries, linearFitFunc);
|
|
87
|
+
const logLinearFitSeries = fitSeries(logLinearSeries, logLinearFitFunc);
|
|
88
|
+
const exponentialFitSeries = fitSeries(exponentialSeries, exponentialFitFunc);
|
|
89
|
+
const polynomialFitSeries = fitSeries(polynomialSeries, polynomialFitFunc);
|
|
90
|
+
const stop = Date.now();
|
|
91
|
+
|
|
92
|
+
expect(sigmoidFitSeries.fittedCurve(2.5), 1.6903875076701773);
|
|
93
|
+
expect(linearFitSeries.fittedCurve(2.5), 1.5348530188202858);
|
|
94
|
+
expect(logLinearFitSeries.fittedCurve(2.5), 1.3696734183366701);
|
|
95
|
+
expect(exponentialFitSeries.fittedCurve(0.00001345), 2.005337264075174);
|
|
96
|
+
expect(polynomialFitSeries.fittedCurve(3.99876), 5.911350894323636);
|
|
97
|
+
expectArray(sigmoidFitSeries.parameters, [1.690911054611206, 1.1880898475646973, 5.402130603790283, 0.22163867950439453]);
|
|
98
|
+
expectArray(linearFitSeries.parameters, [-0.21431826055049896, 2.070648670196533]);
|
|
99
|
+
expectArray(logLinearFitSeries.parameters, [-0.6303421854972839, 2.1593427658081055]);
|
|
100
|
+
expectArray(exponentialFitSeries.parameters, [2.005340814590454, -0.13163800537586212]);
|
|
101
|
+
expectArray(polynomialFitSeries.parameters, [0.06199381500482559, -0.9554166793823242, 2.872941017150879, 5.736424446105957]);
|
|
102
|
+
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('fitSeries sigmoid benchmark', async () => {
|
|
106
|
+
const start = Date.now();
|
|
107
|
+
fitSeries(sigmoidSeries, sigmoidFitFunc);
|
|
108
|
+
const stop = Date.now();
|
|
109
|
+
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
110
|
+
}, {benchmark: true});
|
|
111
|
+
|
|
112
|
+
test('fitSeries linear benchmark', async () => {
|
|
113
|
+
const start = Date.now();
|
|
114
|
+
fitSeries(linearSeries, linearFitFunc);
|
|
115
|
+
const stop = Date.now();
|
|
116
|
+
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
117
|
+
}, {benchmark: true});
|
|
118
|
+
|
|
119
|
+
test('fitSeries log-linear benchmark', async () => {
|
|
120
|
+
const start = Date.now();
|
|
121
|
+
fitSeries(logLinearSeries, logLinearFitFunc);
|
|
122
|
+
const stop = Date.now();
|
|
123
|
+
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
124
|
+
}, {benchmark: true});
|
|
125
|
+
|
|
126
|
+
test('fitSeries exponential benchmark', async () => {
|
|
127
|
+
const start = Date.now();
|
|
128
|
+
fitSeries(exponentialSeries, exponentialFitFunc);
|
|
129
|
+
const stop = Date.now();
|
|
130
|
+
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
131
|
+
}, {benchmark: true});
|
|
132
|
+
|
|
133
|
+
test('fitSeries polynomial benchmark', async () => {
|
|
134
|
+
const start = Date.now();
|
|
135
|
+
fitSeries(polynomialSeries, polynomialFitFunc);
|
|
136
|
+
const stop = Date.now();
|
|
137
|
+
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
138
|
+
}, {benchmark: true});
|
|
139
|
+
|
|
140
|
+
test('getSeriesConfidenceInterval', async () => {
|
|
141
|
+
const sigmoidSeriesConfidenceIntervals = getSeriesConfidenceInterval(sigmoidSeries, sigmoidFitFunc, true);
|
|
142
|
+
const linearSeriesConfidenceIntervals = getSeriesConfidenceInterval(linearSeries, linearFitFunc, true);
|
|
143
|
+
const logLinearSeriesConfidenceIntervals = getSeriesConfidenceInterval(logLinearSeries, logLinearFitFunc, true);
|
|
144
|
+
const exponentialSeriesConfidenceIntervals = getSeriesConfidenceInterval(exponentialSeries, exponentialFitFunc, true);
|
|
145
|
+
const polynomialSeriesConfidenceIntervals = getSeriesConfidenceInterval(polynomialSeries, polynomialFitFunc, true);
|
|
146
|
+
|
|
147
|
+
expect(sigmoidSeriesConfidenceIntervals.confidenceTop(2.578), 1.8540855269320198);
|
|
148
|
+
expect(linearSeriesConfidenceIntervals.confidenceTop(2.578), 26.645777275332037);
|
|
149
|
+
expect(logLinearSeriesConfidenceIntervals.confidenceTop(2.578), 231.75768109324696);
|
|
150
|
+
expect(exponentialSeriesConfidenceIntervals.confidenceTop(0.00001345), 103.51168317113999);
|
|
151
|
+
expect(polynomialSeriesConfidenceIntervals.confidenceTop(2.3342), 10.03522960294218);
|
|
152
|
+
expect(sigmoidSeriesConfidenceIntervals.confidenceBottom(3.987), 1.4949306416468298);
|
|
153
|
+
expect(linearSeriesConfidenceIntervals.confidenceBottom(3.987), -41.55415698266847);
|
|
154
|
+
expect(logLinearSeriesConfidenceIntervals.confidenceBottom(3.987), -75.23471085303483);
|
|
155
|
+
expect(exponentialSeriesConfidenceIntervals.confidenceBottom(0.01), 64.61508096811347);
|
|
156
|
+
expect(polynomialSeriesConfidenceIntervals.confidenceBottom(3.8796), 4.1686506915250385);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('getSeriesStatistics', async () => {
|
|
160
|
+
const sigmoidSeriesStatistics = getSeriesStatistics(sigmoidSeries, sigmoidFitFunc);
|
|
161
|
+
// TODO: statistics tests on linear, log linear and exponential series
|
|
162
|
+
const polynomialSeriesStatistics = getSeriesStatistics(polynomialSeries, polynomialFitFunc);
|
|
163
|
+
|
|
164
|
+
expect(sigmoidSeriesStatistics.auc, 9.335422628533761);
|
|
165
|
+
expect(polynomialSeriesStatistics.auc, 36.525538394763096);
|
|
166
|
+
expect(sigmoidSeriesStatistics.rSquared, 0.9781915962461156);
|
|
167
|
+
expect(polynomialSeriesStatistics.rSquared, 0.846055768956569);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('calculateBoxPlotStatistics', async () => {
|
|
171
|
+
const values = [0.7654603719711304, 0.8199243545532227, 0.8257747292518616, 0.9558155536651611, 0.9596694707870483];
|
|
172
|
+
const boxPlotStats = calculateBoxPlotStatistics(values);
|
|
173
|
+
|
|
174
|
+
expect(boxPlotStats.q1, 0.8199243545532227);
|
|
175
|
+
expect(boxPlotStats.q2, 0.8257747292518616);
|
|
176
|
+
expect(boxPlotStats.q3, 0.9558155536651611);
|
|
177
|
+
expect(boxPlotStats.lowerAdjacentValue, 0.7654603719711304);
|
|
178
|
+
expect(boxPlotStats.upperAdjacentValue, 0.9558155536651611);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('sigmoid', async () => {
|
|
182
|
+
const parameters = [2.612687371569039, -1.421800778574126, 5.16688669906018, 0.341788492203575];
|
|
183
|
+
const params = new Float32Array(4);
|
|
184
|
+
params.set(parameters);
|
|
185
|
+
expect(sigmoid(params, 0.5), 0.341789026340178);
|
|
186
|
+
expect(sigmoid(params, 2.5), 0.34215523020636207);
|
|
187
|
+
expect(sigmoid(params, 5.678976), 2.2548815999597016);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('linear', async () => {
|
|
191
|
+
const parameters = [-5.12346546, 6.24654654];
|
|
192
|
+
const params = new Float32Array(2);
|
|
193
|
+
params.set(parameters);
|
|
194
|
+
expect(linear(params, 0.5), 3.684813976287842);
|
|
195
|
+
expect(linear(params, 2.5), -6.562117099761963);
|
|
196
|
+
expect(linear(params, 5.678976), -22.849491081970214);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('log-linear', async () => {
|
|
200
|
+
const parameters = [-5.12346546, 91.5465454654];
|
|
201
|
+
const params = new Float32Array(2);
|
|
202
|
+
params.set(parameters);
|
|
203
|
+
expect(logLinear(params, 0.5), 89.46916042777144);
|
|
204
|
+
expect(logLinear(params, 2.5), 85.12805903963536);
|
|
205
|
+
expect(logLinear(params, 5.678976), 81.81726682791052);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
test('exponential', async () => {
|
|
209
|
+
const parameters = [95.12346546, -11.5465454654];
|
|
210
|
+
const params = new Float32Array(2);
|
|
211
|
+
params.set(parameters);
|
|
212
|
+
expect(exponential(params, 0.0005), 94.57587501550823);
|
|
213
|
+
expect(exponential(params, 0.5), 0.2957925783034655);
|
|
214
|
+
expect(exponential(params, 0.98746), 0.0010630898492656174);
|
|
215
|
+
});
|
|
215
216
|
});
|
package/src/tests/plate-tests.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
1
2
|
import * as DG from 'datagrok-api/dg';
|
|
2
3
|
import * as ui from 'datagrok-api/ui';
|
|
3
4
|
|
|
@@ -20,7 +21,7 @@ function getPlate(): Plate {
|
|
|
20
21
|
|
|
21
22
|
category('plates', () => {
|
|
22
23
|
test('fromCsvPlate', async () => {
|
|
23
|
-
const plate = Plate.fromCsv(concentrationCsv, {
|
|
24
|
+
const plate = Plate.fromCsv(concentrationCsv, {field: 'concentration'});
|
|
24
25
|
plate.print();
|
|
25
26
|
expect(plate.rows, 16);
|
|
26
27
|
expect(plate.cols, 24);
|
|
@@ -45,7 +46,7 @@ category('plates', () => {
|
|
|
45
46
|
test('fromExcel', async () => {
|
|
46
47
|
const plate = await Plate.fromExcelPath('System:DemoFiles/hts/xlsx_plates/plate1.xlsx');
|
|
47
48
|
ui.dialog({title: 'Inspect plate'})
|
|
48
|
-
.add(PlateWidget.detailedView(plate
|
|
49
|
+
.add(PlateWidget.detailedView(plate).root)
|
|
49
50
|
.show({width: 500, height: 500});
|
|
50
51
|
await DG.delay(10000);
|
|
51
52
|
});
|
|
@@ -55,7 +56,7 @@ category('plates', () => {
|
|
|
55
56
|
|
|
56
57
|
const hcMean = jStat.mean(plate.fieldValues('readout', {match: {'layout': 'High Control'}}));
|
|
57
58
|
const lcMean = jStat.mean(plate.fieldValues('readout', {match: {'layout': 'Low Control'}}));
|
|
58
|
-
plate.normalize('readout', value => (hcMean - value) / (hcMean - lcMean));
|
|
59
|
+
plate.normalize('readout', (value) => (hcMean - value) / (hcMean - lcMean));
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
test('use case', async () => {
|
|
@@ -63,7 +64,7 @@ category('plates', () => {
|
|
|
63
64
|
|
|
64
65
|
const hcMean = jStat.mean(plate.fieldValues('readout', {match: {'layout': 'High Control'}}));
|
|
65
66
|
const lcMean = jStat.mean(plate.fieldValues('readout', {match: {'layout': 'Low Control'}}));
|
|
66
|
-
plate.normalize('readout', value => (hcMean - value) / (hcMean - lcMean));
|
|
67
|
+
plate.normalize('readout', (value) => (hcMean - value) / (hcMean - lcMean));
|
|
67
68
|
|
|
68
69
|
const drc = plate.doseResponseSeries({concentration: 'concentration', value: 'readout'}); // if we get
|
|
69
70
|
Plate.inspectSeries(drc['Compound 1'], '4pl-regression');
|
|
@@ -72,7 +73,7 @@ category('plates', () => {
|
|
|
72
73
|
test('render', async () => {
|
|
73
74
|
const plate = getPlate();
|
|
74
75
|
ui.dialog({title: 'Inspect plate'})
|
|
75
|
-
.add(PlateWidget.detailedView(plate
|
|
76
|
+
.add(PlateWidget.detailedView(plate).root)
|
|
76
77
|
.show({width: 500, height: 500});
|
|
77
78
|
await DG.delay(10000);
|
|
78
79
|
});
|
|
@@ -95,8 +96,6 @@ category('plates', () => {
|
|
|
95
96
|
});
|
|
96
97
|
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
99
|
const concentrationCsv = `col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
|
|
101
100
|
A,,,,,,,,,,,,,,,,,,,,,,,,
|
|
102
101
|
B,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
@@ -14,9 +14,9 @@ category('viewport', () => {
|
|
|
14
14
|
const dataBounds = new DG.Rect(0.1, 0.06, 7, 5.94);
|
|
15
15
|
const viewport = new Viewport(dataBounds, dataBox, false, false);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
expect(viewport.xToScreen(1.5), 182.4);
|
|
18
|
+
expect(viewport.yToScreen(2.33), 73.01346801346801);
|
|
19
|
+
expect(viewport.xToWorld(150), -0.9652173913043479);
|
|
20
|
+
expect(viewport.yToWorld(67), 2.855294117647059);
|
|
21
21
|
});
|
|
22
22
|
});
|