-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImatinib_Dissociation_Kinetics.py
67 lines (51 loc) · 1.67 KB
/
Imatinib_Dissociation_Kinetics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from scipy.interpolate import interp1d
# Read the .csv data file into Python and store the data in a DataFrame
data = pd.read_csv('example3_data.csv')
# Extract x and y data from the DataFrame
x = data.iloc[:, 0].values
y = data.iloc[:, 1].values
# Plot the data
plt.figure()
plt.plot(x, y, marker='o', linestyle='', label='Data')
plt.xlabel('time (s)', fontsize=12)
plt.ylabel('Fluorescence (au)', fontsize=12)
plt.title('BCR-ABL1/Imatinib Dissociation Curve')
plt.legend()
# Identify baseline fluorescence (b0)
b0 = y[-1]
# Identify signal adjustment (a0)
a0 = y[0] - b0
# Identify initial estimate for k0
half_max_fluorescence = max(y) / 2
half_life_time = interp1d(y, x)(half_max_fluorescence)
k0 = -np.log((half_max_fluorescence - b0) / a0) / half_life_time
# Define the fitting function
def dissociation_equation(x, a, k, b):
"""
Custom equation representing the dissociation kinetics.
Parameters:
x (numpy.ndarray): Time points.
a (float): Amplitude.
k (float): Rate constant.
b (float): Baseline.
Returns:
numpy.ndarray: Predicted fluorescence values.
"""
return a * np.exp(-k * x) + b
# Fit the data to the custom equation
params, _ = curve_fit(dissociation_equation, x, y, p0=[a0, k0, b0])
# Plot the fit
plt.figure()
plt.plot(x, y, marker='o', linestyle='', label='Data')
plt.plot(x, dissociation_equation(x, *params), 'r-', label='Fit')
plt.title('BCR-ABL1/Imatinib Dissociation Curve')
plt.xlabel('time (seconds)')
plt.ylabel('fluorescence (au)')
plt.legend()
# Save the plot
plt.savefig('ImatinibDissociationCurve.png')
plt.show()