Skip to content

Commit

Permalink
requirements and figures
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan authored and Ivan committed Jan 2, 2023
1 parent cd3b265 commit 5561a4d
Show file tree
Hide file tree
Showing 76 changed files with 55 additions and 32 deletions.
63 changes: 31 additions & 32 deletions code/n_pubhs_per_drug.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def fig_2_indv(data, sch_color, max_y, steps, dict_params):
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
plt.tight_layout()

plt.savefig(f'./../figures/dev_write_up/sched_2_{data.lower()}.png'.format(), transparent = True, bbox_inches='tight')
plt.savefig(f'./../figures/writeup/sched_2_{data.lower()}.png'.format(), transparent = True, bbox_inches='tight')

return dict_params

Expand Down Expand Up @@ -230,7 +230,7 @@ def fig_2_indv(data, sch_color, max_y, steps, dict_params):
labelleft=False,
labelbottom=False)

plt.savefig(f'./../figures/dev_write_up/solo_legend.png', transparent = True, bbox_inches='tight')
plt.savefig(f'./../figures/writeup/solo_legend.png', transparent = True, bbox_inches='tight')

# %% Figure 2 fitting by schedule
def fig_2_sche(data, color, lineswag, name_file, max_y, steps, dict_params):
Expand Down Expand Up @@ -280,7 +280,7 @@ def fig_2_sche(data, color, lineswag, name_file, max_y, steps, dict_params):
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
plt.tight_layout()

plt.savefig(f'./../figures/dev_write_up/{name_file}.png'.format(), transparent = True, bbox_inches='tight')
plt.savefig(f'./../figures/writeup/{name_file}.png'.format(), transparent = True, bbox_inches='tight')

return dict_params

Expand Down Expand Up @@ -349,7 +349,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
plt.tight_layout()

plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

return dict_params

Expand Down Expand Up @@ -391,7 +391,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):
#### Figure 3 Rs, Grs and table
# %% Save R^2, a_init, g_rate as csv for table
file_table = 'table_params_exp'
table_exp_params = open('./../figures/dev_write_up/{}.csv'.format(file_table), 'a')
table_exp_params = open('./../figures/writeup/{}.csv'.format(file_table), 'a')

data_writer = csv.writer(table_exp_params)
header_pure = dict_params['Alcohol'].keys()
Expand Down Expand Up @@ -491,7 +491,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):
# # name_file = 'heatmap_r_values'
plt.tight_layout(pad=1.6)
name_file = 'hbars_r_values_ORD_sched'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

# %%
order_sched = ['Psilocybin', 'Cannabis', 'Khat', 'LSD', 'Heroin', 'MDMA',
Expand Down Expand Up @@ -540,7 +540,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):

plt.tight_layout(pad=1.6)
name_file = 'exp_hbars_sched_ORD'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

# %% R-square values coloured by schedule ORDERED MAX TO LOW
sort_orders_r2 = sorted(rs_ds.items(), key=lambda x: x[1][0], reverse=True)
Expand Down Expand Up @@ -602,7 +602,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):
# # name_file = 'heatmap_r_values'
plt.tight_layout(pad=1.6)
name_file = 'hbars_r_values_sched'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

# %% PLOT R squares
zs = np.reshape(r_squares, (16, 1))
Expand Down Expand Up @@ -647,7 +647,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):
# # name_file = 'heatmap_r_values'
plt.tight_layout(pad=1.6)
name_file = 'hbars_r_values'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

# %% GROWTH RATE by SCHEDULE

Expand Down Expand Up @@ -698,7 +698,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):

plt.tight_layout(pad=1.6)
name_file = 'exp_hbars_sched'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')


# %%
Expand Down Expand Up @@ -735,7 +735,7 @@ def fig_2_drug_cat(data, color, title, name_file, max_y, steps, dict_params):

plt.tight_layout(pad=1.6)
name_file = 'exp_hbars'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')


# %% Initial value
Expand Down Expand Up @@ -849,7 +849,7 @@ def fig_3_sched(data, color, name_file):
leg.get_frame().set_linewidth(0.0)

# plt.tight_layout()
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

# %% Schedule I
fig_3_sched(sched_Irgr[:3], ['#235f74', '#3388a6', '#99c3d2'], 'sched_I_lsd_md_hero')
Expand Down Expand Up @@ -921,7 +921,7 @@ def fig_3_rgr(data, color, title, name_file):
leg.get_frame().set_linewidth(0.0)

