def make_plots(background_color, label_color, rares, ymax, xmax, output_dir, resolution, imagetype, groups, colors, data_colors, metric_name, labelname, rarefaction_data_mat, rarefaction_legend_mat, sample_dict, sample_data_colors, sample_colors, mapping_lookup, output_type='file_creation', generate_per_sample_plots=True):
 raredata = rares
 file_path = os.path.join(output_dir, splitext(split(raredata['headers'][0])[1])[0])
 all_plots_single = []
 for i in natsort(groups):
  for j in range(len(raredata['xaxis'])):
   group_field = i
   seq_per_sample_field = int(raredata['xaxis'][j])
   color_field = data_colors[colors[group_field]].toHex()
   try:
    average_field = raredata['series'][i][j]
    error_field = raredata['error'][i][j]
    if isnan(average_field):
     error_field = nan
   except:
    average_field = nan
    error_field = nan
   if (i in rarefaction_data_mat[labelname]):
    if (metric_name in rarefaction_data_mat[labelname][i]):
     rarefaction_data_mat[labelname][i][metric_name]['ave'].append(''.join(('%10.3f' % raredata['series'][i][j])))
     rarefaction_data_mat[labelname][i][metric_name]['err'].append(''.join(('%10.3f' % raredata['error'][i][j])))
    else:
     rarefaction_data_mat[labelname][i][metric_name] = {}
     rarefaction_data_mat[labelname][i][metric_name]['ave'] = []
     rarefaction_data_mat[labelname][i][metric_name]['err'] = []
     rarefaction_data_mat[labelname][i][metric_name]['ave'].append(''.join(('%10.3f' % raredata['series'][i][j])))
     rarefaction_data_mat[labelname][i][metric_name]['err'].append(''.join(('%10.3f' % raredata['error'][i][j])))
   else:
    rarefaction_data_mat[labelname][i] = {}
    rarefaction_data_mat[labelname][i][metric_name] = {}
    rarefaction_data_mat[labelname][i][metric_name]['ave'] = []
    rarefaction_data_mat[labelname][i][metric_name]['err'] = []
    rarefaction_data_mat[labelname][i][metric_name]['ave'].append(''.join(('%10.3f' % raredata['series'][i][j])))
    rarefaction_data_mat[labelname][i][metric_name]['err'].append(''.join(('%10.3f' % raredata['error'][i][j])))
  if generate_per_sample_plots:
   if (output_type == 'file_creation'):
    rarefaction_legend_mat = save_single_rarefaction_plots(sample_dict, imagetype, metric_name, sample_data_colors, sample_colors, output_dir, background_color, label_color, resolution, ymax, xmax, rarefaction_legend_mat, groups[i], labelname, i, mapping_lookup, output_type)
   elif (output_type == 'memory'):
    (rarefaction_legend_mat, rare_plot_for_all) = save_single_rarefaction_plots(sample_dict, imagetype, metric_name, sample_data_colors, sample_colors, output_dir, background_color, label_color, resolution, ymax, xmax, rarefaction_legend_mat, groups[i], labelname, i, mapping_lookup, output_type)
    all_plots_single.append(rare_plot_for_all)
 all_plots_ave = {}
 if generate_per_sample_plots:
  categories = [k for k in groups]
  if (output_type == 'file_creation'):
   rarefaction_legend_mat = save_single_ave_rarefaction_plots(raredata['xaxis'], raredata['series'], raredata['error'], xmax, ymax, categories, labelname, imagetype, resolution, data_colors, colors, file_path, background_color, label_color, rarefaction_legend_mat, metric_name, mapping_lookup, output_type)
  elif (output_type == 'memory'):
   (rarefaction_legend_mat, all_plots_ave) = save_single_ave_rarefaction_plots(raredata['xaxis'], raredata['series'], raredata['error'], xmax, ymax, categories, labelname, imagetype, resolution, data_colors, colors, file_path, background_color, label_color, rarefaction_legend_mat, metric_name, mapping_lookup, output_type)
 if (output_type == 'file_creation'):
  return (rarefaction_data_mat, rarefaction_legend_mat)
 elif (output_type == 'memory'):
  return (rarefaction_data_mat, rarefaction_legend_mat, all_plots_single, all_plots_ave)

