Skip to content

Instantly share code, notes, and snippets.

@normcyr
Last active March 2, 2018 18:20
Show Gist options
  • Save normcyr/332e18a0b307b00885f1880527bdd705 to your computer and use it in GitHub Desktop.
Save normcyr/332e18a0b307b00885f1880527bdd705 to your computer and use it in GitHub Desktop.
'''
Script to analyze, plot and fit fluorescence anisotropy data
Data file can be foudn here:
https://www.normandcyr.com/data/data.csv
'''
import pandas as pd
import matplotlib.pyplot as plt
from scipy import optimize
from math import sqrt
# read the data (presented in mP)
df = pd.read_csv('data.csv', sep = ',', header = 0)
# convert to anisotropy values
df = (2 * (df / 1000)) / (3 - (df / 1000))
# calculate mean and standard deviation of the data
df['mean'] = df.mean(axis = 1)
df['stdev'] = df.std(axis = 1)
LC3Aconc = 20000
DOR = 20
LC3A = [LC3Aconc]
# fill dataframe with LC3A concentration (serial dilution 3 folds)
for i in range(len(df) - 1):
LC3Aconc = float(LC3Aconc / 3)
LC3A.append(LC3Aconc)
# create the dataframe with mean and standard deviation
LC3A.reverse()
df['LC3A'] = LC3A
data_for_graph = pd.concat([df['LC3A'], df['mean'], df['stdev']], axis = 1)
# plot the data
data_for_graph.plot.scatter(x = 'LC3A', y = 'mean', yerr = 'stdev', logx = True)
def fit_FP(LC3Aconc, Af, Ab, Kd):
return(Af + (LC3Aconc + DOR + Kd) - ((LC3Aconc + DOR + Kd)**2 - (4 * LC3Aconc * DOR))**-1 * ((Ab - Af) / (2 * LC3Aconc)))
# fit the data
print(optimize.curve_fit(fit_FP, df['LC3A'], df['mean'], p0 = None))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment