@datagrok/curves 1.6.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.
Files changed (58) hide show
  1. package/.eslintrc.json +39 -0
  2. package/.vscode/launch.json +10 -9
  3. package/.vscode/tasks.json +14 -0
  4. package/CHANGELOG.md +33 -0
  5. package/README.md +36 -8
  6. package/databases/plates/0000_init.sql +167 -0
  7. package/detectors.js +2 -2
  8. package/dist/package-test.js +15930 -1
  9. package/dist/package-test.js.map +1 -1
  10. package/dist/package.js +13750 -1
  11. package/dist/package.js.map +1 -1
  12. package/img/plate-dose-response-series.gif +0 -0
  13. package/img/plate-readers.gif +0 -0
  14. package/package.json +17 -11
  15. package/queries/plates-crud.sql +148 -0
  16. package/src/fit/const.ts +60 -59
  17. package/src/fit/data-to-curves.ts +220 -0
  18. package/src/fit/fit-demo.ts +6 -6
  19. package/src/fit/fit-grid-cell-handler.ts +94 -85
  20. package/src/fit/fit-renderer.ts +162 -98
  21. package/src/fit/multi-curve-viewer.ts +69 -28
  22. package/src/fit/render-utils.ts +346 -288
  23. package/src/package-api.ts +167 -0
  24. package/src/package-test.ts +7 -1
  25. package/src/package.g.ts +140 -2
  26. package/src/package.ts +221 -79
  27. package/src/plate/excel-plates.ts +112 -0
  28. package/src/plate/plate-cell-renderer.ts +48 -0
  29. package/src/plate/plate-drc-analysis.ts +262 -0
  30. package/src/plate/plate-reader.ts +28 -0
  31. package/src/plate/plate-well-validators.ts +41 -0
  32. package/src/plate/plate-widget.ts +242 -0
  33. package/src/plate/plate.ts +557 -0
  34. package/src/plate/plates-folder-preview.ts +63 -0
  35. package/src/plate/readers/bmg-pherastar-96.ts +42 -0
  36. package/src/plate/readers/delfia-envision-96-max-rlu.ts +16 -0
  37. package/src/plate/readers/delfia-envision-by-row.ts +18 -0
  38. package/src/plate/readers/spectramax.ts +42 -0
  39. package/src/plate/utils.ts +141 -0
  40. package/src/plates/numeric_matcher.ts +191 -0
  41. package/src/plates/objects/plate-template-handler.ts +48 -0
  42. package/src/plates/plates-app.ts +64 -0
  43. package/src/plates/plates-crud.ts +502 -0
  44. package/src/plates/plates-demo.ts +107 -0
  45. package/src/plates/plates.sql +169 -0
  46. package/src/plates/views/plates-create-view.ts +123 -0
  47. package/src/plates/views/plates-schema-view.ts +58 -0
  48. package/src/plates/views/plates-search-view.ts +137 -0
  49. package/src/plates/views/plates-templates-view.ts +38 -0
  50. package/src/tests/curves-cell-renderer-tests.ts +95 -75
  51. package/src/tests/detector-tests.ts +3 -2
  52. package/src/tests/fit-tests.ts +199 -163
  53. package/src/tests/plate-tests.ts +153 -0
  54. package/src/tests/transform-tests.ts +6 -6
  55. package/test-console-output-1.log +435 -0
  56. package/test-record-1.mp4 +0 -0
  57. package/tsconfig.json +1 -1
  58. package/src/fit/cell-render-viewer.ts +0 -54
