1
0
Fork 0
mirror of https://github.com/Athemis/pyKinetics.git synced 2025-04-05 06:56:02 +00:00

option to disable MM calculation; option to scale y and x axis in kinetics plot as log

This commit is contained in:
Alexander Minges 2016-04-08 15:55:57 +02:00
parent 19c97dc6f2
commit b8a950fbc8
2 changed files with 49 additions and 5 deletions

View file

@ -42,9 +42,12 @@ class ExperimentHelper():
Provides plotting and data output functionality for libkinetics.Experiment.
"""
def __init__(self, experiment, logger):
def __init__(self, experiment, logger, unit, logx=False, logy=False):
self.exp = experiment
self.logger = logger
self.logx = logx
self.logy = logy
self.unit = unit
def linear_regression_function(self, slope, x, intercept):
y = slope * x + intercept
@ -83,10 +86,15 @@ class ExperimentHelper():
def plot_kinetics(self, outpath):
exp = self.exp
fig, ax = plt.subplots()
ax.set_xlabel('c [mM]')
ax.set_xlabel('c [{}]'.format(self.unit))
ax.set_ylabel('dA/dt [Au/s]')
ax.set_title('Kinetics')
if self.logx:
ax.set_xscale('log')
if self.logy:
ax.set_yscale('log')
ax.errorbar(exp.raw_kinetic_data['x'],
exp.raw_kinetic_data['y'],
yerr=exp.raw_kinetic_data['yerr'],
@ -159,10 +167,22 @@ def parse_arguments():
'--replicates',
action='store_true',
help='fit kinetics to individual replicates')
parser.add_argument('-nm',
'--no-michaelis',
action='store_true',
help='do not compute michaelis-menten kinetics')
parser.add_argument('-wh',
'--hill',
action='store_true',
help='compute additional kinetics using Hill equation')
parser.add_argument('-lx',
'--log-x',
action='store_true',
help='x axis in kinetics is log-scaled')
parser.add_argument('-ly',
'--log-y',
action='store_true',
help='y axis in kinetics is log-scaled')
parser.add_argument('start',
type=np.float64,
help='start of fitting window')
@ -173,6 +193,9 @@ def parse_arguments():
parser.add_argument('output',
type=str,
help='results will be written to this directory')
parser.add_argument('unit',
type=str,
help='unit of concentrations')
args = parser.parse_args()
@ -244,6 +267,21 @@ def main():
# grab fitting window from provided arguments
fitting_window = (args.start, args.end)
if args.log_x:
logx = args.log_x
else:
logx = False
if args.log_y:
logy = args.log_y
else:
logy = False
if args.no_michaelis:
no_mm = args.no_michaelis
else:
no_mm = False
if args.hill:
do_hill = args.hill
else:
@ -278,9 +316,10 @@ def main():
exp = libkinetics.Experiment(data_files,
fitting_window,
do_hill=do_hill,
no_mm=no_mm,
logger=logger,
fit_to_replicates=fit_to_replicates)
ehlp = ExperimentHelper(exp, logger)
ehlp = ExperimentHelper(exp, logger, args.unit, logx=logx, logy=logy)
logger.info('Plotting linear fits')
ehlp.plot_data(str(output_path))
logger.info('Plotting kinetic fit(s)')

View file

@ -225,7 +225,7 @@ class Experiment():
lower and upper bounds for calculating the v0 linear fit.
"""
def __init__(self, data_files, xlim, do_hill=False,
def __init__(self, data_files, xlim, do_hill=False, no_mm=False,
fit_to_replicates=False, logger=None):
"""
Inits Experiment class with experimental parameters
@ -240,6 +240,8 @@ class Experiment():
linear fitting of v0
do_hill: boolean to define whether to fit Hill-type kinetics in
addition to Michaelis-Menten kinetics. Defaults to False
no_mm: boolean to define whether the calculation of Michaelis-Menten
kinetics is supressed. Defaults to False
fit_to_replicates: boolean to define wheter to fit to individual
replicates instead of the avarage slope. Defaults to False
logger: logging.Logger instance. If not given, a new logger is
@ -311,7 +313,10 @@ class Experiment():
self.raw_kinetic_data['yerr'].append(m.avg_slope_err)
# calculate kinetics
self.mm = self.do_mm_kinetics()
if not no_mm:
self.mm = self.do_mm_kinetics()
else:
self.mm = None
if do_hill:
self.hill = self.do_hill_kinetics()
else: