(data,
              data_type='bits',
              seq_type='dna',
              yaxis='bits',
              colorscheme='classic',
              nrow=1,
              ncol=1,
              padding=0,
              draw_range=None,
              coordinate_type='data',
              draw_axis=False,
              fontfamily='Arial',
              debug=False,
              ax=None)
return fig, axarr
Draw sequence logo

    Parameters
    ----------

    data : str or dict or matrix

    data_type : str
        Options : 'msa', 'meme', 'jaspar', 'counts', 'pwm', 'pfm', 'ic'

    yaxis : str
        Type of plot. Options : 'probability', 'bits'

    colorscheme : str
        Colorschemes. Options for DNA : basepairing/classic.
                      AA : hydrophobicity, chemistry

    nrow : int
        Total nrows in column. This doesn't work with 'data' type dict

    ncol : int
        Total nrows in column. This doesn't work with 'data' type dict
Draw sequence logo
Draw sequence logo
def draw_logo(data,
              data_type='bits',
              seq_type='dna',
              yaxis='bits',
              colorscheme='classic',
              nrow=1,
              ncol=1,
              padding=0,
              draw_range=None,
              coordinate_type='data',
              draw_axis=False,
              fontfamily='Arial',
              debug=False,
              ax=None):
    """Draw sequence logo

    Parameters
    ----------

    data : str or dict or matrix

    data_type : str
        Options : 'msa', 'meme', 'jaspar', 'counts', 'pwm', 'pfm', 'ic'

    yaxis : str
        Type of plot. Options : 'probability', 'bits'

    colorscheme : str
        Colorschemes. Options for DNA : basepairing/classic.
                      AA : hydrophobicity, chemistry

    nrow : int
        Total nrows in column. This doesn't work with 'data' type dict

    ncol : int
        Total nrows in column. This doesn't work with 'data' type dict

    """
    if yaxis not in ['probability', 'bits']:
        sys.stderr.write(
            'yaxis can be {}, got {}\n'.format(['probability', 'bits'], yaxis))
        sys.exit(1)
    if not ax:
        fig, axarr = plt.subplots(nrow, ncol, squeeze=False)
        fig.set_size_inches(((len(data) + 1) * ncol, 3 * nrow))
        ax = axarr[0, 0]
    else:
        fig = ax.get_figure()
        axarr = np.array([[ax]])
        ax.set_xticks(list(range(1, len(data) + 1)))

        ax.set_xticklabels(list(range(1, len(data) + 1)), rotation=90)
        pfm, ic = process_data(data, data_type=data_type, seq_type=seq_type)
        if yaxis == 'probability':
            xshifts_list = _draw_text_data_coord(
                pfm, ax, fontfamily, colorscheme, draw_axis=draw_axis)
        else:
            xshifts_list = _draw_text_data_coord(
                ic, ax, fontfamily, colorscheme, draw_axis=draw_axis)
        #ax.axis('off')
        #despine(
        #    ax=ax,
        #    trim=False,
        #    top=True,
        #    right=True,
        #    bottom=True,
        #    offset=0)
        return

    #ax.set_xticks(range(1, len(data) + 1))
    if draw_axis:
        ax.set_xticks(list(range(len(data))))
        if yaxis == 'probability':
            ax.set_yticks(list(range(0, 2)))
        elif yaxis == 'bits':
            ax.set_yticks(list(range(0, 3)))

        #ax.set_xticklabels(range(1, len(data) + 1), rotation=90)
        setup_axis(ax, 'y', majorticks=1, minorticks=0.1)
    else:
        ax.axis('off')

    if data_type != 'bits':
        pfm, ic = process_data(data, data_type=data_type, seq_type=seq_type)
    else:
        ic = data
        pfm = data

    if draw_range:
        #    ic = np.array(ic)
        ic = ic[draw_range[0]:draw_range[1]]
        pfm = pfm[draw_range[0]:draw_range[1]]
    if coordinate_type == 'data':
        ax = axarr[0, 0]
        ax.set_xticks(list(range(1, len(data) + 1)))

        ax.set_xticklabels(list(range(1, len(data) + 1)), rotation=90)
        if yaxis == 'probability':
            xshifts_list = _draw_text_data_coord(
                pfm, ax, fontfamily, colorscheme, draw_axis=draw_axis)
        else:
            xshifts_list = _draw_text_data_coord(
                ic, ax, fontfamily, colorscheme, draw_axis=draw_axis)
    else:
        if yaxis == 'probability':
            xshifts_list = _draw_text_display_coord(
                pfm, ax, fontfamily, colorscheme, draw_axis=draw_axis)
        else:
            xshifts_list = _draw_text_display_coord(
                ic, ax, fontfamily, colorscheme, draw_axis=draw_axis)

    for i in range(nrow):
        for j in range(ncol):
            if i == j == 0:
                despine(
                    ax=axarr[i, j],
                    trim=False,
                    top=True,
                    right=True,
                    bottom=True)
                continue
            despine(
                ax=axarr[i, j],
                trim=False,
                top=True,
                right=True,
                bottom=True,
                offset=00)
            axi = axarr[i, j]
            #axi.get_shared_x_axes().join(axi, ax)
            #axi.set_xticklabels([])
            #ax.set_xticklabels(range(1, len(data) + 1), rotation=90)
    return fig, axarr