package/.eslintrc.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es6": true
5
+ },
6
+ "extends": ["google"],
7
+ "parser": "@typescript-eslint/parser",
8
+ "parserOptions": {
9
+ "ecmaVersion": 12,
10
+ "sourceType": "module"
11
+ },
12
+ "plugins": ["@typescript-eslint"],
13
+ "rules": {
14
+ "indent": ["error", 2, { "SwitchCase": 1 }],
15
+ "max-len": ["error", 120],
16
+ "no-unused-vars": "off",
17
+ "@typescript-eslint/no-unused-vars": [
18
+ "warn",
19
+ { "varsIgnorePattern": "^(_|ui$|grok$|DG$)", "argsIgnorePattern": "^_" }
20
+ ],
21
+ "require-jsdoc": "off",
22
+ "valid-jsdoc": "off",
23
+ "spaced-comment": "off",
24
+ "linebreak-style": "off",
25
+ "curly": ["error", "multi-or-nest", "consistent"],
26
+ "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
27
+ "block-spacing": [2, "always"],
28
+ "comma-dangle": [
29
+ "error",
30
+ {
31
+ "arrays": "only-multiline",
32
+ "functions": "never",
33
+ "objects": "only-multiline",
34
+ "imports": "only-multiline"
35
+ }
36
+ ],
37
+ "guard-for-in": "off"
38
+ }
39
+ }
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "version": "0.2.0",
3
3
  "configurations": [
4
- {
5
- "preLaunchTask": "rebuild",
6
- "type": "chrome",
7
- "request": "launch",
8
- "name": "Launch Chrome against Dev",
9
- "url": "https://dev.datagrok.ai/",
10
- "webRoot": "${workspaceFolder}"
11
- }
4
+ {
5
+ "name": "Launch Curves",
6
+ "type": "chrome",
7
+ "request": "launch",
8
+ "url": "http://localhost:8888",
9
+ "preLaunchTask": "debug-curves",
10
+ "webRoot": "${workspaceFolder}",
11
+ "restart": true
12
+ }
12
13
  ]
13
- }
14
+ }
@@ -5,6 +5,20 @@
5
5
  "type": "shell",
6
6
  "command": "(cmd.exe /c \"npm run build) -and (grok publish dev\")",
7
7
  "label": "rebuild"
8
+ },
9
+ {
10
+ "label": "debug-curves",
11
+ "type": "shell",
12
+ "command": "npm run debug-curves",
13
+ "group": {
14
+ "kind": "build",
15
+ "isDefault": true
16
+ },
17
+ "presentation": {
18
+ "reveal": "always",
19
+ "panel": "new"
20
+ },
21
+ "problemMatcher": []
8
22
  }
9
23
  ]
10
24
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Curves changelog
2
2
 
3
+
4
+ ## 1.6.0 - 1.8.0 (2025-03-31)
5
+
6
+ ### Features
7
+
8
+ * GROK-17295: Fitting caching:
9
+ * Performance improvements
10
+ * Cached fitting and wrote tests
11
+ * Fixed margins
12
+ * Fit: Disabled caching for non valid row indexes
13
+ * Outliers: Made outlier toggling not to invalidate the whole grid
14
+ * Added custom event for outlier toggling
15
+ * Added 4pl-regression fit function
16
+ * #3195: Plate Viewer:
17
+ * Supported plate handling
18
+ * Implemented automatic plate import from Excel
19
+ * Added new fluent API
20
+ * Enabled DRC with grouping
21
+ * Supported multi-plate file folders
22
+ * Added details, stats column, IC50, curve preview, statistics recalculation, outlier marking, configuration options
23
+ * Implemented content-dependent file import
24
+ * Added rendering for 1536-well plates
25
+ * Enabled inspection of single series in plate
26
+ * Added demo
27
+ * Plate readers: Added Delfia Envision and Spectramax parsers
28
+ * Added docs on plate DRC
29
+
30
+ ### Bug fixes
31
+
32
+ * Fixed MultiCurveViewer issues
33
+ * Fit panel: Fixed namings and inputs
34
+ * GROK-17492: Fixed error when adding statistics column if the series has no name
35
+
3
36
  ## 1.5.0 (2024-08-23)
4
37
 
5
38
  ### Features
package/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # Curves
2
2
 
