Python pylab.tick_params() Examples

The following are 4 code examples of pylab.tick_params(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pylab , or try the search function .
Example #1
Source File: plot_mh_analysis.py    From SelfTarget with MIT License 6 votes vote down vote up
def compareMHlines(all_result_outputs, label='', y_axis = 'Percent Non-Null Reads', data_label='RegrLines'):

    color_map = {'K562':'b','K562_1600x':'lightblue', 'BOB':'g', 'RPE1':'purple', 'TREX2':'k', 'TREX2_2A':'gray', 'HAP1':'r', 'E14TG2A':'orange','eCAS9':'c', 'WT':'pink', 'CHO':'salmon'}
    lysty_map = {2:'--',3:'--',5:'--',7:'-',10:'-.',16:':',20:':'}

    dirnames = [x[1] for x in all_result_outputs]
    lystys = [lysty_map[parseSampleName(x)[1]] for x in dirnames]
    clrs = [color_map[parseSampleName(x)[0]] for x in dirnames]

    for mh_len in [9]:
        PL.figure()
        regr_lines = [x[0][data_label][mh_len] for x in all_result_outputs]
        for dirname, regr_line,lysty,clr in zip(dirnames,regr_lines,lystys, clrs):
            PL.plot(regr_line[0], regr_line[1], label='%s (R=%.1f)' % (getSimpleName(dirname), regr_line[2]), linewidth=2, color=clr, linestyle=lysty, alpha=0.5 )
        PL.xlabel('Distance between nearest ends of microhomologous sequences',fontsize=14)
        PL.ylabel('Corresponding microhomology-mediated deletion\n as percent of total mutated reads',fontsize=14)
        PL.tick_params(labelsize=16)
        PL.legend(loc='upper right')
        PL.ylim((0,70))
        PL.xlim((0,20))
        PL.xticks(range(0,21,5))
        PL.title('Microhomology Length %d' % mh_len,fontsize=18)
        PL.show(block=False)  
        saveFig('mh_regr_lines_all_samples__%d' % mh_len) 
Example #2
Source File: plot_mh_analysis.py    From SelfTarget with MIT License 6 votes vote down vote up
def compareMHK562lines(all_result_outputs, label='', y_axis = 'Percent Non-Null Reads', data_label='RegrLines'):

    dirnames = [x[1] for x in all_result_outputs]
    clrs = ['silver','grey','darkgreen','green','lightgreen','royalblue','dodgerblue','skyblue','mediumpurple','orchid','red','orange','salmon']

    fig = PL.figure(figsize=(6,6))
    leg_handles = []
    mh_lens = [3,4,5,6,7,8,9,10,11,12,13,14,15]
    for mh_len, clr in zip(mh_lens,clrs):
        regr_lines = [x[0][data_label][mh_len] for x in all_result_outputs]
        mean_line = np.mean([x[:2] for x in regr_lines], axis=0)
        leg_handles.append(PL.plot(mean_line[0], mean_line[1], label='MH Len=%d  (R=%.1f)' % (mh_len,np.mean([x[2] for x in regr_lines])) , linewidth=2, color=clr )[0])
    PL.xlabel('Distance between nearest ends of\nmicrohomologous sequences',fontsize=16)
    PL.ylabel('Correspondng microhomology-mediated deletion\n as percent of total mutated reads',fontsize=16)
    PL.tick_params(labelsize=16)
    PL.legend(handles=[x for x in reversed(leg_handles)], loc='upper right')
    PL.ylim((0,80))
    PL.xlim((0,20))
    PL.xticks(range(0,21,5))
    PL.show(block=False)  
    saveFig('mh_regr_lines_K562') 
Example #3
Source File: plotting.py    From webvectors with GNU General Public License v3.0 5 votes vote down vote up
def embed(words, matrix, classes, usermodel, fname):
    perplexity = int(len(words) ** 0.5)  # We set perplexity to a square root of the words number
    embedding = TSNE(n_components=2, perplexity=perplexity, metric='cosine', n_iter=500, init='pca')
    y = embedding.fit_transform(matrix)

    print('2-d embedding finished', file=sys.stderr)

    class_set = [c for c in set(classes)]
    colors = plot.cm.rainbow(np.linspace(0, 1, len(class_set)))

    class2color = [colors[class_set.index(w)] for w in classes]

    xpositions = y[:, 0]
    ypositions = y[:, 1]
    seen = set()

    plot.clf()

    for color, word, class_label, x, y in zip(class2color, words, classes, xpositions, ypositions):
        plot.scatter(x, y, 20, marker='.', color=color,
                     label=class_label if class_label not in seen else "")
        seen.add(class_label)

        lemma = word.split('_')[0].replace('::', ' ')
        mid = len(lemma) / 2
        mid *= 4  # TODO Should really think about how to adapt this variable to the real plot size
        plot.annotate(lemma, xy=(x - mid, y), size='x-large', weight='bold', fontproperties=font,
                      color=color)

    plot.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
    plot.tick_params(axis='y', which='both', left=False, right=False, labelleft=False)
    plot.legend(loc='best')

    plot.savefig(root + 'data/images/tsneplots/' + usermodel + '_' + fname + '.png', dpi=150,
                 bbox_inches='tight')
    plot.close()
    plot.clf() 
Example #4
Source File: plot_mh_analysis.py    From SelfTarget with MIT License 4 votes vote down vote up
def plotPercScatterAnalysis(data, label='test', y_axis = 'Percent Non-Null Reads', plot_scatters=False, plot_regr_lines=False, scatter_mh_lens=[], mh_lens=[9]):
    
    plot_dir = getPlotDir()
    regr_lines = {}
    for mh_len in mh_lens:
        mh_data = data.loc[data['MH Len'] == mh_len]
        mh_rdata = mh_data.loc[(mh_data['MH Dist'] >= 0) & (mh_data['MH Dist'] < (30-mh_len)) ]
        
        regr = linear_model.LinearRegression()
        rx, ry = mh_rdata[['MH Dist']], mh_rdata[[y_axis]] #np.log(mh_rdata[[y_axis]])
        regr.fit(rx, ry)
        corr = scipy.stats.pearsonr(rx, ry)
        min_x, max_x = rx.min()[0], rx.max()[0]
        x_pts = [min_x, max_x]
        regr_lines[mh_len] = (x_pts,[regr.predict(x)[0] for x in x_pts],corr[0])
        
        if plot_scatters and mh_len in scatter_mh_lens:
            fig = PL.figure(figsize=(5,5))
            PL.plot( mh_data['MH Dist'], mh_data[y_axis], '.', alpha=0.4 )
            PL.plot(regr_lines[mh_len][0],regr_lines[mh_len][1],'dodgerblue',linewidth=3)
        
            PL.xlabel('Distance between nearest ends of\nmicrohomologous sequences',fontsize=14)
            PL.ylabel('Percent of mutated reads of corresponding\nMH-mediated deletion',fontsize=14)
            PL.tick_params(labelsize=14)
            PL.xlim((0,20))
            PL.title('Microhomology of length %d (r=%.2f)' % (mh_len,corr[0]),fontsize=14)
            PL.show(block=False)  
            saveFig('mh_scatter_len%d_%s' % (mh_len,label.split('/')[-1])) 
    
    if plot_regr_lines:
        fig = PL.figure()
        output_data = {}
        for mh_len in mh_lens:
            fit_data = regr_lines[mh_len]
            if mh_len > 15:
                continue
            lsty = '--' if mh_len < 9 else '-'
            PL.plot(fit_data[0], fit_data[1], linewidth=2, linestyle=lsty, label='MH length %d (R=%.1f)' % (mh_len, fit_data[2]))
        PL.title(label,fontsize=18)
        PL.xlabel('Distance between nearest ends of\nmicrohomologous sequences',fontsize=14)
        PL.ylabel('Percent of mutated reads of corresponding\nMH-mediated deletion',fontsize=14)
          
        PL.tick_params(labelsize=18)
        PL.legend()
        PL.ylim((0,100))
        PL.show(block=False)  
        saveFig(plot_dir + '/mh_scatter_all_len_%s' % label.split('/')[-1]) 
    return regr_lines