Пример #1
0
def label_ys(labels):
    import plotting as pl
    ax = pl.gca()
    bottoms = [YSCALE*i for i in range(len(labels))]
    for b in bottoms: pl.axhline(y=b, linewidth=.5, color='gray')
    ax.axes.set_yticks([b+YSCALE/2 for b in bottoms])
    ax.axes.set_yticklabels(labels)
    ax.axes.yaxis.set_ticks_position('none')
Пример #2
0
def label_xs(lefts, labels):
    import plotting as pl
    # Draw bars separating fractionations. Were in the wrong place before
    # moving to the left by one.
    for left in lefts[1:]:
        pl.axvline(x=left-1, linewidth=.5, color='gray')
    ax = pl.gca()
    # Center x-axis labels
    ax.axes.set_xticks([int((lefts[i]+lefts[i+1])/2) for i in
        range(len(lefts)-1)])
    ax.axes.xaxis.set_ticks_position('none')
    ax.axes.set_xticklabels(labels, fontsize=10)
    labels = ax.get_xticklabels() 
    for label in labels: 
        label.set_rotation(35) 
    [i.set_linewidth(0.5) for i in ax.spines.itervalues()]
Пример #3
0
def cluster_ids(gids, unnorm_eluts, sp, gt=None, dist='cosine', do_plot=True,
        norm_rows=True, bigarr=None, **kwargs):
    import plotting as pl
    import hcluster
    arr = (bigarr if bigarr is not None else single_array(gids, unnorm_eluts,
        sp, norm_rows=norm_rows))
    ymat = hcluster.pdist(arr, metric=dist)
    zmat = hcluster.linkage(ymat)
    zmat = np.clip(zmat, 0, 10**8)
    if do_plot: pl.figure()
    order = hcluster.dendrogram(zmat, no_plot=bool(1-do_plot), 
            **kwargs)['leaves']
    if do_plot: 
        ax = pl.gca()
        ax.axes.set_xticklabels([gt.id2name[gids[ind]] for ind in order])
        pl.figure() 
        pl.imshow(arr[order,:])
    return list(np.array(list(gids))[order])