Skip to content

Commit

Permalink
script for DR curves and first steps for tool development
Browse files Browse the repository at this point in the history
  • Loading branch information
rmassei committed Apr 6, 2024
1 parent da150f1 commit 0acacd5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tools/tox_tools/dose_responses/dose_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse
import pandas as pd
from py50.calculator import Calculator
from py50.plotcurve import PlotCurve
import matplotlib.pyplot as plt


parser = argparse.ArgumentParser(description="Calculate IC50 values, plot dose-response curves, and save results.")
parser.add_argument('file_path', type=str, help='Path to the CSV file containing the data.')
parser.add_argument('--plot_title', type=str, default='Default Plot Single Example (Positive)', help='Title for the plot.')
parser.add_argument('--drug_name', type=str, default='Drug 1', help='Name of the drug for labeling purposes.')
parser.add_argument('--output_plot', type=str, default='dose_response_curve.jpg', help='File name for saving the output plot as JPG.')
parser.add_argument('--output_ic50', type=str, default='ic50_values.txt', help='File name for saving the IC50 values as a text file.')
args = parser.parse_args()


df = pd.read_csv(args.file_path)

data = Calculator(df)
ic50 = data.calculate_ic50(name_col='compound', concentration_col='concentration', response_col='effect')

with open(args.output_ic50, 'w') as f:
f.write(f"IC50 Value: {ic50}\n")

plot_data = PlotCurve(df)
fig, ax = plt.subplots()
fig = plot_data.single_curve_plot(ax=ax,
concentration_col='concentration',
response_col='effect',
plot_title=args.plot_title,
drug_name=args.drug_name,
xlabel='Concentration',
ylabel='Effect',
legend=True)

fig.savefig(args.output_plot, format='jpg', dpi=300)

Empty file.
11 changes: 11 additions & 0 deletions tools/tox_tools/dose_responses/test-data/single_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
compound,concentration,effect,% Inhibition 2,% Inhibition Avg
Drug 1,100000,90,94,92
Drug 1,33300,97,89,93
Drug 1,11100,86,89,88
Drug 1,3700,81,88,84
Drug 1,1240,63,70,67
Drug 1,412,36,47,41
Drug 1,137,22,11,16
Drug 1,45.7,-4,-3,-3
Drug 1,15.2,11,-3,4
Drug 1,5,-14,-11,-12

0 comments on commit 0acacd5

Please sign in to comment.