1717from pcpostprocess .directory_builder import setup_output_directory
1818from pcpostprocess .scripts .run_herg_qc import create_qc_table
1919
20- matplotlib .use ('Agg' )
21-
22- pool_kws = {'maxtasksperchild' : 1 }
23-
24- color_cycle = ["#5790fc" , "#f89c20" , "#e42536" , "#964a8b" , "#9c9ca1" , "#7a21dd" ]
25- plt .rcParams ['axes.prop_cycle' ] = cycler .cycler ('color' , color_cycle )
26- sns .set_palette (sns .color_palette (color_cycle ))
27-
2820
2921def get_wells_list (input_dir , experiment_name ):
3022 regex = re .compile (f"{ experiment_name } -([a-z|A-Z|0-9]*)-([A-Z][0-9][0-9])-after" )
@@ -54,7 +46,6 @@ def run_from_command_line():
5446
5547 description = '' # TODO Describe what this does
5648 parser = argparse .ArgumentParser (description )
57-
5849 parser .add_argument (
5950 'data_directory' , help = 'path to the run_herg_qc results' )
6051 parser .add_argument (
@@ -67,32 +58,27 @@ def run_from_command_line():
6758 parser .add_argument (
6859 '--figsize' , type = int , nargs = 2 , default = (5 , 3 ),
6960 help = 'A figure size, to pass to matplotlib' )
70- parser .add_argument ('--log_level' , default = 'INFO' )
7161 args = parser .parse_args ()
7262
73- # Setup logging
74- logging .basicConfig (level = args .log_level )
75- logger = logging .getLogger (__name__ )
76- logger .setLevel (args .log_level )
77-
7863 run (args .data_directory , args .output_dir , args .experiment_name ,
79- logger , args .Erev , args .figsize )
64+ args .Erev , args .figsize )
8065
8166
82- def run (data_path , output_path , experiment_name , logger ,
83- reversal_potential = None , figsize = None ):
67+ def run (data_path , output_path , experiment_name , reversal_potential = None ,
68+ figsize = None ):
8469 """
8570 Does whatever this does.
8671
8772 @param data_path The path to read data from
8873 @param output_path A root path, will be appended with "summarise_herg_export"
8974 @param experiment_name
90- @param logger
9175 @param reversal_potential The calculated reversal potential, or ``None``
9276 @param figsize The matplotlib figure size, or ``None``.
93-
9477 """
95- output_path = setup_output_directory (output_path , 'summarise_herg_export' )
78+ # TODO: Find some way around setting this
79+ matplotlib .use ('Agg' )
80+
81+ output_path = setup_output_directory (output_path )
9682
9783 leak_parameters_df = pd .read_csv (os .path .join (data_path , 'subtraction_qc.csv' ))
9884
@@ -113,8 +99,6 @@ def run(data_path, output_path, experiment_name, logger,
11399 leak_parameters_df .protocol = ['staircaseramp1_2' if protocol == 'staircaseramp_2' else protocol
114100 for protocol in leak_parameters_df .protocol ]
115101
116- print (leak_parameters_df .protocol .unique ())
117-
118102 with open (os .path .join (data_path , 'passed_wells.txt' )) as fin :
119103 passed_wells = fin .read ().splitlines ()
120104
@@ -138,8 +122,6 @@ def run(data_path, output_path, experiment_name, logger,
138122
139123 leak_parameters_df .sort_values (['protocol' , 'sweep' ], inplace = True )
140124 except FileNotFoundError as exc :
141- logging .warning (str (exc ))
142- logger .warning ('no chronological information provided. Sorting alphabetically' )
143125 leak_parameters_df .sort_values (['protocol' , 'sweep' ])
144126
145127 scatterplot_timescale_E_obs (output_path , leak_parameters_df , passed_wells , figsize )
@@ -171,13 +153,6 @@ def run(data_path, output_path, experiment_name, logger,
171153 # do_scatter_matrices(leak_parameters_df, qc_vals_df, output_path, reversal_potential)
172154 plot_histograms (leak_parameters_df , output_path , reversal_potential , figsize )
173155
174- # Don't work
175- # wells = leak_parameters_df.well.unique()
176- # overlay_reversal_plots(data_path, output_path, experiment_name,
177- # leak_parameters_df, wells, reversal_potential, figsize)
178- # do_combined_plots(data_path, output_path, experiment_name,
179- # leak_parameters_df, passed_wells, logger, figsize)
180-
181156
182157def compute_leak_magnitude (df , lims = [- 120 , 60 ]):
183158 def compute_magnitude (g , E , lims = lims ):
@@ -371,7 +346,7 @@ def label_func(p, s):
371346
372347
373348def do_combined_plots (data_path , output_path , experiment_name ,
374- leak_parameters_df , passed_wells , logger , figsize = None ):
349+ leak_parameters_df , passed_wells , figsize = None ):
375350 """
376351 ???
377352
@@ -380,7 +355,6 @@ def do_combined_plots(data_path, output_path, experiment_name,
380355 @param experiment_name
381356 @param leak_parameters_df
382357 @param passed_wells
383- @param logger
384358 @param figsize
385359
386360 """
@@ -389,8 +363,6 @@ def do_combined_plots(data_path, output_path, experiment_name,
389363
390364 wells = [well for well in leak_parameters_df .well .unique () if well in passed_wells ]
391365
392- logger .info (f"passed wells are { passed_wells } " )
393-
394366 protocol_overlaid_dir = os .path .join (output_path , 'overlaid_by_protocol' )
395367 if not os .path .exists (protocol_overlaid_dir ):
396368 os .makedirs (protocol_overlaid_dir )
@@ -456,8 +428,6 @@ def do_combined_plots(data_path, output_path, experiment_name,
456428 if not os .path .exists (wells_overlaid_dir ):
457429 os .makedirs (wells_overlaid_dir )
458430
459- logger .info ('overlaying traces by well' )
460-
461431 for well in passed_wells :
462432 i = 0
463433 for sweep in leak_parameters_df .sweep .unique ():
@@ -728,6 +698,7 @@ def func(protocol, sweep):
728698 ax = fig .subplots ()
729699 # add black color for NaNs
730700
701+ color_cycle = ["#5790fc" , "#f89c20" ]
731702 cmap = matplotlib .colors .ListedColormap ([color_cycle [0 ], color_cycle [1 ]], 'indexed' )
732703 ax .pcolormesh (zs , edgecolors = 'white' , cmap = cmap ,
733704 linewidths = 1 , antialiased = True )
@@ -776,6 +747,7 @@ def plot_spatial_passed(df, output_path, passed_wells):
776747
777748 zs = np .array (zs ).reshape (16 , 24 )
778749
750+ color_cycle = ["#5790fc" , "#f89c20" ]
779751 cmap = matplotlib .colors .ListedColormap ([color_cycle [0 ], color_cycle [1 ]], 'indexed' )
780752 _ = ax .pcolormesh (zs , edgecolors = 'white' ,
781753 linewidths = 1 , antialiased = True , cmap = cmap
0 commit comments