def draw_logo ( data , data_type = 'bits' , seq_type = 'dna' , yaxis = 'bits' , colorscheme = 'classic' , nrow = 1 , ncol = 1 , padding = 0 , draw_range = None , coordinate_type = 'data' , draw_axis = False , fontfamily = 'Arial' , debug = False , ax = None ) : if yaxis not in [ 'probability' , 'bits' ] : sys . stderr . write ( 'yaxis can be {}, got {}\n' . format ( [ 'probability' , 'bits' ] , yaxis ) ) sys . exit ( 1 ) if not ax : fig , axarr = plt . subplots ( nrow , ncol , squeeze = False ) fig . set_size_inches ( ( ( len ( data ) + 1 ) * ncol , 3 * nrow ) ) ax = axarr [ 0 , 0 ] else : fig = ax . get_figure ( ) axarr = np . array ( [ [ ax ] ] ) ax . set_xticks ( list ( range ( 1 , len ( data ) + 1 ) ) ) ax . set_xticklabels ( list ( range ( 1 , len ( data ) + 1 ) ) , rotation = 90 ) pfm , ic = process_data ( data , data_type = data_type , seq_type = seq_type ) if yaxis == 'probability' : xshifts_list = _draw_text_data_coord ( pfm , ax , fontfamily , colorscheme , draw_axis = draw_axis ) else : xshifts_list = _draw_text_data_coord ( ic , ax , fontfamily , colorscheme , draw_axis = draw_axis ) #ax.axis('off') #despine( #    ax=ax, #    trim=False, #    top=True, #    right=True, #    bottom=True, #    offset=0) return #ax.set_xticks(range(1, len(data) + 1)) if draw_axis : ax . set_xticks ( list ( range ( len ( data ) ) ) ) if yaxis == 'probability' : ax . set_yticks ( list ( range ( 0 , 2 ) ) ) elif yaxis == 'bits' : ax . set_yticks ( list ( range ( 0 , 3 ) ) ) #ax.set_xticklabels(range(1, len(data) + 1), rotation=90) setup_axis ( ax , 'y' , majorticks = 1 , minorticks = 0.1 ) else : ax . axis ( 'off' ) if data_type != 'bits' : pfm , ic = process_data ( data , data_type = data_type , seq_type = seq_type ) else : ic = data pfm = data if draw_range : #    ic = np.array(ic) ic = ic [ draw_range [ 0 ] : draw_range [ 1 ] ] pfm = pfm [ draw_range [ 0 ] : draw_range [ 1 ] ] if coordinate_type == 'data' : ax = axarr [ 0 , 0 ] ax . set_xticks ( list ( range ( 1 , len ( data ) + 1 ) ) ) ax . set_xticklabels ( list ( range ( 1 , len ( data ) + 1 ) ) , rotation = 90 ) if yaxis == 'probability' : xshifts_list = _draw_text_data_coord ( pfm , ax , fontfamily , colorscheme , draw_axis = draw_axis ) else : xshifts_list = _draw_text_data_coord ( ic , ax , fontfamily , colorscheme , draw_axis = draw_axis ) else : if yaxis == 'probability' : xshifts_list = _draw_text_display_coord ( pfm , ax , fontfamily , colorscheme , draw_axis = draw_axis ) else : xshifts_list = _draw_text_display_coord ( ic , ax , fontfamily , colorscheme , draw_axis = draw_axis ) for i in range ( nrow ) : for j in range ( ncol ) : if i == j == 0 : despine ( ax = axarr [ i , j ] , trim = False , top = True , right = True , bottom = True ) continue despine ( ax = axarr [ i , j ] , trim = False , top = True , right = True , bottom = True , offset = 00 ) axi = axarr [ i , j ] #axi.get_shared_x_axes().join(axi, ax) #axi.set_xticklabels([]) #ax.set_xticklabels(range(1, len(data) + 1), rotation=90) return fig , axarr