# plt.tight_layout()
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')

# %% Depressants
fig_3_rgr(depressants, blue_moon, 'Relative Growth Rate.\n Excluding alcohol', 'rgr_depressants_excl_alc')
Expand Down Expand Up @@ -1055,9 +1055,9 @@ def fig_3_rgr(data, color, title, name_file):
leg.get_frame().set_linewidth(0.0)

name_file = 'time_pie_chart_sched_indv'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
name_file = 'figure5_time_pie_chart_sched_indv'
plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
# name_file = 'figure5_time_pie_chart_sched_indv'
# plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')

# %%

Expand Down Expand Up @@ -1104,9 +1104,8 @@ def fig_3_rgr(data, color, title, name_file):
# plt.tight_layout()

name_file = 'time_pie_chart_inset'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')

plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
# plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')

# %%

Expand Down Expand Up @@ -1163,9 +1162,9 @@ def fig_3_rgr(data, color, title, name_file):
# plt.tight_layout()

name_file = 'time_pie_chart_by_schedule'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
name_file = 'figure5_time_pie_chart_by_schedule'
plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
# name_file = 'figure5_time_pie_chart_by_schedule'
# plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')

# %%

Expand Down Expand Up @@ -1223,9 +1222,9 @@ def fig_3_rgr(data, color, title, name_file):
# plt.tight_layout()

name_file = 'time_pie_chart_by_cat'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
name_file = 'figure5_time_pie_chart_by_cat'
plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
# name_file = 'figure5_time_pie_chart_by_cat'
# plt.savefig('./../figures/final_paper/{}.pdf'.format(name_file), transparent = True, bbox_inches='tight')


# %% Figure 5 Per countries
Expand Down Expand Up @@ -1317,7 +1316,7 @@ def fig_5_countries(dat, years, title, color, y_max, steps, name_file):
leg.get_frame().set_linewidth(0.0)
plt.tight_layout()

plt.savefig('./../figures/dev_write_up/{}.png'.format(name_file), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name_file), transparent = True, bbox_inches='tight')


# %% Figure 5 Alcohol
Expand Down Expand Up @@ -1609,7 +1608,7 @@ def test(x, a, b):
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

name = 'all'
# plt.savefig('./../figures/dev_write_up/{}.png'.format(name), transparent = True, bbox_inches='tight')
# plt.savefig('./../figures/writeup/{}.png'.format(name), transparent = True, bbox_inches='tight')

# %% ############# Figure 2 all no alcohol
drugs = raw.iloc[:,2:16]
Expand Down Expand Up @@ -1637,7 +1636,7 @@ def test(x, a, b):
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

