Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.3.0: enable scripts to switch Comps environments; update with latest dependencies; #66

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions create_plots/helpers_likelihood_and_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import warnings
import numpy as np
from plotnine import ggplot, aes, geom_point, xlab, ylab, coord_fixed, geom_abline, theme_classic, themes, \
ggtitle, geom_smooth
ggtitle, geom_smooth, element_text
import collections


Expand Down Expand Up @@ -230,7 +230,7 @@ def corr_ref_sim_points(combined_df):
+ geom_abline(slope=1, intercept=0, color='grey', alpha=0.5)
+ geom_smooth(method="lm", fill=None, se=False, alpha=0.5, size=0.5)
+ theme_classic()
+ themes.theme(plot_title=themes.element_text(size=12)))
+ themes.theme(plot_title=element_text(size=12)))

# create data frame with information about linear regression and correlation for each Site
lm_summary = collections.defaultdict(list)
Expand Down Expand Up @@ -296,7 +296,7 @@ def corr_ref_deriv_sim_points(combined_df):
+ geom_abline(slope=1, intercept=0, color='grey', alpha=0.5)
# + geom_smooth(method="lm", fill=None, se=False, alpha=0.5, size=0.5)
+ theme_classic()
+ themes.theme(plot_title=themes.element_text(size=12)))
+ themes.theme(plot_title=element_text(size=12)))

# create data frame with information about linear regression and correlation for each Site
lm_summary = collections.defaultdict(list)
Expand Down
8 changes: 4 additions & 4 deletions create_plots/helpers_plot_ref_sim_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from plotnine import ggplot, aes, geom_bar, scale_fill_brewer, facet_grid, geom_line, geom_point, geom_errorbar, \
theme_bw, xlab, ylab, scale_color_manual, scale_fill_manual, coord_fixed, geom_abline, theme_classic, themes, \
facet_wrap, scale_shape_manual, scale_size_manual, scale_x_log10, ggtitle, labs, position_dodge
facet_wrap, scale_shape_manual, scale_size_manual, scale_x_log10, ggtitle, labs, position_dodge, element_text
import numpy as np
import pandas as pd
from scipy.stats import beta
Expand Down Expand Up @@ -58,7 +58,7 @@ def compare_benchmark(combined_df):
+ coord_fixed(ratio=1, xlim=(min_value, max_value), ylim=(min_value, max_value))
+ geom_abline(slope=1, intercept=0, color='grey', alpha=0.5)
+ theme_classic()
+ themes.theme(plot_title=themes.element_text(size=12)))
+ themes.theme(plot_title=element_text(size=12)))
return gg


Expand Down Expand Up @@ -249,7 +249,7 @@ def plot_par_dens_ref_sim_comparison(combined_df):
+ theme_bw()
+ ylab('fraction of population')
+ xlab('parasite density bin')
+ themes.theme(axis_text_x=themes.element_text(angle=45))
+ themes.theme(axis_text_x=element_text(angle=45))
+ ggtitle(cur_site)
+ scale_color_manual(values=color_manual)
+ scale_shape_manual(values=shape_manual)
Expand Down Expand Up @@ -742,6 +742,6 @@ def plot_infection_duration_dist_by_age(ref_df, sim_data, pos_thresh_dens, age_b
+ scale_fill_manual(values=color_manual_2)
+ labs(title='infection duration', x='infection duration (days)')
# ylim(NA,max_y) +
+ facet_grid(scales='fixed', facets=['censor_type', 'age_group']))
+ facet_grid('censor_type', 'age_group', scales='fixed'))

return gg
2 changes: 1 addition & 1 deletion idmtools.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ max_local_sims = 6

[SLURM]
type = COMPS
endpoint = https://comps.idmod.org
endpoint = https://comps2.idmod.org
environment = Calculon
priority = Normal
simulation_root = $COMPS_PATH(USER)\output
Expand Down
Binary file added report/Malaria_model_validation_output_v1.3.0.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ scipy~=1.9
snakemake~=7.19
plotnine~=0.10
datar~=0.9
pulp==2.7.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_arguments_from_file(filepath, arguments_list):