3
- **Curves** provides support for fitted curves (such as dose-response curves),
4
- including in-grid rendering, storing charts in cells, interactivity, and automatic fitting.
3
+ **Curves** provides support for dose-response curves,
4
+ including charts in cells, interactivity, and automatic fitting.
5
+ Also, it integrates with assay plates, allowing you to
6
+ [read data directly from instruments](#plate-readers), and visualize
7
+ [dose-response curves from assay plates](#integration-with-assay-plates).
5
8
 
6
9
  - Fitting: computing parameters of the specified function to best fit the data
7
10
  - For dose-response curves, we are typically fitting the sigmoid function
@@ -21,11 +24,13 @@ including in-grid rendering, storing charts in cells, interactivity, and automat
21
24
  - Ability to overlay curves from multiple grid cells (special viewer)
22
25
  - Work with series stored in multiple formats (binary for performance, JSON for flexibility, etc.)
23
26
 
24
- ## Rendering fitted curves using JSON format
27
+ ## Data format
25
28
 
26
- To render a fitted curve based on series points, you need to write it in the following JSON format:
29
+ To render a fitted curve, the cell has to contain a string in the following JSON format:
27
30
 
28
- ```json
31
+ <details>
32
+ <summary> Example of the JSON chart cell </summary>
33
+ <pre>
29
34
  {
30
35
  "series": [
31
36
  {
@@ -76,7 +81,8 @@ To render a fitted curve based on series points, you need to write it in the fol
76
81
  "showColumnLabel": true
77
82
  }
78
83
  }
79
- ```
84
+ </pre>
85
+ </details>
80
86
 
81
87
  Each series has its own parameters, such as:
82
88
 
@@ -93,7 +99,7 @@ Each series has its own parameters, such as:
93
99
  - `showFitLine` - defines whether to show the fit line or not
94
100
  - `showCurveConfidenceInterval` - defines whether to show the confidence intervals or not
95
101
  - `fitFunction` - controls the series fit function, which could be either a sigmoid, linear, log-linear function or a
96
- [custom-defined function](/README.md#creating-custom-fit-function).
102
+ [custom-defined function](#creating-a-custom-fit-function).
97
103
  - `parameters` - controls the series parameters, if set explicitly - the fitting process won't be executed. The parameter order of the
98
104
  sigmoid function is: `max, tan, IC50, min`.
99
105
  - `parameterBounds` - defines the acceptable range of each parameter, which is taken into account during the fitting. See also `parameters`
@@ -146,10 +152,32 @@ returns the result of the fit function. These functions are written as JavaScrip
146
152
 
147
153
  ## Multi Curve Viewer
148
154
 
149
- You can overlay curves from multiple cells on one chart with the Multi Curve Viewer:
155
+ To compare dose-response curves from multiple cells, put them on the Multi Curve Viewer::
150
156
 
151
157
  ![](img/multi-curve-viewer.gif)
152
158
 
159
+ ## Integration with assay plates
160
+
161
+ For a number of commonly used formats representing assay plates, Curves automatically detects
162
+ layout, concentration, and activity layers, and shows you plate content in the form of automatically
163
+ fitted dose-response curves.
164
+
165
+ While typically such functionality gets integrated into custom apps (for instance, for doing
166
+ the quality control, registering experiments to ELN, etc), this is quite useful for
167
+ previewing plates. In this picture, excel files are recognized as containing assay plate data,
168
+ and we can see dose-response curves in the file preview.
169
+
170
+ ![](img/plate-dose-response-series.gif)
171
+
172
+ ## Plate readers
173
+
174
+ The package provides support for some of the common plate formats produced by instruments, such
175
+ as **BMG Pherastar**, **Delfia Envision**, and **Spectramax**. The detection / parsing mechanism
176
+ is extensible, so you can easily write your own reader - [see examples](src/plate/plate-reader.ts).
177
+
178
+
179
+ ![](img/plate-readers.gif)
180
+
153
181
  See also:
154
182
 
155
183
  - [Packages](../../help/develop/develop.md#packages)
@@ -0,0 +1,167 @@
1
+ -- Explains the meaning of a scalar property.
2
+ CREATE TABLE plates.semantic_types (
3
+ id SERIAL PRIMARY KEY,
4
+ name TEXT NOT NULL, -- e.g., "Molecule", "Cell", "Tissue", "Organism", "Treatment", "Drug", "Image"
5
+ description TEXT
6
+ );
7
+
8
+ -- Similar to core.properties or MolTrack.properties
9
+ -- Consider merging
10
+ CREATE TABLE plates.properties (
11
+ id SERIAL PRIMARY KEY,
12
+ name TEXT NOT NULL,
13
+ nullable BOOLEAN NOT NULL DEFAULT TRUE, -- used for validation of the submitted data
14
+ type TEXT CHECK (type IN ('int', 'double', 'bool', 'datetime', 'string')),
15
+ semType TEXT, -- Semantic type
16
+ userEditable BOOLEAN, -- Whether the property should be editable via the UI
17
+ units TEXT, -- Units of measurement
18
+ min REAL, -- Minimum value. Applicable to numerical properties only
19
+ max REAL, -- Maximum value. Applicable to numerical properties only
20
+ step REAL, -- Step to be used in a slider. Only applies to numerical properties
21
+ showSlider REAL, -- Whether a slider appears next to the number input. Applies to numerical columns only
22
+ showPlusMinus REAL, -- Whether a plus/minus clicker appears next to the number input. Applies to numerical columns only
23
+ inputType TEXT, -- Property input type (see DG.InputType)
24
+ category TEXT, -- Corresponding category on the context panel
25
+ format TEXT, -- Value format, such as '0.000'
26
+ choices TEXT, -- JSON-encoded list of choices. Applicable to string properties only
27
+ validators TEXT, -- JSON-encoded list of validators, such as '[">42"]'
28
+ friendlyName TEXT, -- Custom field friendly name shown in [PropertyGrid]
29
+ options JSONB, -- Additional options
30
+
31
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
32
+ );
33
+
34
+ -- Allowed values for properties that are strings, floats, or integers.
35
+ -- When allowed values are present, the property value must be one of the allowed values.
36
+ CREATE TABLE plates.property_allowed_values (
37
+ id SERIAL PRIMARY KEY,
38
+ property_id INTEGER NOT NULL REFERENCES plates.properties(id),
39
+ value_string TEXT,
40
+ value_float REAL,
41
+ value_int INTEGER
42
+ );
43
+
44
+ -- maximum volume per well, material, shape (round bottom, conical).
45
+ CREATE TABLE plates.plate_types (
46
+ id SERIAL PRIMARY KEY,
47
+ name TEXT,
48
+ rows SMALLINT,
49
+ cols SMALLINT,
50
+ max_volume REAL -- microliters
51
+ );
52
+
53
+ -- layouts are reused across assay runs
54
+ CREATE TABLE plates.layouts (
55
+ id SERIAL PRIMARY KEY,
56
+ rows SMALLINT,
57
+ cols SMALLINT,
58
+ description TEXT,
59
+ details JSONB,
60
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
61
+ created_by UUID
62
+ );
63
+
64
+ -- represents an assay plate
65
+ CREATE TABLE plates.plates (
66
+ id SERIAL PRIMARY KEY,
67
+ layout_id INTEGER references plates.layouts(id),
68
+ plate_type_id INTEGER references plates.plate_types(id),
69
+ barcode TEXT,
70
+ description TEXT,
71
+ details JSONB,
72
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
73
+ created_by UUID
74
+ );
75
+
76
+ -- User-defined plate details
77
+ -- Stored in the Plate.meta in TypeScript
78
+ CREATE TABLE plates.plate_details (
79
+ plate_id INTEGER NOT NULL REFERENCES plates.plates(id),
80
+ property_id INTEGER NOT NULL REFERENCES plates.properties(id),
81
+
82
+ value_datetime TIMESTAMP WITH TIME ZONE,
83
+ value_uuid uuid,
84
+ value_num REAL,
85
+ value_string TEXT,
86
+ value_bool BOOLEAN,
87
+
88
+ PRIMARY KEY (plate_id, property_id)
89
+ );
90
+
91
+ -- A template specifies a set of properties applicable on plate and well levels.
92
+ -- See also template_plate_properties and template_well_properties.
93
+ CREATE TABLE plates.templates (
94
+ id SERIAL PRIMARY KEY,
95
+ plate_layout_id INTEGER REFERENCES plates.plates(id),
96
+ name TEXT,
97
+ description TEXT,
98
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
99
+ created_by UUID
100
+ );
101
+
102
+ CREATE TABLE plates.template_plate_properties (
103
+ template_id INTEGER NOT NULL references plates.templates(id),
104
+ property_id INTEGER NOT NULL references plates.properties(id),
105
+ PRIMARY KEY (template_id, property_id)
106
+ );
107
+
108
+ CREATE TABLE plates.template_well_properties (
109
+ template_id INTEGER NOT NULL references plates.templates(id),
110
+ property_id INTEGER NOT NULL references plates.properties(id),
111
+ PRIMARY KEY (template_id, property_id)
112
+ );
113
+
114
+
115
+ CREATE TABLE plates.plate_layout_wells (
116
+ layout_id INTEGER NOT NULL references plates.plates(id),
117
+ row SMALLINT,
118
+ col SMALLINT,
119
+ PRIMARY KEY (layout_id, row, col)
120
+ );
121
+
122
+ CREATE TABLE plates.plate_wells (
123
+ plate_id INTEGER NOT NULL references plates.plates(id),
124
+ row SMALLINT,
125
+ col SMALLINT,
126
+ details JSONB,
127
+ PRIMARY KEY (plate_id, row, col)
128
+ );
129
+
130
+ CREATE TABLE plates.plate_well_values (
131
+ plate_id INTEGER NOT NULL references plates.plates(id),
132
+ row SMALLINT,
133
+ col SMALLINT,
134
+ property_id INTEGER references plates.properties(id),
135
+
136
+ value_num REAL,
137
+ value_string TEXT,
138
+ value_bool BOOLEAN
139
+ );
140
+
141
+
142
+ INSERT INTO plates.semantic_types (name) values ('Molecule');
143
+ INSERT INTO plates.semantic_types (name) values ('Solvent');
144
+ INSERT INTO plates.semantic_types (name) values ('URL');
145
+ INSERT INTO plates.semantic_types (name) values ('Image');
146
+
147
+ INSERT INTO plates.properties (id, name, type, units) values (1000, 'Volume', 'double', 'uL');
148
+ INSERT INTO plates.properties (id, name, type, units) values (1001, 'Concentration', 'double', 'uM');
149
+ INSERT INTO plates.properties (id, name, type) values (1002, 'Sample', 'string');
150
+ INSERT INTO plates.properties (id, name, type) values (1003, 'Well Role', 'string');
151
+
152
+ INSERT INTO plates.plate_types (id, name, rows, cols) values (1, 'Generic 96 wells', 8, 12);
153
+ INSERT INTO plates.plate_types (id, name, rows, cols) values (2, 'Generic 384 wells', 16, 24);
154
+ INSERT INTO plates.plate_types (id, name, rows, cols) values (3, 'Generic 1536 wells', 32, 48);
155
+
156
+ INSERT INTO plates.property_allowed_values (property_id, value_string)
157
+ VALUES
158
+ (1003, 'Empty'),
159
+ (1003, 'Sample'),
160
+ (1003, 'DMSO'),
161
+ (1003, 'Low Control'),
162
+ (1003, 'High Control');
163
+
164
+
165
+ GRANT ALL PRIVILEGES ON SCHEMA plates TO CURRENT_USER;
166
+ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA plates TO :LOGIN;
167
+ GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA plates TO :LOGIN;
package/detectors.js CHANGED
@@ -26,11 +26,11 @@ 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('fitFunction');
29
+ return s.includes('series') && s.includes('points');
30
30
  }, 1)) {
31
31
  col.semType = FIT_SEM_TYPE;
32
32
  return col.semType;
33
33
  }
34
34
  return null;
35
- }
35
+ }
36
36
  }