Skip to content

Commit

Permalink
Merge pull request #77 from mitre/t61-66-update-growth-charts
Browse files Browse the repository at this point in the history
Incorporate new growth chart data supporting infants; update graphs correspondingly. Closes #61, #66.
  • Loading branch information
dchud authored Mar 14, 2023
2 parents 96c6990 + 72a453e commit 3f45fa9
Show file tree
Hide file tree
Showing 17 changed files with 662 additions and 21,487 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ on:
push:
branches:
- main
- v3-dev

jobs:
build-and-publish-image:
if: github.repository == 'mitre/GrowthViz'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.5.0

- name: Build and publish Docker image
- name: Build and publish latest Docker image
uses: VaultVulp/gp-docker-action@1.5.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
image-name: mitre/growthviz
image-name: gv-image
image-tag: latest
23 changes: 23 additions & 0 deletions .github/workflows/build-and-publish-image-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Adapted from:
# https://github.com/VaultVulp/gp-docker-action#complete-workflow-example
name: Build and publish

on:
push:
tags:
- "*"

jobs:
build-and-publish-image:
if: github.repository == 'mitre/GrowthViz'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.5.0

- name: Build and publish tagged Docker image
uses: VaultVulp/gp-docker-action@1.5.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
image-name: gv-image
extract-git-tag: true
38 changes: 23 additions & 15 deletions GrowthViz-adults.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -415,13 +415,15 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"mdf = sumstats.add_mzscored_to_merged_df_adults(merged_df, percentiles_wide) \n",
"mdf['wtz'] = (mdf['weight'] - mdf['Mean_weight'])/mdf['sd_weight']\n",
"mdf['htz'] = (mdf['height'] - mdf['Mean_height'])/mdf['sd_height']\n",
"mdf['BMIz'] = (mdf['bmi'] - mdf['Mean_bmi'])/mdf['sd_bmi']\n",
"mdf['bmiz'] = (mdf['bmi'] - mdf['Mean_bmi'])/mdf['sd_bmi']\n",
"mdf.head()\n",
"\n",
"col_opt = {\n",
Expand All @@ -438,7 +440,7 @@
" 'weight_cat': { 'width': 80 },\n",
" 'wtz': { 'width': 50 },\n",
" 'bmi': { 'width': 40 },\n",
" 'BMIz': { 'width': 30 },\n",
" 'bmiz': { 'width': 30 },\n",
"}\n",
"g = qgrid.show_grid(charts.top_ten(mdf, 'weight'), precision=3, column_options=col_opt, column_definitions=col_def)\n",
"ind_out = widgets.Output()\n",
Expand All @@ -458,7 +460,7 @@
" charts.overlap_view_adults(obs, subjid, 'WEIGHTKG', True, True, wt_percentiles, bmi_percentiles, ht_percentiles)\n",
" display(plt.show()) \n",
"g.on('selection_changed', handle_selection_change) \n",
"widgets.VBox([g, ind_out])\n"
"widgets.VBox([g, ind_out])"
]
},
{
Expand Down Expand Up @@ -496,7 +498,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
"scrolled": false
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -628,17 +630,22 @@
"def edge25(obs, category, group, sort_order, param):\n",
" filtered_by_cat = obs[(obs.clean_cat == category) & (obs.param == param)]\n",
" # get list of relevant IDs\n",
" filtered_sum = filtered_by_cat.groupby('subjid', as_index=False).agg(max_measure=('measurement', 'max'), min_measure=('measurement', 'min'), start_age=('age', 'min'), axis_range=('range', 'mean'))\n",
" filtered_sum = filtered_by_cat.groupby('subjid', as_index=False).agg(max_measure=('measurement', 'max'), \n",
" min_measure=('measurement', 'min'), \n",
" start_age=('ageyears', 'min'), \n",
" axis_range=('range', 'mean'))\n",
" if group == 'largest':\n",
" filtered_sum = filtered_sum.nlargest(25, 'max_measure')\n",
" else:\n",
" filtered_sum = filtered_sum.nsmallest(25, 'min_measure')\n",
" filtered_sum.sort_values(by=[sort_order, 'subjid'], inplace=True)\n",
" fig = charts.five_by_five_view(obs, filtered_sum.subjid.values, param, wt_percentiles, ht_percentiles, bmi_percentiles, 'dotted')\n",
" fig = charts.five_by_five_view(obs, filtered_sum.subjid.values, param, wt_percentiles, ht_percentiles, \n",
" bmi_percentiles, 'dotted')\n",
" plt.show()\n",
" \n",
"interact(edge25, obs = fixed(obs_wbmi_mult), category = obs.clean_cat.unique(), \n",
" group = ['largest', 'smallest'], sort_order = ['max_measure', 'min_measure', 'start_age', 'axis_range'], param = ['WEIGHTKG', 'HEIGHTCM', 'BMI'])"
"interact(edge25, obs=fixed(obs_wbmi_mult), category=obs.clean_cat.unique(), \n",
" group=['largest', 'smallest'], sort_order=['max_measure', 'min_measure', 'start_age', 'axis_range'], \n",
" param=['WEIGHTKG', 'HEIGHTCM', 'BMI']);"
]
},
{
Expand All @@ -658,10 +665,11 @@
"source": [
"all_ids = obs_wbmi['subjid'].unique()\n",
"val = 2431 if 2431 in all_ids else np.random.choice(all_ids, size=1, replace=False)\n",
"interact(charts.param_with_percentiles, merged_df = fixed(obs_wbmi),\n",
" subjid = widgets.Dropdown(options=all_ids, value=val,\n",
" description='Subject ID:',disabled=False), \n",
" param = ['BMI', 'WEIGHTKG', 'HEIGHTCM'], wt_df = fixed(wt_percentiles), ht_df = fixed(ht_percentiles), bmi_df = fixed(bmi_percentiles))"
"interact(charts.param_with_percentiles, merged_df=fixed(obs_wbmi),\n",
" subjid=widgets.Dropdown(options=all_ids, value=val,\n",
" description='Subject ID:', disabled=False), \n",
" param=['BMI', 'WEIGHTKG', 'HEIGHTCM'], wt_df=fixed(wt_percentiles), \n",
" ht_df=fixed(ht_percentiles), bmi_df=fixed(bmi_percentiles));"
]
},
{
Expand Down Expand Up @@ -833,7 +841,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
26 changes: 16 additions & 10 deletions GrowthViz-adults.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
mdf = sumstats.add_mzscored_to_merged_df_adults(merged_df, percentiles_wide)
mdf['wtz'] = (mdf['weight'] - mdf['Mean_weight'])/mdf['sd_weight']
mdf['htz'] = (mdf['height'] - mdf['Mean_height'])/mdf['sd_height']
mdf['BMIz'] = (mdf['bmi'] - mdf['Mean_bmi'])/mdf['sd_bmi']
mdf['bmiz'] = (mdf['bmi'] - mdf['Mean_bmi'])/mdf['sd_bmi']
mdf.head()

col_opt = {
Expand All @@ -270,7 +270,7 @@
'weight_cat': { 'width': 80 },
'wtz': { 'width': 50 },
'bmi': { 'width': 40 },
'BMIz': { 'width': 30 },
'bmiz': { 'width': 30 },
}
g = qgrid.show_grid(charts.top_ten(mdf, 'weight'), precision=3, column_options=col_opt, column_definitions=col_def)
ind_out = widgets.Output()
Expand Down Expand Up @@ -397,17 +397,22 @@ def all_charts(subjid=val):
def edge25(obs, category, group, sort_order, param):
filtered_by_cat = obs[(obs.clean_cat == category) & (obs.param == param)]
# get list of relevant IDs
filtered_sum = filtered_by_cat.groupby('subjid', as_index=False).agg(max_measure=('measurement', 'max'), min_measure=('measurement', 'min'), start_age=('age', 'min'), axis_range=('range', 'mean'))
filtered_sum = filtered_by_cat.groupby('subjid', as_index=False).agg(max_measure=('measurement', 'max'),
min_measure=('measurement', 'min'),
start_age=('ageyears', 'min'),
axis_range=('range', 'mean'))
if group == 'largest':
filtered_sum = filtered_sum.nlargest(25, 'max_measure')
else:
filtered_sum = filtered_sum.nsmallest(25, 'min_measure')
filtered_sum.sort_values(by=[sort_order, 'subjid'], inplace=True)
fig = charts.five_by_five_view(obs, filtered_sum.subjid.values, param, wt_percentiles, ht_percentiles, bmi_percentiles, 'dotted')
fig = charts.five_by_five_view(obs, filtered_sum.subjid.values, param, wt_percentiles, ht_percentiles,
bmi_percentiles, 'dotted')
plt.show()

interact(edge25, obs = fixed(obs_wbmi_mult), category = obs.clean_cat.unique(),
group = ['largest', 'smallest'], sort_order = ['max_measure', 'min_measure', 'start_age', 'axis_range'], param = ['WEIGHTKG', 'HEIGHTCM', 'BMI'])
interact(edge25, obs=fixed(obs_wbmi_mult), category=obs.clean_cat.unique(),
group=['largest', 'smallest'], sort_order=['max_measure', 'min_measure', 'start_age', 'axis_range'],
param=['WEIGHTKG', 'HEIGHTCM', 'BMI']);


# # Visualizing Changes in Trajectory
Expand All @@ -419,10 +424,11 @@ def edge25(obs, category, group, sort_order, param):

all_ids = obs_wbmi['subjid'].unique()
val = 2431 if 2431 in all_ids else np.random.choice(all_ids, size=1, replace=False)
interact(charts.param_with_percentiles, merged_df = fixed(obs_wbmi),
subjid = widgets.Dropdown(options=all_ids, value=val,
description='Subject ID:',disabled=False),
param = ['BMI', 'WEIGHTKG', 'HEIGHTCM'], wt_df = fixed(wt_percentiles), ht_df = fixed(ht_percentiles), bmi_df = fixed(bmi_percentiles))
interact(charts.param_with_percentiles, merged_df=fixed(obs_wbmi),
subjid=widgets.Dropdown(options=all_ids, value=val,
description='Subject ID:', disabled=False),
param=['BMI', 'WEIGHTKG', 'HEIGHTCM'], wt_df=fixed(wt_percentiles),
ht_df=fixed(ht_percentiles), bmi_df=fixed(bmi_percentiles));


# # Summary Statistics
Expand Down
Loading

0 comments on commit 3f45fa9

Please sign in to comment.