plt.savefig('./../figures/dev_write_up/all_no_alc.png', transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/all_no_alc.png', transparent = True, bbox_inches='tight')

# %% ############ Figure 2 number pubs selected_two_axes
drugs_two = ['Cannabis', 'Ketamine', 'MDMA', 'Psilocybin']
Expand Down Expand Up @@ -1686,7 +1685,7 @@ def test(x, a, b):
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
ax2.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

plt.savefig('./../figures/dev_write_up/selected_two_axes.png', transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/selected_two_axes.png', transparent = True, bbox_inches='tight')


# %% ############ Figure 2 WoS
Expand Down Expand Up @@ -1715,7 +1714,7 @@ def test(x, a, b):
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

plt.savefig('./../figures/dev_write_up/WoS.png', transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/WoS.png', transparent = True, bbox_inches='tight')


# %% ############ Figure 2 LSD, Psilocybin, alcohol
Expand Down Expand Up @@ -1765,7 +1764,7 @@ def test(x, a, b):
ax2.yaxis.label.set_color('b')
ax2.spines['right'].set_color('b')

plt.savefig('./../figures/dev_write_up/psyche_alc.png', transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/psyche_alc.png', transparent = True, bbox_inches='tight')

# %%############ Figure 2 Depressants
fig, ax = plt.subplots(figsize = (20, 10))
Expand Down Expand Up @@ -1805,4 +1804,4 @@ def test(x, a, b):
ax.yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))

name = 'depressants'
plt.savefig('./../figures/dev_write_up/{}.png'.format(name), transparent = True, bbox_inches='tight')
plt.savefig('./../figures/writeup/{}.png'.format(name), transparent = True, bbox_inches='tight')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added figures/writeup/alcohol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/alcohol_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/amphetamine_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/benzos_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/cannabis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/cannabis_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/cocaine_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/codeine_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/depressants_excl_alc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/disso.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/exp_hbars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/exp_hbars_sched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/exp_hbars_sched_ORD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/ghb_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/hbars_r_values.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/hbars_r_values_ORD_sched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/hbars_r_values_sched.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/heroin_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/ketamine_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/khat_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/legal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/lsd_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/mdma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/mdma_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/methadone_countries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/writeup/methamphetamine_countries.png
Binary file added figures/writeup/opioids.png
Binary file added figures/writeup/psilo_countries.png
Binary file added figures/writeup/psychedelics.png
Binary file added figures/writeup/rgr_alcohol.png
Binary file added figures/writeup/rgr_cannabis.png
Binary file added figures/writeup/rgr_depressants_excl_alc.png
Binary file added figures/writeup/rgr_disso.png
Binary file added figures/writeup/rgr_mdma.png
Binary file added figures/writeup/rgr_opioids.png
Binary file added figures/writeup/rgr_psychedelics.png
Binary file added figures/writeup/rgr_stimulants.png
Binary file added figures/writeup/sched_2_alcohol.png
Binary file added figures/writeup/sched_2_amphetamines.png
Binary file added figures/writeup/sched_2_benzodiazepines.png
Binary file added figures/writeup/sched_2_cannabis.png
Binary file added figures/writeup/sched_2_cocaine.png
Binary file added figures/writeup/sched_2_codeine.png
Binary file added figures/writeup/sched_2_ghb.png
Binary file added figures/writeup/sched_2_heroin.png
Binary file added figures/writeup/sched_2_ketamine.png
Binary file added figures/writeup/sched_2_khat.png
Binary file added figures/writeup/sched_2_lsd.png
Binary file added figures/writeup/sched_2_mdma.png
Binary file added figures/writeup/sched_2_methadone.png
Binary file added figures/writeup/sched_2_methamphetamines.png
Binary file added figures/writeup/sched_2_psilocybin.png
Binary file added figures/writeup/sched_2_wos.png
Binary file added figures/writeup/sched_II.png
Binary file added figures/writeup/sched_III.png
Binary file added figures/writeup/sched_IV.png
Binary file added figures/writeup/sched_I_lsd_md_hero.png
Binary file added figures/writeup/sched_I_psilo_khat_cann.png
Binary file added figures/writeup/sched_V.png
Binary file added figures/writeup/solo_legend.png
Binary file added figures/writeup/stimulants.png
17 changes: 17 additions & 0 deletions figures/writeup/table_params_exp.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Drugs,r_square,a_init,g_rate
Benzodiazepines,0.66,292.16651926784664,0.02815790196273298
GHB,0.75,6.842647843781876,0.050659040932815674
Khat,0.95,0.7573195888486924,0.08433647660996227
WoS,0.96,372992.76088430115,0.03569500846588188
Ketamine,0.98,24.47362488980567,0.06950411985704238
LSD,0.85,10.094979754268229,0.06229877229509308
Psilocybin,0.92,0.00492157881490633,0.17299473920184968
MDMA,0.84,21.25269365573248,0.05509322680872568
Heroin,0.97,41.891593093546476,0.0557433756755348
Methadone,0.96,35.9703138806572,0.057031237068768934
Codeine,0.94,18.141177640385344,0.046405073422656644
Alcohol,0.99,1093.572415688869,0.06360406994539172
Cannabis,0.97,35.03599976981951,0.08452446892719857
Methamphetamines,0.97,17.046746758139676,0.07131789289344002
Cocaine,0.86,176.3232388877336,0.047814290740857066
Amphetamines,0.82,166.1616081082101,0.03599289697473994
Binary file added figures/writeup/time_pie_chart_by_cat.png
Binary file added figures/writeup/time_pie_chart_by_schedule.png
Binary file added figures/writeup/time_pie_chart_inset.png
Binary file added figures/writeup/time_pie_chart_sched_indv.png
Binary file added figures/writeup/wos_pubs.png
Binary file added figures/writeup/wos_rgr.png
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
matplotlib==3.6.1
matplotlib-inline==0.1.6
scikit-learn==1.2.0
scipy==1.9.3
pandas==1.5.1
numpy==1.23.4
scipy==1.9.3

0 comments on commit 5561a4d

Please sign in to comment.