-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into nf-core-template-merge-3.2.0
- Loading branch information
Showing
64 changed files
with
2,724 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ testing/ | |
testing* | ||
*.pyc | ||
null/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
from drevalpy.utils import get_parser, check_arguments | ||
|
||
|
||
def main(argv=None): | ||
"""Coordinate argument parsing and program execution.""" | ||
args = get_parser().parse_args(argv) | ||
check_arguments(args) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
import pandas as pd | ||
|
||
from drevalpy.visualization.utils import prep_results, write_results | ||
|
||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser(description="Collect results and write to single files.") | ||
parser.add_argument("--outfiles", type=str, nargs="+", required=True, help="Output files.") | ||
return parser | ||
|
||
|
||
def parse_results(args): | ||
# get all files with the pattern f'{model_name}_evaluation_results.csv' from args.outfiles | ||
result_files = [file for file in args.outfiles if "evaluation_results.csv" in file] | ||
# get all files with the pattern f'{model_name}_evaluation_results_per_drug.csv' from args.outfiles | ||
result_per_drug_files = [file for file in args.outfiles if "evaluation_results_per_drug.csv" in file] | ||
# get all files with the pattern f'{model_name}_evaluation_results_per_cl.csv' from args.outfiles | ||
result_per_cl_files = [file for file in args.outfiles if "evaluation_results_per_cl.csv" in file] | ||
# get all files with the pattern f'{model_name}_true_vs_pred.csv' from args.outfiles | ||
t_vs_pred_files = [file for file in args.outfiles if "true_vs_pred.csv" in file] | ||
return result_files, result_per_drug_files, result_per_cl_files, t_vs_pred_files | ||
|
||
|
||
def collapse_file(files): | ||
out_df = None | ||
for file in files: | ||
if out_df is None: | ||
out_df = pd.read_csv(file, index_col=0) | ||
else: | ||
out_df = pd.concat([out_df, pd.read_csv(file, index_col=0)]) | ||
return out_df | ||
|
||
|
||
if __name__ == "__main__": | ||
args = get_parser().parse_args() | ||
# parse the results from args.outfiles | ||
eval_result_files, eval_result_per_drug_files, eval_result_per_cl_files, true_vs_pred_files = parse_results(args) | ||
|
||
# collapse the results into single dataframes | ||
eval_results = collapse_file(eval_result_files) | ||
eval_results_per_drug = collapse_file(eval_result_per_drug_files) | ||
eval_results_per_cell_line = collapse_file(eval_result_per_cl_files) | ||
t_vs_p = collapse_file(true_vs_pred_files) | ||
|
||
# prepare the results through introducing new columns algorithm, rand_setting, LPO_LCO_LDO, split, CV_split | ||
eval_results, eval_results_per_drug, eval_results_per_cell_line, t_vs_p = prep_results( | ||
eval_results, eval_results_per_drug, eval_results_per_cell_line, t_vs_p | ||
) | ||
|
||
# save the results to csv files | ||
write_results( | ||
path_out="", | ||
eval_results=eval_results, | ||
eval_results_per_drug=eval_results_per_drug, | ||
eval_results_per_cl=eval_results_per_cell_line, | ||
t_vs_p=t_vs_p, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import argparse | ||
from drevalpy.models import MODEL_FACTORY | ||
from drevalpy.experiment import consolidate_single_drug_model_predictions | ||
|
||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser(description="Consolidate results for SingleDrugModels") | ||
parser.add_argument('--run_id', type=str, required=True, help="Run ID") | ||
parser.add_argument("--test_mode", type=str, required=True, help="Test mode (LPO, LCO, LDO)") | ||
parser.add_argument("--model_name", type=str, required=True, help="All Model " | ||
"names") | ||
parser.add_argument("--outdir_path", type=str, required=True, help="Output directory path") | ||
parser.add_argument("--n_cv_splits", type=int, required=True, help="Number of CV splits") | ||
parser.add_argument("--cross_study_datasets", type=str, nargs="+", help="All " | ||
"cross-study " | ||
"datasets") | ||
parser.add_argument("--randomization_modes", type=str, required=True, help="All " | ||
"randomizations") | ||
parser.add_argument("--n_trials_robustness", type=int, required=True, help="Number of trials") | ||
return parser | ||
|
||
|
||
def main(): | ||
parser = get_parser() | ||
args = parser.parse_args() | ||
results_path = os.path.join( | ||
args.outdir_path, | ||
args.run_id, | ||
args.test_mode, | ||
) | ||
randomizations = args.randomization_modes.split('[')[1].split(']')[0].split(', ') | ||
model = MODEL_FACTORY[args.model_name] | ||
if args.cross_study_datasets is None: | ||
args.cross_study_datasets = [] | ||
consolidate_single_drug_model_predictions( | ||
models=[model], | ||
n_cv_splits=args.n_cv_splits, | ||
results_path=results_path, | ||
cross_study_datasets=args.cross_study_datasets, | ||
randomization_mode=randomizations, | ||
n_trials_robustness=args.n_trials_robustness, | ||
out_path="" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import pickle | ||
import sys | ||
|
||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser(description="Split data into CV splits") | ||
parser.add_argument("--response", type=str, required=True, help="Path to response data") | ||
parser.add_argument("--n_cv_splits", type=int, required=True, help="Number of CV splits") | ||
parser.add_argument("--test_mode", type=str, default="LPO", help="Test mode (LPO, LCO, LDO)") | ||
return parser | ||
|
||
|
||
def main(): | ||
parser = get_parser() | ||
args = parser.parse_args() | ||
response_data = pickle.load(open(args.response, "rb")) | ||
response_data.remove_nan_responses() | ||
response_data.split_dataset( | ||
n_cv_splits=args.n_cv_splits, | ||
mode=args.test_mode, | ||
split_validation=True, | ||
split_early_stopping=True, | ||
validation_ratio=0.1, | ||
random_state=42, | ||
) | ||
for split_index, split in enumerate(response_data.cv_splits): | ||
with open(f"split_{split_index}.pkl", "wb") as f: | ||
pickle.dump(split, f) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
import pandas as pd | ||
|
||
from drevalpy.visualization.critical_difference_plot import CriticalDifferencePlot | ||
|
||
def get_parser(): | ||
parser = argparse.ArgumentParser(description="Draw critical difference plots.") | ||
parser.add_argument("--name", type=str, required=True, help="Name/Setting of plot.") | ||
parser.add_argument("--data", type=str, required=True, help="Path to data.") | ||
return parser | ||
|
||
|
||
def draw_cd(path_to_df: str, setting: str): | ||
df = pd.read_csv(path_to_df, index_col=0) | ||
df = df[(df["LPO_LCO_LDO"] == setting) & (df["rand_setting"] == "predictions")] | ||
cd_plot = CriticalDifferencePlot( | ||
eval_results_preds=df, | ||
metric='MSE' | ||
) | ||
cd_plot.draw_and_save( | ||
out_prefix='', | ||
out_suffix=setting | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
args = get_parser().parse_args() | ||
draw_cd(path_to_df=args.data, setting=args.name) |
Oops, something went wrong.