Skip to content

Commit

Permalink
chore: UI Tweaks (#20)
Browse files Browse the repository at this point in the history
* Units in parameter view
* Units in form
* Metabolite time series for Petri Dish fix
  • Loading branch information
cbolles authored Nov 26, 2024
1 parent 69ad4a9 commit c7e011e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export const GlobalParamsView: React.FC<GlobalParamsViewProps> = ({ params }) =>
<CardHeader title="Global Parameters" titleTypographyProps={{ variant: 'h3' }} />
<CardContent>
<List>
<ListItem>Time Step: {params.timeStep}</ListItem>
<ListItem>Time Step: {params.timeStep} (h/cycle)</ListItem>
<ListItem>Log Frequency: {params.logFreq}</ListItem>
<ListItem>Nutrient Diffusivity: {params.defaultDiffConst} cm2/s</ListItem>
<ListItem>Default VMax: {params.defaultVMax}</ListItem>
<ListItem>Default KM: {params.defaultKm}</ListItem>
<ListItem>Nutrient Diffusivity: {params.defaultDiffConst} (cm^2/s)</ListItem>
<ListItem>Default VMax: {params.defaultVMax} (mmol/gh)</ListItem>
<ListItem>Default KM: {params.defaultKm} (M)</ListItem>
<ListItem>Max Cycles: {params.maxCycles}</ListItem>
</List>
</CardContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const MetaboliteParamsView: React.FC<MetaboliteParamsViewProps> = ({ para
<CardContent>
<List>
<ListItem>Type: {getMetaboliteName(params.type)}</ListItem>
<ListItem>Amount: {params.concentration} mmol/cm3</ListItem>
<ListItem>Amount: {params.concentration} (M)</ListItem>
</List>
</CardContent>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const SingleModelParamsView: React.FC<{ params: ModelParametersInput }> = ({ par
<ListItem>Neutral Drift: {params.neutralDrift ? 'True' : 'False'}</ListItem>
<ListItem>Neutral Drift Amp: {params.neutralDriftAmp}</ListItem>
<ListItem>Death Rate: {params.deathRate}</ListItem>
<ListItem>Linear Diffusivity: {params.linearDiffusivity}</ListItem>
<ListItem>Nonlinear Diffusivity: {params.nonlinearDiffusivity}</ListItem>
<ListItem>Linear Diffusivity: {params.linearDiffusivity} (cm^2/s)</ListItem>
<ListItem>Nonlinear Diffusivity: {params.nonlinearDiffusivity} (cm^2/sg)</ListItem>
</List>
</Paper>
);
Expand Down
83 changes: 47 additions & 36 deletions packages/frontend/src/pages/ExperimentForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JsonForms } from '@jsonforms/react';
import { materialRenderers, materialCells } from '@jsonforms/material-renderers';
import { JsonSchema } from '@jsonforms/core';
import { JsonSchema7 } from '@jsonforms/core';
import { Box, Stack, Button } from '@mui/material';
import { ErrorObject } from 'ajv';
import { useState } from 'react';
Expand Down Expand Up @@ -29,7 +29,40 @@ const getSchema = (metaboliteType: MetaboliteType | null) => {
];
}

const schema: JsonSchema = {
const metaboliteParams: JsonSchema7 = {
type: 'object',
title: 'Metabolite Parameters',
properties: {
type: {
type: 'string',
oneOf: [
{
const: MetaboliteType.Glucose,
title: getMetaboliteName(MetaboliteType.Glucose)
},
{
const: MetaboliteType.Acetate,
title: getMetaboliteName(MetaboliteType.Acetate)
},
{
const: MetaboliteType.Rich,
title: getMetaboliteName(MetaboliteType.Rich)
}
]
}
},
required: ['type']
};

if (metaboliteType != MetaboliteType.Rich) {
metaboliteParams!.properties!['concentration'] = {
type: 'number',
title: 'Concentration (M)'
};
metaboliteParams.required!.push('concentration');
}

const schema: JsonSchema7 = {
type: 'object',
properties: {
layoutParams: {
Expand Down Expand Up @@ -60,34 +93,7 @@ const getSchema = (metaboliteType: MetaboliteType | null) => {
},
required: ['type', 'volume']
},
metaboliteParams: {
type: 'object',
title: 'Metabolite Parameters',
properties: {
type: {
type: 'string',
oneOf: [
{
const: MetaboliteType.Glucose,
title: getMetaboliteName(MetaboliteType.Glucose)
},
{
const: MetaboliteType.Acetate,
title: getMetaboliteName(MetaboliteType.Acetate)
},
{
const: MetaboliteType.Rich,
title: getMetaboliteName(MetaboliteType.Rich)
}
]
},
concentration: {
type: 'number',
title: 'Concentration (mmol/cm3)'
}
},
required: ['type', 'concentration']
},
metaboliteParams: metaboliteParams,
modelParams: {
type: 'array',
title: 'Model Parameters',
Expand All @@ -111,11 +117,13 @@ const getSchema = (metaboliteType: MetaboliteType | null) => {
},
linearDiffusivity: {
type: 'number',
default: 0.001
default: 0.001,
title: 'Linear Diffusivity (cm^2/s)'
},
nonlinearDiffusivity: {
type: 'number',
default: 0.6
default: 0.6,
title: 'Nonlinear Diffusivity (cm^2/sg)'
}
},
required: ['name', 'neutralDriftAmp', 'deathRate', 'linearDiffusivity', 'nonlinearDiffusivity']
Expand All @@ -127,7 +135,8 @@ const getSchema = (metaboliteType: MetaboliteType | null) => {
properties: {
timeStep: {
type: 'number',
default: 0.1
default: 0.1,
title: 'Timestep (Hours/Cycle)'
},
logFreq: {
type: 'number',
Expand All @@ -136,15 +145,17 @@ const getSchema = (metaboliteType: MetaboliteType | null) => {
defaultDiffConst: {
type: 'number',
default: 0.000006,
title: 'Nutrient Diffusivity (cm2/s)'
title: 'Nutrient Diffusivity (cm^2/s)'
},
defaultVMax: {
type: 'number',
default: 10
default: 10,
title: 'Default VMax (mmol/gh)'
},
defaultKm: {
type: 'number',
default: 0.00001
default: 0.00001,
title: 'Default KM (M)'
},
maxCycles: {
type: 'number',
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/pages/SummaryReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const InformationSection: React.FC<InformationSectionProps> = ({ data }) => {
for (const model of data['modelParams']) {
model['neutralDrift'] = !!model['neutralDrift'];
}

// If the concentration value is not present, provide a default
if (!data.metaboliteParams.concentration) {
data.metaboliteParams.concentration = 0.0;
}

requestSimulation({
variables: {
request: {
Expand Down
19 changes: 9 additions & 10 deletions packages/runner/runner/savers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def upload_file(self, config: SaveConfig, key: str, filename: Path) -> None:

@abstractmethod
def save(self, experiment: c.comets, config: SaveConfig) -> dict:
"""
'''
Handles saving a component of the comets experiment
"""
'''

class BiomassSaver(Saver):
def save(self, experiment: c.comets, config: SaveConfig) -> dict:
Expand Down Expand Up @@ -219,17 +219,16 @@ def save(self, experiment: c.comets, config: SaveConfig) -> dict:
output_path = config.output_folder / filename
bucket_location = f'{config.s3_folder}/{filename}'

media = experiment.media.copy()
media['time'] = media['cycle'] * experiment.parameters.get_param('timeStep')
media = media[media.conc_mmol<900]
# Get the time series media data and convert time to hours
media = experiment.get_metabolite_time_series(upper_threshold=900)
media['cycle'] = media['cycle'] * experiment.parameters.get_param('timeStep')

# Plot the media time series
fig, ax = plt.subplots()
media.groupby('metabolite').plot(x='time', ax =ax, y='conc_mmol')
ax.legend(('acetate','CO2', 'formate', 'glucose'))
ax.set_ylabel("Concentration (mmol)")
ax.set_xlabel("Time (h)")
ax = media.plot(x='cycle', ax=ax)
ax.set_ylabel('Concentration (mmol)')
ax.set_xlabel('Time (h)')

# Save the file and upload
plt.savefig(output_path, format='png', bbox_inches='tight')
self.upload_file(config, bucket_location, output_path)

Expand Down

0 comments on commit c7e011e

Please sign in to comment.