@datagrok/compute 1.15.1 → 1.17.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/CHANGELOG.md +28 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +5 -5
- package/scripts/default-get-real-data.js +1 -1
- package/scripts/lorenz-attractor.js +0 -1
- package/scripts/lotka-volterra.js +1 -2
- package/scripts/maximal-volume.R +0 -1
- package/scripts/{demo-rfv-simple.js → object-cooling.js} +5 -5
- package/src/css/model-card.css +1 -1
- package/src/model-handler.ts +104 -8
- package/src/package.ts +79 -0
- package/files/cars.csv +0 -6
- package/scripts/cars.js +0 -16
- package/scripts/pkpd.R +0 -71
- package/scripts/pop-pk.R +0 -85
- package/scripts/trig.js +0 -15
- package/scripts/vmax.js +0 -179
- package/scripts/wrapper.js +0 -8
package/scripts/vmax.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
//name: Vmax
|
|
2
|
-
//description: Predict the minimum filter size required for the separation of effluent from bioreactors, given the constraints of batch size and total batch time based on a training dataset of time vs filtrate volume for a given filter type, filter area and pressure
|
|
3
|
-
//language: javascript
|
|
4
|
-
//tags: filtration, scale-up, model
|
|
5
|
-
//meta.status: Upstream
|
|
6
|
-
//input: dataframe inputTable {caption: Input table; viewer: OutliersSelectionViewer(block: 25) | Scatter Plot(y: "t/V (hr/(L/m²))", block: 75, filter: "!${isOutlier}", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, showRegressionLine: "true", markers: "isOutlier", lassoTool: "true", legendVisibility: "Never", filterByZoom: "false")}
|
|
7
|
-
//input: dataframe reportingParameters {caption: Reporting parameters; viewer: Grid()}
|
|
8
|
-
//input: double testFilterArea = 3.5 {caption: Test filter area; units: cm²} [Test filter area]
|
|
9
|
-
//input: double desiredVolumeOfBatch = 25 {caption: Desired batch volume; units: L} [Desired batch volume]
|
|
10
|
-
//input: double desiredProcessTime = 0.5 {caption: Desired process time; units: hr} [Desired process time]
|
|
11
|
-
//input: double sf = 1.5 {caption: Safety factor} [Safety factor]
|
|
12
|
-
//help-url: https://github.com/datagrok-ai/public/blob/master/packages/Compute/src/help.md
|
|
13
|
-
//output: dataframe filtrationKinetics {caption: Filtration kinetics; viewer: Scatter Plot(block: 75, filter: "!${isOutlier}", markers: "isOutlier", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, showRegressionLine: "true", legendVisibility: "Never"); category: OUTPUT}
|
|
14
|
-
//output: dataframe trialData {caption: Trial data; viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); category: OUTPUT}
|
|
15
|
-
//output: dataframe fluxDecayDf {caption: Flux decay experimental results; viewer: Scatter Plot(description: "Absolute flux decay", y: "Flux", block: 50, filter: "!${isOutlier}", markers: "isOutlier", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, legendVisibility: "Never") | Scatter Plot(description: "Relative flux decay", y: "Rel Flux", block: 50, filter: "!${isOutlier}", markers: "isOutlier", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, legendVisibility: "Never"); category: OUTPUT}
|
|
16
|
-
//output: dataframe experimentalResultsSummary {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Experimental results summary; category: OUTPUT}
|
|
17
|
-
//output: dataframe recommendations {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Recommendations; category: OUTPUT}
|
|
18
|
-
//output: dataframe sampleCharacteristics {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Sample characteristics; category: OUTPUT}
|
|
19
|
-
//output: dataframe filter {viewer: Grid(block: 25, showColumnLabels: false, showRowHeader: false); caption: Filter; category: OUTPUT}
|
|
20
|
-
//editor: Compute:ComputationView
|
|
21
|
-
//meta.runOnOpen: true
|
|
22
|
-
//meta.runOnInput: true
|
|
23
|
-
|
|
24
|
-
const COL_NAMES = {
|
|
25
|
-
INPUT_TIME_IN_MINUTES: "time (min)",
|
|
26
|
-
INPUT_VOLUME_IN_MILLILITERS: "filtrate volume (mL)",
|
|
27
|
-
INPUT_IS_OUTLIER: "isOutlier",
|
|
28
|
-
TIME_IN_HOURS: "Time [hr]",
|
|
29
|
-
TRIAL_THROUGHPUT: "Throughput [L/m²]",
|
|
30
|
-
T_V: "Time/volume/area [hr/L/m²]",
|
|
31
|
-
FLOW_RATE: "Flow rate",
|
|
32
|
-
FLUX: "Flux",
|
|
33
|
-
RELATIVE_FLUX: "Rel Flux"
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const PARAM_NAMES = {
|
|
37
|
-
FILTER_FAMILY: "Filter family",
|
|
38
|
-
FILTER_NAME: "Filter name",
|
|
39
|
-
PORE_RATING: "Pore rating (μm)",
|
|
40
|
-
EFFECTIVE_MEMBR_AREA: "Effective membr. area (cm^2)",
|
|
41
|
-
MEMBR_MATERIAL: "Membr material",
|
|
42
|
-
CATALOG_NR: "Catalog nr",
|
|
43
|
-
DATE: "Date",
|
|
44
|
-
PRIOR_STEP: "Prior step",
|
|
45
|
-
PROT_CONC: "Prot conc. (mg/mL)",
|
|
46
|
-
DENSITY: "Density (g/L)",
|
|
47
|
-
TURBIDITY: "Turbidity (NTU)",
|
|
48
|
-
INSTALLED_DEVICE: "Installed device",
|
|
49
|
-
PROJECT_NAME: "Project name", // PARAMETERS BELOW ARE NOT USED
|
|
50
|
-
FILTRATION_STAGE: "Filtration stage",
|
|
51
|
-
ELN_REFERENCE: "ELN reference",
|
|
52
|
-
BIOREACTOR_ID: "Bioreactor ID",
|
|
53
|
-
BIOREACTOR_PCV: "Bioreactor PCV (%)",
|
|
54
|
-
BIOREACTOR_TURBIDITY: "Bioreactor turbidity (NTU)",
|
|
55
|
-
FILTER_FEED_TURBIDITY: "Filter feed turbidity (NTU)",
|
|
56
|
-
FILTER_FEED_PCV: "Filter feed PCV (%)",
|
|
57
|
-
FILTER_FEED_PH: "Filter feed pH",
|
|
58
|
-
FILTER_FEED_LDH: "Filter feed LDH (U/L)",
|
|
59
|
-
FILTER_FEED_CONDUCTIVITY: "Filter feed conductivity (mS/cm)"
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function linearRegression(x, y) {
|
|
63
|
-
let sum_x = 0, sum_y = 0, sum_xy = 0, sum_xx = 0;
|
|
64
|
-
for (let i = 0; i < y.length; i++) {
|
|
65
|
-
sum_x += x[i];
|
|
66
|
-
sum_y += y[i];
|
|
67
|
-
sum_xy += x[i] * y[i];
|
|
68
|
-
sum_xx += x[i] * x[i];
|
|
69
|
-
}
|
|
70
|
-
const slope = (y.length * sum_xy - sum_x * sum_y) / (y.length * sum_xx - sum_x * sum_x);
|
|
71
|
-
const intercept = (sum_y - slope * sum_x) / y.length;
|
|
72
|
-
return { slope: slope, intercept: intercept };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const timeInMinutes = inputTable.col(COL_NAMES.INPUT_TIME_IN_MINUTES);
|
|
76
|
-
const volumeInMilliliters = inputTable.col(COL_NAMES.INPUT_VOLUME_IN_MILLILITERS);
|
|
77
|
-
const isOutlier = inputTable.col(COL_NAMES.INPUT_IS_OUTLIER);
|
|
78
|
-
|
|
79
|
-
let df = DG.DataFrame.fromColumns([timeInMinutes, volumeInMilliliters, isOutlier]);
|
|
80
|
-
|
|
81
|
-
df.columns.addNewFloat(COL_NAMES.TIME_IN_HOURS).init((i) => timeInMinutes.get(i) / 60);
|
|
82
|
-
const timeInHours = df.col(COL_NAMES.TIME_IN_HOURS);
|
|
83
|
-
|
|
84
|
-
df.columns.addNewFloat(COL_NAMES.TRIAL_THROUGHPUT).init((i) => 10 * volumeInMilliliters.get(i) / testFilterArea);
|
|
85
|
-
const trialThroughputCol = df.col(COL_NAMES.TRIAL_THROUGHPUT);
|
|
86
|
-
|
|
87
|
-
df.columns.addNewFloat(COL_NAMES.T_V).init((i) => timeInHours.get(i) / trialThroughputCol.get(i));
|
|
88
|
-
const tv = df.col(COL_NAMES.T_V);
|
|
89
|
-
|
|
90
|
-
df.columns.addNewFloat(COL_NAMES.FLOW_RATE).init((i) => (i > 0) ?
|
|
91
|
-
0.06 * (volumeInMilliliters.get(i) - volumeInMilliliters.get(i - 1)) / (timeInMinutes.get(i) - timeInMinutes.get(i - 1)) : 0
|
|
92
|
-
);
|
|
93
|
-
const flowRate = df.col(COL_NAMES.FLOW_RATE);
|
|
94
|
-
|
|
95
|
-
df.columns.addNewFloat(COL_NAMES.FLUX).init((i) => 10000 * flowRate.get(i) / testFilterArea);
|
|
96
|
-
const flux = df.col(COL_NAMES.FLUX);
|
|
97
|
-
|
|
98
|
-
df.columns.addNewFloat(COL_NAMES.RELATIVE_FLUX).init((i) => flux.get(i) / flux.get(1));
|
|
99
|
-
const relativeFlux = df.col(COL_NAMES.RELATIVE_FLUX);
|
|
100
|
-
|
|
101
|
-
fluxDecayDf = DG.DataFrame.fromColumns([
|
|
102
|
-
DG.Column.fromFloat32Array(COL_NAMES.TRIAL_THROUGHPUT, df.col(COL_NAMES.TRIAL_THROUGHPUT).toList().slice(1)),
|
|
103
|
-
DG.Column.fromFloat32Array(COL_NAMES.FLUX, df.col(COL_NAMES.FLUX).toList().slice(1)),
|
|
104
|
-
DG.Column.fromFloat32Array(COL_NAMES.RELATIVE_FLUX, df.col(COL_NAMES.RELATIVE_FLUX).toList().slice(1)),
|
|
105
|
-
DG.Column.fromList(DG.COLUMN_TYPE.BOOL, isOutlier.name, isOutlier.toList().slice(1))
|
|
106
|
-
]);
|
|
107
|
-
|
|
108
|
-
filtrationKinetics = DG.DataFrame.fromColumns([
|
|
109
|
-
timeInHours,
|
|
110
|
-
df.col(COL_NAMES.T_V),
|
|
111
|
-
volumeInMilliliters,
|
|
112
|
-
isOutlier
|
|
113
|
-
]);
|
|
114
|
-
|
|
115
|
-
df.col(COL_NAMES.INPUT_IS_OUTLIER).markers.assign('true', DG.MARKER_TYPE.OUTLIER);
|
|
116
|
-
filtrationKinetics.col(COL_NAMES.INPUT_IS_OUTLIER).markers.assign('true', DG.MARKER_TYPE.OUTLIER);
|
|
117
|
-
|
|
118
|
-
for (let i = df.rowCount - 1; i > -1; i--)
|
|
119
|
-
if (isOutlier.get(i))
|
|
120
|
-
df.rows.removeAt(i, 1, false);
|
|
121
|
-
|
|
122
|
-
const coefficients = linearRegression(df.col(COL_NAMES.TIME_IN_HOURS).toList(), df.col(COL_NAMES.T_V).toList());
|
|
123
|
-
const vmax = 1 / coefficients.slope;
|
|
124
|
-
const j0 = 1 / coefficients.intercept;
|
|
125
|
-
const flux0 = flux.get(1);
|
|
126
|
-
const amin = desiredVolumeOfBatch / vmax + desiredVolumeOfBatch / desiredProcessTime / j0;
|
|
127
|
-
const installedArea = sf * amin;
|
|
128
|
-
const processLoading = desiredVolumeOfBatch / installedArea;
|
|
129
|
-
const trialThroughput = df.col(COL_NAMES.TRIAL_THROUGHPUT).get(df.rowCount - 1);
|
|
130
|
-
const fluxDecay = (1 - df.col(COL_NAMES.RELATIVE_FLUX).get(df.rowCount - 1)) * 100;
|
|
131
|
-
const initialFlowRate = flowRate.get(1);
|
|
132
|
-
const meanFlux = flux.stats.avg * df.rowCount / (df.rowCount - 1); // exclude zero from calculation
|
|
133
|
-
|
|
134
|
-
const names = reportingParameters.col('Parameter name').toList();
|
|
135
|
-
const values = reportingParameters.col('Parameter value').toList();
|
|
136
|
-
|
|
137
|
-
experimentalResultsSummary = DG.DataFrame.fromObjects([
|
|
138
|
-
{ Name: 'Run', Value: '1' },
|
|
139
|
-
{ Name: 'Filter', Value: values[names.indexOf(PARAM_NAMES.FILTER_FAMILY)] },
|
|
140
|
-
{ Name: 'Trial Throughput [L/m²]', Value: Math.round(1000 * trialThroughput) / 1000 },
|
|
141
|
-
{ Name: 'Flux0 [LMH]', Value: Math.round(1000 * flux0) / 1000 },
|
|
142
|
-
{ Name: 'Mean Flux [LMH]', Value: Math.round(1000 * meanFlux) / 1000 },
|
|
143
|
-
{ Name: 'Vmax [L/m²]', Value: Math.round(1000 * vmax) / 1000 },
|
|
144
|
-
{ Name: 'Flux Decay [%]', Value: Math.round(1000 * fluxDecay) / 1000 }
|
|
145
|
-
]);
|
|
146
|
-
|
|
147
|
-
recommendations = DG.DataFrame.fromObjects([
|
|
148
|
-
{ Name: 'Volume [L]', Value: desiredVolumeOfBatch },
|
|
149
|
-
{ Name: 'Time [h]', Value: desiredProcessTime },
|
|
150
|
-
{ Name: 'Amin [m²]', Value: Math.round(1000 * amin) / 1000 },
|
|
151
|
-
{ Name: 'Safety Factor', Value: sf },
|
|
152
|
-
{ Name: 'Installed Area', Value: Math.round(1000 * installedArea) / 1000 },
|
|
153
|
-
{ Name: 'Process Loading [L/m²]', Value: Math.round(1000 * processLoading) / 1000 },
|
|
154
|
-
{ Name: PARAM_NAMES.FILTER_FAMILY, Value: values[names.indexOf(PARAM_NAMES.FILTER_FAMILY)] },
|
|
155
|
-
{ Name: PARAM_NAMES.INSTALLED_DEVICE, Value: values[names.indexOf(PARAM_NAMES.INSTALLED_DEVICE)] }
|
|
156
|
-
]);
|
|
157
|
-
|
|
158
|
-
trialData = DG.DataFrame.fromObjects([
|
|
159
|
-
{ Name: 'Test Filter Area [cm²]', Value: testFilterArea },
|
|
160
|
-
{ Name: 'Initial Flow Rate [L/h]', Value: Math.round(1000 * initialFlowRate) / 1000 },
|
|
161
|
-
{ Name: 'Vmax [L/m²]', Value: Math.round(1000 * vmax) / 1000 }
|
|
162
|
-
]);
|
|
163
|
-
|
|
164
|
-
filter = DG.DataFrame.fromObjects([
|
|
165
|
-
{ Name: PARAM_NAMES.FILTER_FAMILY, Value: values[names.indexOf(PARAM_NAMES.FILTER_FAMILY)] },
|
|
166
|
-
{ Name: PARAM_NAMES.FILTER_NAME, Value: values[names.indexOf(PARAM_NAMES.FILTER_NAME)] },
|
|
167
|
-
{ Name: PARAM_NAMES.PORE_RATING, Value: values[names.indexOf(PARAM_NAMES.PORE_RATING)] },
|
|
168
|
-
{ Name: PARAM_NAMES.EFFECTIVE_MEMBR_AREA, Value: values[names.indexOf(PARAM_NAMES.EFFECTIVE_MEMBR_AREA)] },
|
|
169
|
-
{ Name: PARAM_NAMES.MEMBR_MATERIAL, Value: values[names.indexOf(PARAM_NAMES.MEMBR_MATERIAL)] },
|
|
170
|
-
{ Name: PARAM_NAMES.CATALOG_NR, Value: values[names.indexOf(PARAM_NAMES.CATALOG_NR)] }
|
|
171
|
-
]);
|
|
172
|
-
|
|
173
|
-
sampleCharacteristics = DG.DataFrame.fromObjects([
|
|
174
|
-
{ Name: PARAM_NAMES.DATE, Value: values[names.indexOf(PARAM_NAMES.DATE)].slice(0, 10) },
|
|
175
|
-
{ Name: PARAM_NAMES.PRIOR_STEP, Value: values[names.indexOf(PARAM_NAMES.PRIOR_STEP)] },
|
|
176
|
-
{ Name: PARAM_NAMES.PROT_CONC, Value: values[names.indexOf(PARAM_NAMES.PROT_CONC)] },
|
|
177
|
-
{ Name: PARAM_NAMES.DENSITY, Value: values[names.indexOf(PARAM_NAMES.DENSITY)].slice(0, 5) },
|
|
178
|
-
{ Name: PARAM_NAMES.TURBIDITY, Value: values[names.indexOf(PARAM_NAMES.TURBIDITY)] }
|
|
179
|
-
]);
|