def new_descriptor_performance_plot(fig, max_overview, selection, method, glomeruli=[], descriptor_plot_type='scatterplot'): """compare performance of different descriptors for several glomeruli""" desc_names = max_overview[method][selection]['desc_names'] if 'p_selection' in max_overview[method][selection] and \ np.sum(max_overview[method][selection]['p_selection']) != 0.0: print('plotting param selection instead of maximum') data = max_overview[method][selection]['p_selection'] else: data = max_overview[method][selection]['max'] # use only selected glomeruli avail_glomeruli = max_overview[method][selection]['glomeruli'] if glomeruli: glom_idx = [i for i, g in enumerate(avail_glomeruli) if g in glomeruli] data = data[:, glom_idx] # compute colors to color all glomeruli according to their all performance all_idx = max_overview[method][selection]['desc_names'].index('all') all_values = data[all_idx] n_val = float(len(all_values)-1) clist_all = [sorted(all_values,reverse=True).index(i) / n_val for i in all_values] ax = fig.add_subplot(111) if descriptor_plot_type == 'boxplot': _descriptor_boxplot(ax, data, desc_names) elif descriptor_plot_type == 'scatterplot': _descriptor_scatterplot(ax, data, clist_all, desc_names) elif descriptor_plot_type == 'curveplot': _descriptor_curveplot(ax, data, desc_names) if i_meth == 1: ax.legend(prop={'size':5}) elif descriptor_plot_type == 'violinplot': _violin_boxplot(ax, data, desc_names) else: assert False utils.simple_axis(ax) ax.set_ylabel('q2 score')
ax.plot(comp_score, ref_score, 'x', color='0.0', markersize=3) plt.axis('scaled') ax.annotate(example_receptor, xy=(comp_score, ref_score), xytext=(0.65, 0.465), arrowprops=dict(facecolor='black', shrink=0.2, width=1, frac=0.2, headwidth=3)) ax.text(0.55, 0.75, 'r:{:.2f}'.format(stats.pearsonr(col_comp, col_ref)[0])) print stats.pearsonr(col_comp, col_ref) ax.set_yticks(xticks) ax.set_yticklabels(xticklabels) ax.set_xticks(xticks) ax.set_xticklabels(xticklabels) ax.set_xlim([-0.05, 0.9]) ax.set_ylim([-0.05, 0.9]) ax.set_xlabel('comparison descriptor (q2)') ax.set_ylabel('ALL (q2)') ax.legend(loc='lower right', numpoints=1, frameon=False, fancybox=True, prop={'size': 'small'}) utils.simple_axis(ax) ax.text(-0.3,0.85, 'A)', fontsize=9, weight='bold') ax = fig.add_subplot(1,2,2) ax.plot([-0.1, 0.8], [-0.1, 0.8], color='0.6') ref_predictions = res[reference][example_receptor]['predictions'] comp_predictions = res[comparison_desc][example_receptor]['predictions'] ax.plot(ref_predictions, comp_predictions, 'kx', color='0.3', markeredgecolor='0.3', markersize=2, label=example_receptor) plt.axis('scaled') ax.set_yticks(xticks) ax.set_yticklabels(xticklabels) ax.set_xticks(xticks) ax.set_xticklabels(xticklabels)