setuptools.setup(
name="malaria_model_validation",
version="1.2.0",
version="1.3.0",
author=[author[0] for author in authors],
author_email=[author[1] for author in authors],
description="malaria-model_validation package",
Expand Down
2 changes: 1 addition & 1 deletion simulations/add_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def add_suite(sites: list, suite_name: str = 'Malaria Model Validation Suite') -
Returns:
suite_id
"""
platform = Platform(manifest.platform_name)
platform = Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment)
first_exp_found = True
for site in sites:
exp_id_file = get_comps_id_filename(site, level=0)
Expand Down
8 changes: 4 additions & 4 deletions simulations/analyzers/AnnualSummaryReportAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from idmtools.core import ItemType
from idmtools.core.platform_factory import Platform


mpl.use('Agg')


Expand Down Expand Up @@ -78,19 +77,20 @@ def reduce(self, all_data: Dict[Union[IWorkflowItem, Simulation], Any]) -> Any:

groupby_tags = self.sweep_variables
groupby_tags.remove('Run_Number')
df_summarized = df_final.groupby(['Age']+groupby_tags)['Prevalence', 'Incidence'].apply(np.mean).reset_index()
df_summarized_std = df_final.groupby(['Age']+groupby_tags)['Prevalence', 'Incidence'].apply(np.std)
df_summarized = df_final.groupby(['Age']+groupby_tags, as_index=False).agg({'Prevalence': np.mean, 'Incidence': np.mean})
df_summarized_std = df_final.groupby(['Age']+groupby_tags).agg({'Prevalence': np.mean, 'Incidence': np.mean})
for c in ['Prevalence', 'Incidence']:
df_summarized[c + '_std'] = list(df_summarized_std[c])

df_summarized.to_csv(os.path.join(self.working_dir, self.expt_name, "inc_prev_data_final.csv"))


if __name__ == '__main__':
import simulations.manifest as manifest
# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
logger = getLogger()
with Platform('CALCULON') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Initialize the analyser class with the path of the output csv file
analyzers = [AnnualSummaryReportAnalyzer()]
Expand Down
3 changes: 2 additions & 1 deletion simulations/analyzers/InfectiousnessByParDensAgeAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ def reduce(self, all_data):


if __name__ == '__main__':
import simulations.manifest as manifest
# Set the experiment id you want to analyze
experiment_id = 'b7126585-30b6-ec11-a9f6-9440c9be2c51'
end_year = 65

# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
logger = getLogger()
with Platform('CALCULON') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Initialize the analyser class with the path of the output csv file
analyzers = [InfectiousnessByParDensAgeAnalyzer(expt_name='Sugungum_1970',
Expand Down
4 changes: 2 additions & 2 deletions simulations/analyzers/InsetChartAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from idmtools.core import ItemType
from idmtools.core.platform_factory import Platform


mpl.use('Agg')


Expand Down Expand Up @@ -103,10 +102,11 @@ def reduce(self, all_data: Dict[Union[IWorkflowItem, Simulation], Any]) -> Any:


if __name__ == '__main__':
import simulations.manifest as manifest
# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
logger = getLogger()
with Platform('CALCULON') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Initialize the analyser class with the path of the output csv file
analyzers = [InsetChartAnalyzer()]
Expand Down
3 changes: 2 additions & 1 deletion simulations/analyzers/MonthlySummaryReportAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ def reduce(self, all_data):


if __name__ == '__main__':
import simulations.manifest as manifest
# Set the experiment id you want to analyze
experiment_id = 'b7126585-30b6-ec11-a9f6-9440c9be2c51'
end_year = 65

# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
logger = getLogger()
with Platform('CALCULON') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Initialize the analyser class with the path of the output csv file
analyzers = [MonthlySummaryReportAnalyzer(expt_name='Sugungum_1970',
Expand Down
3 changes: 2 additions & 1 deletion simulations/analyzers/ParDensAgeAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def reduce(self, all_data):


if __name__ == '__main__':
import simulations.manifest as manifest

# Set the experiment id you want to analyze
experiment_id = 'b7126585-30b6-ec11-a9f6-9440c9be2c51'
Expand All @@ -84,7 +85,7 @@ def reduce(self, all_data):
# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
logger = getLogger()
with Platform('CALCULON') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Initialize the analyser class with the path of the output csv file
analyzers = [ParDensAgeAnalyzer(expt_name='Sugungum_1970',
Expand Down
3 changes: 2 additions & 1 deletion simulations/analyzers/PatientReportAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ def reduce(self, all_data):
from idmtools.analysis.analyze_manager import AnalyzeManager
from idmtools.core import ItemType
from idmtools.core.platform_factory import Platform
import simulations.manifest as manifest

use_ssmt = True

# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
with Platform('Calculon') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Set the experiment you want to analyze
experiments = {
Expand Down
3 changes: 2 additions & 1 deletion simulations/analyzers/PatientReportAnalyzer_laterDays.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ def reduce(self, all_data):
from idmtools.core import ItemType
from idmtools.core.platform_factory import Platform
from general.manifest import analyzed_ouptut_path
import simulations.manifest as manifest

# Set the platform where you want to run your analysis
# In this case we are running in BELEGOST since the Work Item we are analyzing was run on COMPS
with Platform('Calculon') as platform:
with Platform(manifest.platform_name, endpoint=manifest.endpoint, environment=manifest.environment) as platform:

# Set the experiment you want to analyze
experiments = {'test_infectDuration_Navrongo2': 'aaa3fc9f-787a-ec11-a9f3-9440c9be2c51'}
Expand Down
6 changes: 3 additions & 3 deletions simulations/create_auth_token_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import getpass
from COMPS import Client
from COMPS.CredentialPrompt import CredentialPrompt

import simulations.manifest as manifest
__comps_client_version = 10


Expand All @@ -29,7 +29,7 @@ def prompt(self):
if __name__ == '__main__':
parser = argparse.ArgumentParser()

parser.add_argument('--comps_url', '-c', default='https://comps.idmod.org', help='comps url')
parser.add_argument('--comps_url', '-c', default=manifest.endpoint, help='comps url')
parser.add_argument('--username', '-u', help='enter username')
parser.add_argument('--password', '-p', help='enter password')

Expand All @@ -43,4 +43,4 @@ def prompt(self):
print(f"Login to {compshost} and cache the credentials.")

Client.login(compshost, StaticCredentialPrompt(comps_url=args.comps_url, username=args.username,
password=p))
password=p))
Binary file modified simulations/download/Eradication
Binary file not shown.
Loading
Loading