@datagrok/api-samples 1.0.8 → 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.
- package/CHANGELOG.md +14 -1
- package/README.md +2 -2
- package/dist/package-test.js +1848 -2
- package/dist/package.js +30 -2
- package/files/viewer-events/bar-chart/on-category-clicked.js +1 -0
- package/files/viewer-events/grid/on-cell-clicked.js +1 -0
- package/files/viewer-events/pc-plot/on-line-clicked.js +1 -0
- package/files/viewer-events/pie-chart/on-segment-clicked.js +1 -0
- package/files/viewer-events/scatter-plot/on-point-clicked.js +1 -0
- package/files/viewer-events/scatter-plot/on-rendered.js +1 -0
- package/layouts/demog-table-layout.json +329 -181
- package/package.json +23 -20
- package/scripts/dapi/admin.js +5 -5
- package/scripts/dapi/applicable-layouts.js +3 -1
- package/scripts/dapi/fetch.js +8 -6
- package/scripts/dapi/files.js +45 -0
- package/scripts/dapi/projects-list.js +3 -3
- package/scripts/dapi/projects-open.js +4 -4
- package/scripts/dapi/sticky-meta-1-tags.js +54 -0
- package/scripts/dapi/sticky-meta-2-semtype.js +33 -0
- package/scripts/dapi/who-am-i.js +10 -10
- package/scripts/data-access/db/ad-hoc-query.js +16 -0
- package/scripts/data-access/db/db-edit.js +6 -9
- package/scripts/data-access/{parameterized-query.js → db/parameterized-query.js} +3 -2
- package/scripts/data-access/db/query_builder_join.js +15 -0
- package/scripts/data-access/db/query_builder_simple.js +15 -0
- package/scripts/data-access/db-master-details-manual.js +10 -12
- package/scripts/data-access/external/stock-prices.js +2 -2
- package/scripts/data-access/files/file-exists.js +10 -0
- package/scripts/data-access/files/read-file.js +19 -0
- package/scripts/data-access/load-csv.js +2 -2
- package/scripts/data-access/open-table-by-id.js +11 -3
- package/scripts/data-access/output-layouts.js +3 -1
- package/scripts/data-access/save-and-load-df.js +6 -5
- package/scripts/data-frame/advanced/data-frames-in-columns.js +4 -1
- package/scripts/data-frame/advanced/virtual-columns.js +1 -1
- package/scripts/data-frame/aggregation/unpivot.js +1 -1
- package/scripts/data-frame/column-access.js +5 -3
- package/scripts/data-frame/columns-ordering.js +4 -0
- package/scripts/data-frame/compare-tables.js +3 -2
- package/scripts/data-frame/construction/add-new-column.js +13 -0
- package/scripts/data-frame/construction/create-from-columns.js +4 -4
- package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
- package/scripts/data-frame/construction/create-from-typed-arrays.js +7 -2
- package/scripts/data-frame/construction/date-time.js +24 -0
- package/scripts/data-frame/construction/export-to-csv-advanced.js +14 -4
- package/scripts/data-frame/construction/export-to-csv-molblock.js +3 -0
- package/scripts/data-frame/construction/export-to-csv.js +1 -1
- package/scripts/data-frame/events/calculated-columns/creation.js +1 -1
- package/scripts/data-frame/events/calculated-columns/deletion.js +1 -1
- package/scripts/data-frame/events/calculated-columns/update.js +1 -1
- package/scripts/data-frame/join-link/link-tables-dynamic.js +11 -12
- package/scripts/data-frame/join-link/link-tables.js +12 -8
- package/scripts/data-frame/metadata/dataframe-meta.js +1 -1
- package/scripts/data-frame/modification/add-columns.js +1 -1
- package/scripts/data-frame/modification/append.js +1 -1
- package/scripts/data-frame/modification/calculated-columns/edit-formula.js +2 -2
- package/scripts/data-frame/modification/double-precision.js +26 -0
- package/scripts/data-frame/modification/manipulate.js +3 -3
- package/scripts/demo/med-chem.js +103 -0
- package/scripts/demo/stock-broker.js +1 -1
- package/scripts/domains/chem/chem-benchmark.js +0 -5
- package/scripts/domains/chem/descriptors.js +2 -4
- package/scripts/domains/chem/diversity-search.js +2 -4
- package/scripts/domains/chem/mcs.js +3 -3
- package/scripts/domains/chem/r-group.js +3 -3
- package/scripts/domains/chem/similarity-scoring-scores.js +3 -5
- package/scripts/domains/chem/similarity-scoring-sorted.js +3 -5
- package/scripts/domains/chem/sketcher.js +2 -2
- package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +11 -12
- package/scripts/domains/chem/substructure-search-smarts.js +4 -7
- package/scripts/domains/chem/substructure-search.js +5 -6
- package/scripts/domains/data-science/cluster.js +8 -10
- package/scripts/domains/data-science/missing-values-imputation.js +3 -3
- package/scripts/domains/data-science/pca.js +3 -3
- package/scripts/domains/data-science/predictive-model.js +4 -4
- package/scripts/domains/data-science/random-data.js +5 -6
- package/scripts/events/form-creation.js +2 -2
- package/scripts/events/function-events.js +1 -1
- package/scripts/events/global-events.js +1 -1
- package/scripts/events/layout-events.js +5 -6
- package/scripts/events/viewer-data-events.js +11 -0
- package/scripts/functions/caching-results.js +8 -9
- package/scripts/functions/calling.js +7 -10
- package/scripts/functions/func-call.js +9 -2
- package/scripts/functions/param-editor.js +1 -1
- package/scripts/functions/progress.js +2 -5
- package/scripts/functions/register-function.js +1 -1
- package/scripts/grid/advanced/cell-renderer.js +1 -1
- package/scripts/grid/advanced/column-groups.js +8 -0
- package/scripts/grid/advanced/dynamic-value-retrieval.js +12 -0
- package/scripts/grid/advanced/format-formula.js +7 -0
- package/scripts/grid/{hit-test.js → advanced/hit-test.js} +1 -1
- package/scripts/grid/advanced/link-click.js +3 -3
- package/scripts/grid/advanced/markup-link.js +6 -0
- package/scripts/grid/advanced/paint-counts.js +4 -1
- package/scripts/grid/cell-types/tags-multi-cell.js +18 -0
- package/scripts/grid/{color-coding-conditional.js → color-coding/color-coding-conditional.js} +17 -10
- package/scripts/grid/color-coding/color-coding.js +8 -9
- package/scripts/grid/color-coding/get-cell-color.js +3 -5
- package/scripts/grid/html-cells/html-table-cells.js +1 -1
- package/scripts/grid/styles/column-cell-styles.js +10 -0
- package/scripts/grid/{column-controlled-values.js → styles/column-controlled-values.js} +2 -2
- package/scripts/grid/{data-format.js → styles/data-format.js} +4 -4
- package/scripts/misc/audit/errors-summary.js +2 -2
- package/scripts/misc/audit/test-tracking.js +2 -2
- package/scripts/misc/audit/users-today.js +3 -5
- package/scripts/misc/package-credentials.js +2 -1
- package/scripts/misc/user-settings-storage.js +48 -0
- package/scripts/performance/all-chembl-structures.js +2 -1
- package/scripts/scripting/files-for-scripting.js +24 -0
- package/scripts/scripting/grok-scripting.js +2 -3
- package/scripts/scripting/package-scripting.js +8 -0
- package/scripts/shell/last-error.js +1 -1
- package/scripts/shell/ui-parts.js +9 -9
- package/scripts/shell/windows/browse/customize-tree.js +3 -0
- package/scripts/ui/apps/bioreactor.js +5 -5
- package/scripts/ui/components/accordion.js +3 -3
- package/scripts/ui/components/drop-down.js +8 -5
- package/scripts/ui/components/icons.js +7 -7
- package/scripts/ui/components/menu-advanced.js +85 -0
- package/scripts/ui/components/popup-menu.js +6 -5
- package/scripts/ui/components/summary-card.js +4 -3
- package/scripts/ui/components/tree-view-adv.js +4 -2
- package/scripts/ui/containers/splitters.js +12 -20
- package/scripts/ui/dialogs/wizard.js +8 -8
- package/scripts/ui/docking/docking.js +4 -1
- package/scripts/ui/handlers/markup-handlers.js +60 -0
- package/scripts/ui/inputs/advanced/all-input-types.js +47 -29
- package/scripts/ui/inputs/advanced/for-properties.js +1 -1
- package/scripts/ui/inputs/advanced/input-api.js +38 -0
- package/scripts/ui/inputs/advanced/input-events.js +10 -10
- package/scripts/ui/inputs/advanced/input-form.js +8 -8
- package/scripts/ui/inputs/choice-input.js +5 -5
- package/scripts/ui/inputs/column-combo-box.js +3 -3
- package/scripts/ui/inputs/column-inputs.js +3 -3
- package/scripts/ui/inputs/forms.js +15 -16
- package/scripts/ui/inputs/helm-input-ui.js +7 -0
- package/scripts/ui/inputs/inputs-events.js +8 -8
- package/scripts/ui/inputs/inputs-extended.js +2 -2
- package/scripts/ui/inputs/inputs.js +17 -15
- package/scripts/ui/inputs/molecule-input.js +1 -1
- package/scripts/ui/inputs/table-input.js +1 -1
- package/scripts/ui/inputs/tags-input.js +2 -2
- package/scripts/ui/inputs/typeahead-input.js +16 -17
- package/scripts/ui/inputs/validation/input-validators.js +11 -0
- package/scripts/ui/inputs/validation/parameter-expressions.js +9 -0
- package/scripts/ui/inputs/validation/parameter-validation.js +6 -0
- package/scripts/ui/interactivity/drag-and-drop.js +3 -3
- package/scripts/ui/rendering/render-items.js +9 -9
- package/scripts/ui/tooltips/tooltip-events.js +2 -1
- package/scripts/ui/tooltips/tooltips.js +11 -2
- package/scripts/ui/viewers/advanced/attached-properties.js +5 -5
- package/scripts/ui/viewers/advanced/default-axis-type.js +1 -1
- package/scripts/ui/viewers/advanced/descriptors.js +14 -0
- package/scripts/ui/viewers/advanced/init-function.js +21 -0
- package/scripts/ui/viewers/advanced/init-script.js +15 -0
- package/scripts/ui/viewers/filters/add-single-filter.js +5 -5
- package/scripts/ui/viewers/filters/custom-filters.js +7 -6
- package/scripts/ui/viewers/filters/filter-group.js +6 -1
- package/scripts/ui/viewers/filters/multi-value-filter.js +1 -1
- package/scripts/ui/viewers/js viewers/chord-viewer.js +1 -1
- package/scripts/ui/viewers/js viewers/globe-viewer.js +7 -7
- package/scripts/ui/viewers/js viewers/sankey-viewer.js +1 -1
- package/scripts/ui/viewers/js viewers/surface-plot.js +19 -1
- package/scripts/ui/viewers/js viewers/word-cloud.js +1 -1
- package/scripts/ui/viewers/scatter-plot-events.js +6 -1
- package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +3 -1
- package/scripts/ui/viewers/types/globe.js +2 -3
- package/scripts/ui/viewers/types/markup-advanced.js +2 -2
- package/scripts/ui/viewers/types/markup-eeg.js +5 -5
- package/scripts/ui/viewers/types/shape-map.js +4 -4
- package/scripts/ui/viewers/types/trellis-plot.js +13 -1
- package/scripts/ui/viewers/types/word-cloud.js +1 -1
- package/scripts/ui/viewers/viewer-tooltips.js +1 -1
- package/scripts/ui/views/default-views.js +8 -7
- package/scripts/ui/views/layouts.js +16 -17
- package/scripts/ui/views/multi-view.js +1 -1
- package/scripts/ui/widgets/widgets-tree.js +32 -0
- package/src/package-api.ts +8 -0
- package/src/package-test.ts +117 -14
- package/src/tests/owners.ts +8 -0
- package/test-console-output-1.log +6957 -0
- package/test-console-output-2.log +371 -0
- package/test-console-output-3.log +887 -0
- package/test-console-output-4.log +1085 -0
- package/test-console-output-5.log +944 -0
- package/test-console-output-6.log +2 -0
- package/test-record-1.mp4 +0 -0
- package/test-record-2.mp4 +0 -0
- package/test-record-3.mp4 +0 -0
- package/test-record-4.mp4 +0 -0
- package/test-record-5.mp4 +0 -0
- package/test-record-6.mp4 +0 -0
- package/to fix/dynamic-loading.js +13 -0
- package/tsconfig.json +1 -1
- package/webpack.config.js +4 -1
- package/files.js +0 -39
- package/scripts/misc/audit/activity-today.js +0 -4
- package/scripts/misc/user-data-storage.js +0 -49
- package/scripts/scripting/scripting.js +0 -6
- package/scripts/ui/handlers/dynamic-loading.js +0 -13
- /package/scripts/data-access/{dynamic-query.js → db/dynamic-query.js} +0 -0
- /package/scripts/grid/{cell-bounds.js → advanced/cell-bounds.js} +0 -0
- /package/scripts/grid/{category-colors.js → color-coding/category-colors.js} +0 -0
- /package/scripts/grid/{custom-cell-prepare.js → events/custom-cell-prepare.js} +0 -0
- /package/scripts/grid/{custom-cell-rendering-indexes.js → events/custom-cell-rendering-indexes.js} +0 -0
- /package/scripts/grid/{custom-cell-rendering.js → events/custom-cell-rendering.js} +0 -0
- /package/scripts/grid/{custom-cell-tooltip.js → events/custom-cell-tooltip.js} +0 -0
- /package/scripts/grid/{scroll-bars.js → navigate/scroll-bars.js} +0 -0
- /package/scripts/grid/{scroll-to-cell.js → navigate/scroll-to-cell.js} +0 -0
- /package/scripts/grid/{scroll-to-pixels.js → navigate/scroll-to-pixels.js} +0 -0
- /package/scripts/grid/{order-columns.js → order/order-columns.js} +0 -0
- /package/scripts/grid/{order-rows-by-comparer.js → order/order-rows-by-comparer.js} +0 -0
- /package/scripts/grid/{order-rows.js → order/order-rows.js} +0 -0
- /package/scripts/grid/{hide-columns.js → resize/hide-columns.js} +0 -0
- /package/scripts/grid/{resize-columns.js → resize/resize-columns.js} +0 -0
- /package/scripts/grid/{resize-events.js → resize/resize-events.js} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
//tags: DataFrame, Column, construction
|
|
2
2
|
// This is the fastest way of creating numerical columns
|
|
3
|
-
// The following example creates a table with 100 million rows and
|
|
3
|
+
// The following example creates a table with 100 million rows and three columns
|
|
4
4
|
// See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
|
|
5
5
|
|
|
6
6
|
let len = 100000000;
|
|
7
7
|
let ints = new Int32Array(len);
|
|
8
8
|
let floats = new Float32Array(len);
|
|
9
|
+
let floats64 = new Float64Array(len);
|
|
9
10
|
|
|
10
11
|
for (let i = 0; i < len; i++)
|
|
11
12
|
ints[i] = i;
|
|
@@ -13,9 +14,13 @@ for (let i = 0; i < len; i++)
|
|
|
13
14
|
for (let i = 0; i < len; i++)
|
|
14
15
|
floats[i] = i / 10;
|
|
15
16
|
|
|
17
|
+
for (let i = 0; i < len; i++)
|
|
18
|
+
floats64[i] = i + i / len;
|
|
19
|
+
|
|
16
20
|
let table = DG.DataFrame.fromColumns([
|
|
17
21
|
DG.Column.fromInt32Array('ints', ints),
|
|
18
|
-
DG.Column.fromFloat32Array('floats', floats)
|
|
22
|
+
DG.Column.fromFloat32Array('floats', floats),
|
|
23
|
+
DG.Column.fromFloat64Array('floats64', floats64)
|
|
19
24
|
]);
|
|
20
25
|
|
|
21
26
|
grok.shell.addTableView(table);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Datetime columns return [Dayjs object](https://github.com/iamkun/dayjs/) but accept multiple types:
|
|
2
|
+
|
|
3
|
+
let t = DG.DataFrame.create(10)
|
|
4
|
+
|
|
5
|
+
// Batch initialization using functions
|
|
6
|
+
t.columns.addNewDateTime('fun dayJs').init((i) => dayjs());
|
|
7
|
+
t.columns.addNewDateTime('fun Date').init((i) => Date.now());
|
|
8
|
+
t.columns.addNewDateTime('fun ms since epoch').init((i) => 42);
|
|
9
|
+
t.columns.addNewDateTime('fun string').init((i) => '2024/10/30');
|
|
10
|
+
|
|
11
|
+
// Batch initialization with the same value
|
|
12
|
+
t.columns.addNewDateTime('dayJs').init(dayjs());
|
|
13
|
+
t.columns.addNewDateTime('Date').init(Date.now());
|
|
14
|
+
t.columns.addNewDateTime('ms since epoch').init(42);
|
|
15
|
+
t.columns.addNewDateTime('string').init('2024/10/30');
|
|
16
|
+
|
|
17
|
+
// Index-based initialization
|
|
18
|
+
let dc = t.columns.addNewDateTime('new');
|
|
19
|
+
dc.set(0, dayjs());
|
|
20
|
+
dc.set(1, Date.now());
|
|
21
|
+
dc.set(2, 42);
|
|
22
|
+
dc.set(3, '2024/10/30');
|
|
23
|
+
|
|
24
|
+
grok.shell.addTableView(t);
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const nums = ['>5.13257', '6.016544', '<7.02'];
|
|
2
|
+
const t = DG.DataFrame.fromColumns([
|
|
3
3
|
DG.Column.qnum('qnum', 3).init((i) => DG.Qnum.parse(nums[i]))
|
|
4
4
|
]);
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// NUMBER FORMATS (https://datagrok.ai/help/discover/tags#numbers)
|
|
7
|
+
// The usual formats, such as "0.000" or "#.0000", are supported.
|
|
8
|
+
const columnFormats = {'qnum': '#0.000'};
|
|
9
|
+
const csv = t.toCsv({filteredRowsOnly: true, qualifierAsColumn: true, columnFormats: columnFormats});
|
|
10
|
+
const df1 = DG.DataFrame.fromCsv(csv);
|
|
11
|
+
const tv = grok.shell.addTableView(df1);
|
|
12
|
+
|
|
13
|
+
const grid = tv.grid;
|
|
14
|
+
grid.sort(['qnum'], [false]);
|
|
15
|
+
grid.col('qual(qnum)').visible = false;
|
|
16
|
+
// if grid is specified, row sorting will be applied as well
|
|
17
|
+
console.log(df1.toCsv({visibleColumnsOnly: true}, grid));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const t = grok.data.demo.demog(5);
|
|
2
2
|
console.log(t.toCsv({delimiter: ' - '}));
|
|
@@ -8,7 +8,7 @@ let df = DG.DataFrame.fromColumns([
|
|
|
8
8
|
df.onColumnsAdded
|
|
9
9
|
.subscribe((data) => {
|
|
10
10
|
data.args.columns
|
|
11
|
-
.filter((col) => col.
|
|
11
|
+
.filter((col) => col.meta.formula != null)
|
|
12
12
|
.forEach((col) => grok.shell.info(`Added ${col.name}`));
|
|
13
13
|
});
|
|
14
14
|
|
|
@@ -11,7 +11,7 @@ grok.shell.addTableView(df);
|
|
|
11
11
|
df.onColumnsRemoved
|
|
12
12
|
.subscribe((data) => {
|
|
13
13
|
data.args.columns
|
|
14
|
-
.filter((col) => col.
|
|
14
|
+
.filter((col) => col.meta.formula != null)
|
|
15
15
|
.forEach((col) => grok.shell.info(`Removed calculated column ${col.name}`));
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// Master-detail table linking feature with dynamic data loading (see also link-tables.js).
|
|
2
2
|
|
|
3
3
|
let tickers = DG.DataFrame.fromCsv(
|
|
4
|
-
`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
MSFT`);
|
|
4
|
+
`chickweight
|
|
5
|
+
fish`
|
|
6
|
+
);
|
|
8
7
|
grok.shell.addTableView(tickers);
|
|
9
8
|
|
|
10
9
|
let detailsView = null;
|
|
11
10
|
|
|
12
|
-
tickers.onCurrentRowChanged.subscribe((_) => {
|
|
13
|
-
grok.data.loadTable(
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
11
|
+
tickers.onCurrentRowChanged.subscribe(async (_) => {
|
|
12
|
+
let t = await grok.data.loadTable(
|
|
13
|
+
`https://calmcode.io/static/data/${tickers.currentRow.chickWeight}.csv`
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (detailsView === null) detailsView = grok.shell.addTableView(t);
|
|
17
|
+
else detailsView.dataFrame = t;
|
|
20
18
|
});
|
|
19
|
+
|
|
@@ -12,14 +12,18 @@
|
|
|
12
12
|
//
|
|
13
13
|
// https://datagrok.ai/help/explore/link-tables
|
|
14
14
|
|
|
15
|
-
grok.data.loadTable(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
let demog = await grok.data.loadTable("https://public.datagrok.ai/demo/demog.csv");
|
|
16
|
+
let demogTypes = await grok.data.loadTable("https://public.datagrok.ai/demo/demog-types.csv");
|
|
17
|
+
|
|
18
|
+
grok.shell.addTableView(demog);
|
|
19
|
+
grok.shell.addTableView(demogTypes);
|
|
20
|
+
grok.data.linkTables(
|
|
21
|
+
demogTypes,
|
|
22
|
+
demog,
|
|
23
|
+
["sex", "race"],
|
|
24
|
+
["sex", "race"],
|
|
25
|
+
[DG.SYNC_TYPE.CURRENT_ROW_TO_FILTER, DG.SYNC_TYPE.MOUSE_OVER_ROW_TO_SELECTION]
|
|
26
|
+
);
|
|
23
27
|
|
|
24
28
|
// Link types:
|
|
25
29
|
// From SYNC_TYPE enum:
|
|
@@ -9,11 +9,11 @@ let col = await df.columns.addNewCalculated('new', '0');
|
|
|
9
9
|
grok.shell.addTableView(df);
|
|
10
10
|
|
|
11
11
|
// Changes a column's formula programmatically. Note that setting a new value
|
|
12
|
-
// to
|
|
12
|
+
// to column.meta.formula will not trigger re-calculation of values in the column.
|
|
13
13
|
// See also:
|
|
14
14
|
// https://dev.datagrok.ai/js/samples/data-frame/modification/calculated-columns/apply-formula
|
|
15
15
|
// https://dev.datagrok.ai/js/samples/data-frame/events/calculated-columns/update
|
|
16
16
|
col = await col.applyFormula('${x}+${y}-${z}');
|
|
17
17
|
|
|
18
18
|
// Opens a dialog to edit a calculated column
|
|
19
|
-
col.dialogs.editFormula();
|
|
19
|
+
col.meta.dialogs.editFormula();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//tags: DataFrame, Column, modification
|
|
2
|
+
|
|
3
|
+
// Smallest number > 1 representable as 64 bit floating point number precisely
|
|
4
|
+
// See https://en.wikipedia.org/wiki/Double-precision_floating-point_format for more details
|
|
5
|
+
let preciseNumber = 1.0000000000000002;
|
|
6
|
+
|
|
7
|
+
let floats32 = new Float32Array(1);
|
|
8
|
+
let floats64 = new Float64Array(1);
|
|
9
|
+
floats32[0] = preciseNumber;
|
|
10
|
+
floats64[0] = preciseNumber;
|
|
11
|
+
|
|
12
|
+
let table = DG.DataFrame.fromColumns([
|
|
13
|
+
DG.Column.fromFloat32Array('compact_floats', floats32),
|
|
14
|
+
DG.Column.fromFloat64Array('precise_floats', floats64)
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
console.log(table.get('compact_floats', 0)); // 1
|
|
18
|
+
console.log(table.get('precise_floats', 0)); // 1.0000000000000002
|
|
19
|
+
|
|
20
|
+
// Bump float column to double precision
|
|
21
|
+
table.columns.byName('compact_floats').doublePrecision = true;
|
|
22
|
+
table.set('compact_floats', 0, preciseNumber);
|
|
23
|
+
|
|
24
|
+
console.log(table.get('compact_floats', 0)); // 1.0000000000000002
|
|
25
|
+
console.log(table.get('precise_floats', 0)); // 1.0000000000000002
|
|
26
|
+
|
|
@@ -25,8 +25,8 @@ demog.selection.set(5, false);
|
|
|
25
25
|
demog.selection.findNext(0, false);
|
|
26
26
|
|
|
27
27
|
// tags
|
|
28
|
-
demog.columns.byName('height').
|
|
29
|
-
demog.columns.byName('weight').
|
|
30
|
-
foo = demog.columns.byName('height').
|
|
28
|
+
demog.columns.byName('height').meta.units = 'm';
|
|
29
|
+
demog.columns.byName('weight').meta.units = 'kg';
|
|
30
|
+
foo = demog.columns.byName('height').meta.units;
|
|
31
31
|
|
|
32
32
|
grok.shell.addTableView(demog);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
let t = grok.shell.table('Med Chem') ?? grok.data.demo.molecules();
|
|
2
|
+
let rnd = (n) => Math.floor(n * Math.random());
|
|
3
|
+
let rnd1 = (n) => Math.ceil(n * Math.random());
|
|
4
|
+
let rndCat = (categories) => categories[rnd(categories.length)];
|
|
5
|
+
const addCatColumn = (columnName, categories, tags) => {
|
|
6
|
+
let c = t.col(columnName) ?? t.columns.addNewString(columnName).init((i) => rndCat(categories));
|
|
7
|
+
if (tags != null) {
|
|
8
|
+
for (let key of Object.getOwnPropertyNames(tags))
|
|
9
|
+
c.tags[key] = tags[key];
|
|
10
|
+
}
|
|
11
|
+
return c;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// HTS image
|
|
15
|
+
addCatColumn('HTS', ['https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Housebeemouth100x.jpg/120px-Housebeemouth100x.jpg', 'https://en.wikipedia.org/wiki/File:RiceStemcs400x1.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Rabbitttestis100x2.jpg/120px-Rabbitttestis100x2.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/FernProthallium400x.jpg/120px-FernProthallium400x.jpg']);
|
|
16
|
+
|
|
17
|
+
// HTS data
|
|
18
|
+
t.columns.addNew('HTS data', DG.TYPE.DATA_FRAME).init((i) => grok.data.demo.doseResponse(96));
|
|
19
|
+
|
|
20
|
+
let stages = t.columns.addNewString('Stage').init((i) => 'Stage ' + rnd1(4));
|
|
21
|
+
let species = addCatColumn('Species', ['Mouse', 'Rat']);
|
|
22
|
+
let strains = {
|
|
23
|
+
'Mouse': ['C57BL/6', 'BALB/c', 'Swiss Webster', 'DBA/2'],
|
|
24
|
+
'Rat': ['Sprague Dawley', 'Wistar', 'Long-Evans', 'Fisher 344', 'Lewis'],
|
|
25
|
+
};
|
|
26
|
+
t.columns.addNewString('Strain').init((i) => rndCat(strains[species.get(i)]));
|
|
27
|
+
|
|
28
|
+
// Chemistry
|
|
29
|
+
const chemTags = {quality: 'Molecule', 'cell.renderer': 'Molecule'};
|
|
30
|
+
addCatColumn('Core', ['n1nc([*:3])n([*:2])c1[*:1]', 'C1C2CN([*:2])CC2CN1[*:1]', 'CC1(N[*:1])CCN([*:2])C1'], chemTags);
|
|
31
|
+
addCatColumn('R1', ['N#Cc1cccc(C[*:1])c1', 'COCC(=O)[*:1]', 'CC(C)N1CCC(N2CCN([*:1])CC2)CC1', 'O=C(C1CC1)[*:1]', 'C#CCN1CCN([*:1])CC1', 'COCCOC(C)[*:1]', 'CCNC(=O)CN1CCN([*:1])CC1', 'COCCOC1CCN([*:1])C1', 'Cc1cnc(C(=O)[*:1])cn1', 'CC(=O)[*:1]'], chemTags);
|
|
32
|
+
addCatColumn('R2', ['N#CC[*:2]', 'O=C(c1ccon1)[*:2]', 'Cn1nnnc1C[*:2]', 'O=C(C[*:2])NCC(F)(F)F', 'CS(=O)(=O)CC(=O)[*:2]', 'O=C(C[*:2])NCC(F)(F)F', 'O=C(C[*:2])NCC(F)(F)F', 'c1csc(C[*:2])n1', 'c1csc(C[*:2])n1', 'c1nonc1C[*:2]', 'O=C(CCOCC(F)(F)F)[*:2]'], chemTags);
|
|
33
|
+
addCatColumn('R3', ['C1CCC([*:3])OC1', 'Brc1ccc([*:3])s1', 'O=C(Nc1ccccn1)[*:3]', 'c1ccc(C[*:3])nc1', 'c1ccc(-n2cc([*:3])cn2)cc1', 'c1ccc([*:3])cc1', 'CN(Cc1ccc(S(C)(=O)=O)cc1)[*:3]', 'c1cncc([*:3])c1', 'CON(C)[*:3]', 'Cc1ccc(SC[*:3])cc1', 'Brc1ccc([*:3])s1', 'Cc1cccc([*:3])n1', 'C1CC1C[*:3]', 'C1CC([*:3])C1', 'CC1(C)CCN([*:3])CC1', 'CN(Cc1nc2ccccc2s1)[*:3]', 'CC(O)(C1CCN([*:3])CC1)C(F)(F)F'], chemTags);
|
|
34
|
+
|
|
35
|
+
// Classifications
|
|
36
|
+
addCatColumn('BSEP classification', ['>= 60 uM', '<= 30 uM', 'Inconclusive']);
|
|
37
|
+
addCatColumn('HLM CLint classification', ['<=25 uL/min/mg', '>100 uL/min/mg', 'Inconclusive']);
|
|
38
|
+
addCatColumn('RLM CLint classification', ['<=30 uL/min/mg', '>120 uL/min/mg', 'Inconclusive']);
|
|
39
|
+
addCatColumn('LE-MDCK Classification', ['<=5 cm-6/s', '>=5 cm-6/s', 'Inconclusive']);
|
|
40
|
+
addCatColumn('PAMPA Classification', ['<=-5.3 cm/s', '>= -4.5 cm/s', 'Inconclusive']);
|
|
41
|
+
addCatColumn('pH6.8 HT Solubility Classification', ['<10 uM', '>100 uM', 'Inconclusive']);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// Random boolean columns
|
|
45
|
+
const boolNames = ['hERG alert', 'Patent pending', 'Completed'];
|
|
46
|
+
for (let name of boolNames)
|
|
47
|
+
t.columns.addNewBool(name).init((i) => rnd(3) === 1);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
const toxicityRisks = ['Mutagenicity', 'Tumorigenicity', 'Irritative effects', 'Reproductive effects'];
|
|
51
|
+
for (const risk of toxicityRisks)
|
|
52
|
+
t.columns.addNewBool(risk).init((i) => rnd(3) === 1);
|
|
53
|
+
|
|
54
|
+
// const warnings = ['Mutagenicity', 'Tumorigenicity', 'Irritative effects', 'Reproductive effects'];
|
|
55
|
+
// const warningsCol = t.columns.getOrCreate('Toxicity', 'string').init((i) => warnings.filter((i, j) => rnd(3) === 1).join(','));
|
|
56
|
+
// warningsCol.setTag(DG.TAGS.CELL_RENDERER, 'Tags');
|
|
57
|
+
|
|
58
|
+
t.columns.addNewString('Idea name').init((i) => 'GRK-' + rnd(10000));
|
|
59
|
+
addCatColumn('Idea status', ['Created', 'Approved', 'Synthesized']);
|
|
60
|
+
addCatColumn('Idea author', ['Jack Hammer', 'Paul Smith', 'Maria DePiotra', 'Marlon Voicek']);
|
|
61
|
+
let ideaCreated = t.columns.addNewDateTime('Idea created').init((_) => dayjs().year(1990 + rnd(30)).month(rnd1(12)).day(rnd1(28)).startOf('day'));
|
|
62
|
+
let ideaApproved = t.columns.addNewDateTime('Idea approved').init((i) => ideaCreated.get(i).add(rnd(100), 'day'));
|
|
63
|
+
let ideaSynthesized = t.columns.addNewDateTime('Idea synthesized').init((i) => ideaApproved.get(i).add(rnd(100), 'day'));
|
|
64
|
+
ideaCreated.tags.format = 'yyyy/MM/dd';
|
|
65
|
+
ideaApproved.tags.format = 'yyyy/MM/dd';
|
|
66
|
+
ideaSynthesized.tags.format = 'yyyy/MM/dd';
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
addCatColumn('PDB_ID', ['2PRO', '3PIS', '1OVO', '4PRO', '3PRO', '1N6E', '3B4R', '7CR9', '1BOQ', '6IHG', '7YUT', '4NJV', '1GBA', '7FIZ']);
|
|
70
|
+
if (!t.col('Affinity'))
|
|
71
|
+
t.columns.addNewFloat('Affinity').init((i) => Math.random() * -11.67 - 4.38);
|
|
72
|
+
|
|
73
|
+
if (!t.col('JIRA'))
|
|
74
|
+
t.columns.addNewString('JIRA').init((i) => Math.random() > 0.3 ? '' : 'GROK-' + rnd1(15000));
|
|
75
|
+
|
|
76
|
+
const plateFiles = ['file://System:DemoFiles/hts/plate-96-1.csv', 'file://System:DemoFiles/hts/plate-96-2.csv', 'file://System:DemoFiles/hts/plate-96-3.csv'];
|
|
77
|
+
addCatColumn('Plate file', plateFiles).tags['cell.renderer'] = 'File';
|
|
78
|
+
addCatColumn('Plate folder', ['file://System:DemoFiles/hts/']).tags['cell.renderer'] = 'File';
|
|
79
|
+
|
|
80
|
+
const groups = {
|
|
81
|
+
'Docking': { columns: ['PDB_ID', 'Pose', 'Affinity'] },
|
|
82
|
+
'Absorption': { color: '#0b74e1', columns: ['Caco2', 'Lipophilicity', 'Solubility'] },
|
|
83
|
+
'Distribution': { color: '#9d05c5', columns: ['PPBR', 'VDss']},
|
|
84
|
+
'Metabolism': { color: '#03a14f', columns: ['CYP1A2-Inhibitor', 'CYP2C19-Inhibitor', 'CYP2C9-Inhibitor', 'CYP2C9-Substrate', 'CYP2D6-Inhibitor', 'CYP2D6-Substrate']},
|
|
85
|
+
'Excretion': { color: '#b47b4a', columns: ['CL-Hepa', 'CL-Micro', 'Half-Life']},
|
|
86
|
+
'Toxicity': { color: '#ba0f0f', columns: ['hERG', 'LD50', 'Toxicity']},
|
|
87
|
+
'Chemspace': { columns: ['Chemspace id', 'Vendor', 'Pack, mg', 'Price, USD', 'Lead time, days']},
|
|
88
|
+
'DRC': { columns: ['DRC', 'DRC R2', 'DRC AUC', 'Plate', 'Plate file', 'Plate folder'] },
|
|
89
|
+
'R-Groups': { columns: ['Core', 'R1', 'R2', 'R3'] },
|
|
90
|
+
'Classifications': {columns: ['BSEP classification', 'HLM CLint classification', 'RLM CLint classification', 'LE-MDCK Classification', 'PAMPA Classification', 'pH6.8 HT Solubility Classification'] },
|
|
91
|
+
'Ideation': { columns: ['Idea status', 'Idea author', 'Idea created', 'Idea approved', 'Idea synthesized']},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// settings virtual columns
|
|
95
|
+
const tv = grok.shell.getTableView('Med Chem');
|
|
96
|
+
if (tv) {
|
|
97
|
+
tv.grid.columns.add({gridColumnName: 'Toxicity risks', cellType: 'Tags'}).settings = { columns: toxicityRisks };
|
|
98
|
+
tv.grid.columns.add({gridColumnName: 'plate', cellType: 'Plate'})
|
|
99
|
+
.onPrepareValueScript = 'return grok.data.demo.wells(96); ';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
t.meta.detectSemanticTypes();
|
|
103
|
+
t.meta.setGroups(groups);
|
|
@@ -123,11 +123,6 @@ async function testCase(title, f) {
|
|
|
123
123
|
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
await testCase(`Substructure search (server), searching benzene in ${nSearch} molecules`, async () =>
|
|
127
|
-
await grok.chem.searchSubstructureServer(col, searchFor[0]), false);
|
|
128
|
-
await testCase(`Substructure search (server), searching aspirin in ${nSearch} molecules`, async () =>
|
|
129
|
-
await grok.chem.searchSubstructureServer(col, searchFor[1]), false);
|
|
130
|
-
|
|
131
126
|
/*
|
|
132
127
|
await testCase(`Similarity scoring (server), search for ${
|
|
133
128
|
queryIdx.length} samples in ${nSearch} molecules`, async () => {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// An example of using diversity search.
|
|
2
2
|
// https://datagrok.ai/help/domains/chem/descriptors
|
|
3
3
|
|
|
4
|
-
grok.chem.descriptors(grok.data.testData('molecules', 100), 'smiles', ['MolWt', 'Lipinski'])
|
|
5
|
-
|
|
6
|
-
grok.shell.addTableView(table);
|
|
7
|
-
});
|
|
4
|
+
let table = await grok.chem.descriptors(grok.data.testData('molecules', 100), 'smiles', ['MolWt', 'Lipinski']);
|
|
5
|
+
grok.shell.addTableView(table);
|
|
8
6
|
|
|
9
7
|
// In 'descriptors' parameter groups or descriptors can be specified.
|
|
10
8
|
//
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// An example of using diversity search.
|
|
2
2
|
// https://datagrok.ai/help/domains/chem/diversity-search
|
|
3
3
|
|
|
4
|
-
grok.chem.diversitySearch(grok.data.testData('molecules', 100).col('smiles'))
|
|
5
|
-
|
|
6
|
-
grok.shell.addTableView(mols);
|
|
7
|
-
});
|
|
4
|
+
let mols = await grok.chem.diversitySearch(grok.data.testData('molecules', 100).col('smiles'));
|
|
5
|
+
grok.shell.addTableView(mols);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// An example of getting Maximum Common Substructure (MCS).
|
|
2
2
|
|
|
3
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
let t = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
|
|
4
|
+
let mcs = await grok.chem.mcs(t, 'smiles');
|
|
5
|
+
grok.shell.info(mcs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// An example of getting R-Groups
|
|
2
2
|
// https://datagrok.ai/help/domains/chem/r-group-analysis
|
|
3
3
|
|
|
4
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let table = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
|
|
5
|
+
let groupedTable = await grok.chem.rGroup(table, 'smiles', 'O=C1Nc2ccccc2C(C2CCCCC2)=NC1');
|
|
6
|
+
grok.shell.addTableView(groupedTable);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
)
|
|
5
|
-
);
|
|
1
|
+
let molecules =await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
|
|
2
|
+
let similar = await grok.chem.getSimilarities(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
|
|
3
|
+
grok.shell.addTableView(DG.DataFrame.fromColumns([similar]));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
)
|
|
5
|
-
);
|
|
1
|
+
let molecules = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
|
|
2
|
+
let similar = await grok.chem.findSimilar(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
|
|
3
|
+
grok.shell.addTableView(similar);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// An example of using substructure search with SMARTS pattern,
|
|
2
2
|
// encoded through an ALS parameter block of a MolFile
|
|
3
3
|
|
|
4
|
-
grok.data.getDemoTable(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
let t = await grok.data.getDemoTable("chem/smiles.csv");
|
|
5
|
+
let bs = await grok.chem.searchSubstructure(
|
|
6
|
+
t.col("canonical_smiles"),
|
|
7
|
+
`
|
|
8
|
+
MJ201900\n
|
|
9
9
|
6 6 1 0 0 0 0 0 0 0999 V2000
|
|
10
10
|
-1.9420 0.9589 0.0000 L 0 0 0 0 0 0 0 0 0 0 0 0
|
|
11
11
|
-2.6564 0.5464 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
@@ -20,11 +20,10 @@ grok.data.getDemoTable('chem/smiles.csv')
|
|
|
20
20
|
1 2 2 0 0 0 0
|
|
21
21
|
6 1 1 0 0 0 0
|
|
22
22
|
1 T 2 6 7
|
|
23
|
-
M ALS 1 2 T C N
|
|
23
|
+
M ALS 1 2 T C N \n
|
|
24
24
|
M END
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}));
|
|
25
|
+
`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
t.filter.copyFrom(bs);
|
|
29
|
+
grok.shell.addTableView(t);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// An example of using substructure search with SMARTS pattern
|
|
2
2
|
|
|
3
|
-
grok.data.getDemoTable('chem/smiles.csv')
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
t.filter.copyFrom(bs);
|
|
8
|
-
grok.shell.addTableView(t);
|
|
9
|
-
}));
|
|
3
|
+
let t = await grok.data.getDemoTable('chem/smiles.csv');
|
|
4
|
+
let bs = await grok.chem.searchSubstructure(t.col('canonical_smiles'), '[!#6&!#7]1:[#6]:[#6]:[#6]:[#6]:[#6]:1')
|
|
5
|
+
t.filter.copyFrom(bs);
|
|
6
|
+
grok.shell.addTableView(t);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// An example of using substructure search
|
|
2
2
|
|
|
3
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}));
|
|
3
|
+
let t = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
|
|
4
|
+
let bs = await grok.chem.searchSubstructure(t.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1');
|
|
5
|
+
|
|
6
|
+
t.filter.copyFrom(bs);
|
|
7
|
+
grok.shell.addTableView(t);
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
//
|
|
3
3
|
// https://datagrok.ai/help/explore/cluster-data
|
|
4
4
|
|
|
5
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/xclara.csv')
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
}));
|
|
5
|
+
let table = await grok.data.loadTable('https://public.datagrok.ai/demo/xclara.csv');
|
|
6
|
+
let clusteredTable = await grok.ml.cluster(table, ["V1", "V2"], 3)
|
|
7
|
+
let view = grok.shell.addTableView(clusteredTable);
|
|
8
|
+
view.scatterPlot({
|
|
9
|
+
x: 'V1',
|
|
10
|
+
y: 'V2',
|
|
11
|
+
color: 'clusters',
|
|
12
|
+
});
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
//
|
|
3
3
|
// https://datagrok.ai/help/transform/missing-values-imputation
|
|
4
4
|
|
|
5
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv')
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let t1 = await grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv');
|
|
6
|
+
let t2 = await grok.ml.missingValuesImputation(t1, ['age', 'height', 'weight'], ['age', 'height', 'weight'], 5);
|
|
7
|
+
grok.shell.addTableView(t2);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
//
|
|
3
3
|
// https://datagrok.ai/help/explore/pca
|
|
4
4
|
|
|
5
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/cars.csv')
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let t1 = await grok.data.loadTable('https://public.datagrok.ai/demo/cars.csv');
|
|
6
|
+
let t2 = await grok.ml.pca(t1, ["wheel.base", "length", "width", "height", "city.mpg", "price"], 2, true, true);
|
|
7
|
+
grok.shell.addTableView(t2);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// An example of using predictive models.
|
|
2
|
-
// https://datagrok.ai/help/learn/
|
|
2
|
+
// https://datagrok.ai/help/learn/
|
|
3
3
|
|
|
4
|
-
grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv')
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
let t1 = await grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv');
|
|
5
|
+
let t2 = await grok.ml.applyModel('Samples:Models:PredictSexByBasicDemographics', t1);
|
|
6
|
+
grok.shell.addTableView(t2);
|
|
@@ -10,9 +10,8 @@ async function generate() {
|
|
|
10
10
|
await grok.ml.randomData(t, 'binomial', {size: 100, prob: 0.7}, 77);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
generate()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
13
|
+
await generate();
|
|
14
|
+
let view = grok.shell.addTableView(t);
|
|
15
|
+
view.histogram({value: 'normal'});
|
|
16
|
+
view.histogram({value: 'uniform'});
|
|
17
|
+
view.histogram({value: 'binomial'});
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
const df = await grok.data.getDemoTable('chem/smiles.csv');
|
|
4
4
|
const view = grok.shell.addTableView(df);
|
|
5
5
|
|
|
6
|
-
grok.events.onFormCreating.subscribe((data) => {
|
|
7
|
-
data.columns = data.
|
|
6
|
+
grok.events.onFormCreating.subscribe((data) => {
|
|
7
|
+
data.columns = data.filter((col) => col.semType === DG.SEMTYPE.MOLECULE);
|
|
8
8
|
});
|
|
@@ -6,7 +6,7 @@ grok.functions.onAfterRunAction.subscribe((_) => grok.shell.info('Runs after a c
|
|
|
6
6
|
// Filtering events to specific function calls
|
|
7
7
|
grok.functions
|
|
8
8
|
.onAfterRunAction
|
|
9
|
-
.pipe(rxjs.operators.filter((call) => call.func.name
|
|
9
|
+
.pipe(rxjs.operators.filter((call) => call.func.name === 'Max'))
|
|
10
10
|
.subscribe((call) => grok.shell.info(`Max of ${Array.from(call.inputs.values())}: ${call.getOutputParamValue()}`));
|
|
11
11
|
|
|
12
12
|
let x = await DG.Func.byName('Abs').apply({ x: -5 });
|