|
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# will find fmax distribution given the single cluster fits on |
| 4 | +# good binders and good fitters. |
| 5 | +# |
| 6 | +# fmax distribtuion is then enforced for weak binders, allowing |
| 7 | +# good measurements even when no reaching saturation. |
| 8 | +# |
| 9 | +# Median of cluster fits are bootstrapped to obtain errors on |
| 10 | +# fit parameters. |
| 11 | +# |
| 12 | +# Sarah Denny |
| 13 | +# July 2015 |
| 14 | + |
| 15 | +##### IMPORT ##### |
| 16 | +import numpy as np |
| 17 | +import pandas as pd |
| 18 | +import sys |
| 19 | +import os |
| 20 | +import argparse |
| 21 | +import seqfun |
| 22 | +import datetime |
| 23 | +import IMlibs |
| 24 | +import seaborn as sns |
| 25 | +import scipy.stats as st |
| 26 | +import matplotlib.pyplot as plt |
| 27 | +sns.set_style("white", {'xtick.major.size': 4, 'ytick.major.size': 4}) |
| 28 | +import plotFun |
| 29 | +import findFmaxDist |
| 30 | +import fitFun |
| 31 | +#plt.rc('text', usetex=True) |
| 32 | +### MAIN ### |
| 33 | + |
| 34 | +################ Parse input parameters ################ |
| 35 | + |
| 36 | +#set up command line argument parser |
| 37 | +parser = argparse.ArgumentParser(description='bootstrap fits') |
| 38 | +parser.add_argument('-b', '--binding_curves', required=True, metavar=".CPseries.pkl", |
| 39 | + help='file containining the binding curve information') |
| 40 | +parser.add_argument('-f', '--single_cluster_fits', required=True, metavar=".CPfitted.pkl", |
| 41 | + help='file containining the single cluster fits') |
| 42 | +parser.add_argument('-c', '--concentrations', required=True, metavar="concentrations.txt", |
| 43 | + help='text file giving the associated concentrations') |
| 44 | +parser.add_argument('-i', '--cluster', required=True, metavar="clusterID", |
| 45 | + help='cluster Id for which to plot') |
| 46 | + |
| 47 | +parser.add_argument('-out', '--out_file', |
| 48 | + help='output filename. default is "cluster_X.binding_curve.pdf"') |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +if __name__ == '__main__': |
| 53 | + args = parser.parse_args() |
| 54 | + |
| 55 | + annotatedClusterFile = args.annotated_clusters |
| 56 | + bindingCurveFilename = args.binding_curves |
| 57 | + singleClusterFilename = args.single_cluster_fits |
| 58 | + cluster = args.cluster |
| 59 | + |
| 60 | + # load data |
| 61 | + concentrations = np.loadtxt(args.concentrations) |
| 62 | + bindingSeries = pd.read_pickle(bindingCurveFilename) |
| 63 | + fittedSingles = pd.read_pickle(singleClusterFilename) |
| 64 | + |
| 65 | + # plot |
| 66 | + fig = plt.figure(figsize=(4,3)) |
| 67 | + ax = fig.add_subplot(111) |
| 68 | + fitParameters = pd.DataFrame(columns=['fmax', 'dG', 'fmin']) |
| 69 | + fitFun.plotFitCurve(concentrations, |
| 70 | + bindingSeries.loc[cluster], |
| 71 | + fittedSingles.loc[cluster], |
| 72 | + fitParameters, ax=ax) |
| 73 | + |
| 74 | + if args.out_file is None: |
| 75 | + args.out_file = 'cluster_%s.binding_curve.pdf'%cluster |
| 76 | + plt.savefig( args.out_file) |
0 commit comments