@datagrok/curves 1.2.11 → 1.2.13
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 +47 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +9 -9
- package/src/fit/fit-grid-cell-handler.ts +27 -22
- package/src/fit/fit-renderer.ts +3 -1
- package/src/tests/fit-tests.ts +4 -4
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/curves",
|
|
3
3
|
"friendlyName": "Curves",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.13",
|
|
5
5
|
"description": "Curves provides support for fitted curves (such as dose-response curves), including in-grid rendering, storing charts in cells, interactivity, and automatic fitting.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Dmytro Kovalyov",
|
|
8
8
|
"email": "dkovalyov@datagrok.ai"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@datagrok-libraries/statistics": "^1.2.
|
|
12
|
-
"@datagrok-libraries/utils": "^4.1.
|
|
11
|
+
"@datagrok-libraries/statistics": "^1.2.10",
|
|
12
|
+
"@datagrok-libraries/utils": "^4.1.0",
|
|
13
13
|
"@types/wu": "^2.1.42",
|
|
14
14
|
"cash-dom": "latest",
|
|
15
|
-
"datagrok-api": "^1.
|
|
16
|
-
"
|
|
17
|
-
"
|
|
15
|
+
"datagrok-api": "^1.17.0",
|
|
16
|
+
"dayjs": "^1.11.7",
|
|
17
|
+
"rxjs": "6.5.5"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"ts-loader": "latest",
|
|
21
20
|
"css-loader": "^5.0.0",
|
|
21
|
+
"source-map-loader": "^4.0.1",
|
|
22
22
|
"style-loader": "^2.0.0",
|
|
23
|
+
"ts-loader": "latest",
|
|
23
24
|
"typescript": "latest",
|
|
24
25
|
"webpack": "latest",
|
|
25
|
-
"webpack-cli": "latest"
|
|
26
|
-
"source-map-loader": "^4.0.1"
|
|
26
|
+
"webpack-cli": "latest"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"link-all": "npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/statistics",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getSeriesFitFunction,
|
|
9
9
|
getDataFrameChartOptions,
|
|
10
10
|
LogOptions,
|
|
11
|
+
getChartBounds,
|
|
11
12
|
} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
12
13
|
import {statisticsProperties, fitSeriesProperties, fitChartDataProperties, FIT_CELL_TYPE, TAG_FIT, IFitChartData, IFitSeries, IFitChartOptions, FIT_SEM_TYPE, IFitSeriesOptions, FitStatistics} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
13
14
|
import {TAG_FIT_CHART_FORMAT, TAG_FIT_CHART_FORMAT_3DX, getChartData, isColorValid, mergeProperties} from './fit-renderer';
|
|
@@ -56,7 +57,7 @@ export function calculateSeriesStats(series: IFitSeries, chartLogOptions: LogOpt
|
|
|
56
57
|
else
|
|
57
58
|
series.parameters = fitSeries(series, fitFunction, chartLogOptions).parameters;
|
|
58
59
|
|
|
59
|
-
const seriesStatistics = getSeriesStatistics(series, fitFunction);
|
|
60
|
+
const seriesStatistics = getSeriesStatistics(series, fitFunction, chartLogOptions);
|
|
60
61
|
return seriesStatistics;
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -64,25 +65,28 @@ export function getChartDataAggrStats(chartData: IFitChartData, aggrType: string
|
|
|
64
65
|
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
65
66
|
const rSquaredValues: number[] = [], aucValues: number[] = [], interceptXValues: number[] = [], interceptYValues: number[] = [],
|
|
66
67
|
slopeValues: number[] = [], topValues: number[] = [], bottomValues: number[] = [];
|
|
67
|
-
for (let i = 0; i < chartData.series?.length!; i++) {
|
|
68
|
+
for (let i = 0, j = 0; i < chartData.series?.length!; i++) {
|
|
69
|
+
if (chartData.series![i].points.every((p) => p.outlier))
|
|
70
|
+
continue;
|
|
68
71
|
const seriesStats = calculateSeriesStats(chartData.series![i], chartLogOptions);
|
|
69
|
-
rSquaredValues[
|
|
70
|
-
aucValues[
|
|
71
|
-
interceptXValues[
|
|
72
|
-
interceptYValues[
|
|
73
|
-
slopeValues[
|
|
74
|
-
topValues[
|
|
75
|
-
bottomValues[
|
|
72
|
+
rSquaredValues[j] = seriesStats.rSquared!;
|
|
73
|
+
aucValues[j] = seriesStats.auc!;
|
|
74
|
+
interceptXValues[j] = seriesStats.interceptX;
|
|
75
|
+
interceptYValues[j] = seriesStats.interceptY;
|
|
76
|
+
slopeValues[j] = seriesStats.slope;
|
|
77
|
+
topValues[j] = seriesStats.top!;
|
|
78
|
+
bottomValues[j] = seriesStats.bottom!;
|
|
79
|
+
j++;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
return {
|
|
79
|
-
rSquared: DG.
|
|
80
|
-
auc: DG.
|
|
81
|
-
interceptX: DG.
|
|
82
|
-
interceptY: DG.
|
|
83
|
-
slope: DG.
|
|
84
|
-
top: DG.
|
|
85
|
-
bottom: DG.
|
|
83
|
+
rSquared: DG.Stats.fromValues(rSquaredValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
84
|
+
auc: DG.Stats.fromValues(aucValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
85
|
+
interceptX: DG.Stats.fromValues(interceptXValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
86
|
+
interceptY: DG.Stats.fromValues(interceptYValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
87
|
+
slope: DG.Stats.fromValues(slopeValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
88
|
+
top: DG.Stats.fromValues(topValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
89
|
+
bottom: DG.Stats.fromValues(bottomValues)[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number
|
|
86
90
|
};
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -93,8 +97,6 @@ function addStatisticsColumn(chartColumn: DG.GridColumn, p: DG.Property, series:
|
|
|
93
97
|
column.tags[SERIES_NUMBER_TAG] = seriesNumber;
|
|
94
98
|
column.tags[STATISTICS_TAG] = p.name;
|
|
95
99
|
|
|
96
|
-
// accordions for runs
|
|
97
|
-
// combobox - series -> all or aggregated, in all we have all the series, then combobox with aggr
|
|
98
100
|
column
|
|
99
101
|
.init((i) => {
|
|
100
102
|
const gridCell = DG.GridCell.fromColumnRow(grid, chartColumn.name, grid.tableRowToGrid(i));
|
|
@@ -102,7 +104,7 @@ function addStatisticsColumn(chartColumn: DG.GridColumn, p: DG.Property, series:
|
|
|
102
104
|
return null;
|
|
103
105
|
const chartData = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX ?
|
|
104
106
|
convertXMLToIFitChartData(gridCell.cell.value) : getChartData(gridCell);
|
|
105
|
-
if (chartData.series![seriesNumber] === undefined)
|
|
107
|
+
if (chartData.series![seriesNumber] === undefined || chartData.series![seriesNumber].points.every((p) => p.outlier))
|
|
106
108
|
return null;
|
|
107
109
|
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
108
110
|
const fitResult = calculateSeriesStats(chartData.series![seriesNumber], chartLogOptions);
|
|
@@ -125,6 +127,8 @@ function addAggrStatisticsColumn(chartColumn: DG.GridColumn, p: DG.Property, agg
|
|
|
125
127
|
return null;
|
|
126
128
|
const chartData = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX ?
|
|
127
129
|
convertXMLToIFitChartData(gridCell.cell.value) : getChartData(gridCell);
|
|
130
|
+
if (chartData.series?.every((series) => series.points.every((p) => p.outlier)))
|
|
131
|
+
return null;
|
|
128
132
|
const fitResult = getChartDataAggrStats(chartData, aggrType);
|
|
129
133
|
return p.get(fitResult);
|
|
130
134
|
});
|
|
@@ -144,9 +148,6 @@ function changePlotOptions(chartData: IFitChartData, inputBase: DG.InputBase, op
|
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
// TODO: fix the margins if small cell sizes
|
|
148
|
-
// TODO: don't allow clickToToggle if small size
|
|
149
|
-
|
|
150
151
|
function convertJnJColumnToJSON(column: DG.Column): void {
|
|
151
152
|
for (let i = 0; i < column.length; i++) {
|
|
152
153
|
const value = column.get(i);
|
|
@@ -346,6 +347,10 @@ export class FitGridCellHandler extends DG.ObjectHandler {
|
|
|
346
347
|
|
|
347
348
|
function createFitPane(): HTMLElement {
|
|
348
349
|
const host = ui.divV(seriesStatsInput.stringValue === 'aggregated' ? [seriesStatsInput.root, aggrTypeInput.root] : [seriesStatsInput.root]);
|
|
350
|
+
const dataBounds = getChartBounds(chartData);
|
|
351
|
+
if (dataBounds.x <= 0 && chartData.chartOptions) chartData.chartOptions.logX = false;
|
|
352
|
+
if (dataBounds.y <= 0 && chartData.chartOptions) chartData.chartOptions.logY = false;
|
|
353
|
+
|
|
349
354
|
if (seriesStatsInput.stringValue === 'all') {
|
|
350
355
|
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
351
356
|
for (let i = 0; i < chartData.series!.length; i++) {
|
package/src/fit/fit-renderer.ts
CHANGED
|
@@ -389,6 +389,8 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
389
389
|
|
|
390
390
|
for (let i = 0; i < data.series?.length!; i++) {
|
|
391
391
|
const series = data.series![i];
|
|
392
|
+
if (series.points.some((point) => point.x === undefined || point.y === undefined))
|
|
393
|
+
continue;
|
|
392
394
|
if (w < MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH || h < MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT) {
|
|
393
395
|
series.showPoints = '';
|
|
394
396
|
if (data.chartOptions)
|
|
@@ -475,7 +477,7 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
475
477
|
}
|
|
476
478
|
|
|
477
479
|
if (data.chartOptions?.showStatistics) {
|
|
478
|
-
const statistics = getSeriesStatistics(series, fitFunc);
|
|
480
|
+
const statistics = getSeriesStatistics(series, fitFunc, chartLogOptions);
|
|
479
481
|
for (let j = 0; j < data.chartOptions.showStatistics.length; j++) {
|
|
480
482
|
const statName = data.chartOptions.showStatistics[j];
|
|
481
483
|
const prop = statisticsProperties.find(p => p.name === statName);
|
package/src/tests/fit-tests.ts
CHANGED
|
@@ -48,10 +48,10 @@ category('fit', () => {
|
|
|
48
48
|
const polynomialFitSeries = fitSeries(polynomialSeries, polynomialFitFunc);
|
|
49
49
|
const stop = Date.now();
|
|
50
50
|
|
|
51
|
-
expect(sigmoidFitSeries.fittedCurve(2.5), 1.
|
|
52
|
-
expect(polynomialFitSeries.fittedCurve(3.99876), 6.
|
|
53
|
-
expectArray(sigmoidFitSeries.parameters, [1.
|
|
54
|
-
expectArray(polynomialFitSeries.parameters, [0.
|
|
51
|
+
expect(sigmoidFitSeries.fittedCurve(2.5), 1.690742266220136);
|
|
52
|
+
expect(polynomialFitSeries.fittedCurve(3.99876), 6.09328601677405);
|
|
53
|
+
expectArray(sigmoidFitSeries.parameters, [1.691390784119389, 1.1540819399621425, 5.4104428146970704, 0.20886765646057662]);
|
|
54
|
+
expectArray(polynomialFitSeries.parameters, [0.07070206940832963, -1.138666933634074, 3.947509109407932, 3.9947960440506685]);
|
|
55
55
|
return `${stop.valueOf() - start.valueOf()} ms`;
|
|
56
56
|
});
|
|
57
57
|
|