def make_plots ( background_color , label_color , rares , ymax , xmax , output_dir , resolution , imagetype , groups , colors , data_colors , metric_name , labelname , rarefaction_data_mat , rarefaction_legend_mat , sample_dict , sample_data_colors , sample_colors , mapping_lookup , output_type = 'file_creation' , generate_per_sample_plots = True ) : raredata = rares file_path = os . path . join ( output_dir , splitext ( split ( raredata [ 'headers' ] [ 0 ] ) [ 1 ] ) [ 0 ] ) all_plots_single = [ ] for i in natsort ( groups ) : for j in range ( len ( raredata [ 'xaxis' ] ) ) : group_field = i seq_per_sample_field = int ( raredata [ 'xaxis' ] [ j ] ) color_field = data_colors [ colors [ group_field ] ] . toHex ( ) try : average_field = raredata [ 'series' ] [ i ] [ j ] error_field = raredata [ 'error' ] [ i ] [ j ] if isnan ( average_field ) : error_field = nan except : average_field = nan error_field = nan if ( i in rarefaction_data_mat [ labelname ] ) : if ( metric_name in rarefaction_data_mat [ labelname ] [ i ] ) : rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'ave' ] . append ( '' . join ( ( '%10.3f' % raredata [ 'series' ] [ i ] [ j ] ) ) ) rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'err' ] . append ( '' . join ( ( '%10.3f' % raredata [ 'error' ] [ i ] [ j ] ) ) ) else : rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] = { } rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'ave' ] = [ ] rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'err' ] = [ ] rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'ave' ] . append ( '' . join ( ( '%10.3f' % raredata [ 'series' ] [ i ] [ j ] ) ) ) rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'err' ] . append ( '' . join ( ( '%10.3f' % raredata [ 'error' ] [ i ] [ j ] ) ) ) else : rarefaction_data_mat [ labelname ] [ i ] = { } rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] = { } rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'ave' ] = [ ] rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'err' ] = [ ] rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'ave' ] . append ( '' . join ( ( '%10.3f' % raredata [ 'series' ] [ i ] [ j ] ) ) ) rarefaction_data_mat [ labelname ] [ i ] [ metric_name ] [ 'err' ] . append ( '' . join ( ( '%10.3f' % raredata [ 'error' ] [ i ] [ j ] ) ) ) if generate_per_sample_plots : if ( output_type == 'file_creation' ) : rarefaction_legend_mat = save_single_rarefaction_plots ( sample_dict , imagetype , metric_name , sample_data_colors , sample_colors , output_dir , background_color , label_color , resolution , ymax , xmax , rarefaction_legend_mat , groups [ i ] , labelname , i , mapping_lookup , output_type ) elif ( output_type == 'memory' ) : ( rarefaction_legend_mat , rare_plot_for_all ) = save_single_rarefaction_plots ( sample_dict , imagetype , metric_name , sample_data_colors , sample_colors , output_dir , background_color , label_color , resolution , ymax , xmax , rarefaction_legend_mat , groups [ i ] , labelname , i , mapping_lookup , output_type ) all_plots_single . append ( rare_plot_for_all ) all_plots_ave = { } if generate_per_sample_plots : categories = [ k for k in groups ] if ( output_type == 'file_creation' ) : rarefaction_legend_mat = save_single_ave_rarefaction_plots ( raredata [ 'xaxis' ] , raredata [ 'series' ] , raredata [ 'error' ] , xmax , ymax , categories , labelname , imagetype , resolution , data_colors , colors , file_path , background_color , label_color , rarefaction_legend_mat , metric_name , mapping_lookup , output_type ) elif ( output_type == 'memory' ) : ( rarefaction_legend_mat , all_plots_ave ) = save_single_ave_rarefaction_plots ( raredata [ 'xaxis' ] , raredata [ 'series' ] , raredata [ 'error' ] , xmax , ymax , categories , labelname , imagetype , resolution , data_colors , colors , file_path , background_color , label_color , rarefaction_legend_mat , metric_name , mapping_lookup , output_type ) if ( output_type == 'file_creation' ) : return ( rarefaction_data_mat , rarefaction_legend_mat ) elif ( output_type == 'memory' ) : return ( rarefaction_data_mat , rarefaction_legend_mat , all_plots_single , all_plots_ave )
load the results from filename .