plotting_scripts/plot_gene_or_transcript_length_by_DE.py
def violin_plot(data, colname, mode, ymax, fname):
    """ Plot a violin plot with the length of each read by novelty category"""

    sns.set_context("paper", font_scale=1.3)
    #ax = sns.stripplot(x='transcript_novelty', y='read_length', data=data, color="grey", jitter = True)

    ax = sns.boxplot(x='DE_type', y=colname, data=data, palette = "Blues")
    #add_stat_annotation(ax, data=data, x='DE_type', y=colname,
    #                box_pairs=[("Higher in Illumina", "Higher in PacBio")],
    #                test='Mann-Whitney', text_format='star', loc='outside', verbose=2)

    #ax = sns.violinplot(x='DE_type', y=colname, legend = False,
    #                    data=data,
    #                    #order=cat_order,
    #                    linewidth = 1,
    #                    inner = 'box', cut = 0)

    # Calculate number of obs per group & position labels
    nobs = list(data.groupby("DE_type").size())
    nobs = [str(x) for x in nobs]
    nobs = ["n=" + i for i in nobs]

    # Add it to the plot
    ypos = data.groupby(['DE_type'])[colname].max().dropna().values
    pos = range(len(nobs))
    for tick,label in zip(pos,ax.get_xticklabels()):
        ax.text(pos[tick], ypos[tick] + ypos[tick]*0.1, nobs[tick],
        horizontalalignment='center', size='x-small', color='black', weight='semibold')

    ax.legend().set_visible(False)
    ax.set_yscale("log", basey=10)
    plt.xlabel("")
    plt.ylabel("%s length (nt)" % (mode))
    #ymin = min(data.groupby(['transcript_novelty'])['read_length'].min().values)
    #plt.ylim(0, max(ypos)*1.1)
    plt.tight_layout()
    plt.savefig(fname, dpi = 600, bbox_inches='tight')
    plt.close()
 Plot a violin plot with the length of each read by novelty category
Plot a violin plot with the length of each read by novelty category
Plot a violin plot with the length of each read by novelty category
def violin_plot(data, colname, mode, ymax, fname):
    sns.set_context("paper", font_scale=1.3)
    ax = sns.boxplot(x='DE_type', y=colname, data=data, palette = "Blues")
    nobs = list(data.groupby("DE_type").size())
    nobs = [str(x) for x in nobs]
    nobs = ["n=" + i for i in nobs]
    ypos = data.groupby(['DE_type'])[colname].max().dropna().values
    pos = range(len(nobs))
    for tick,label in zip(pos,ax.get_xticklabels()):
        ax.text(pos[tick], ypos[tick] + ypos[tick]*0.1, nobs[tick],
        horizontalalignment='center', size='x-small', color='black', weight='semibold')
    ax.legend().set_visible(False)
    ax.set_yscale("log", basey=10)
    plt.xlabel("")
    plt.ylabel("%s length (nt)" % (mode))
    plt.tight_layout()
    plt.savefig(fname, dpi = 600, bbox_inches='tight')
    plt.close()
def violin_plot ( data , colname , mode , ymax , fname ) : sns . set_context ( "paper" , font_scale = 1.3 ) ax = sns . boxplot ( x = 'DE_type' , y = colname , data = data , palette = "Blues" ) nobs = list ( data . groupby ( "DE_type" ) . size ( ) ) nobs = [ str ( x ) for x in nobs ] nobs = [ "n=" + i for i in nobs ] ypos = data . groupby ( [ 'DE_type' ] ) [ colname ] . max ( ) . dropna ( ) . values pos = range ( len ( nobs ) ) for tick , label in zip ( pos , ax . get_xticklabels ( ) ) : ax . text ( pos [ tick ] , ypos [ tick ] + ypos [ tick ] * 0.1 , nobs [ tick ] , horizontalalignment = 'center' , size = 'x-small' , color = 'black' , weight = 'semibold' ) ax . legend ( ) . set_visible ( False ) ax . set_yscale ( "log" , basey = 10 ) plt . xlabel ( "" ) plt . ylabel ( "%s length (nt)" % ( mode ) ) plt . tight_layout ( ) plt . savefig ( fname , dpi = 600 , bbox_inches = 'tight' ) plt . close ( )
Plot a violin plot with the length of each read by novelty category
Plot a violin plot with the length of each read by novelty category
""" Plot a violin plot with the length of each read by novelty category""" #ax = sns.stripplot(x='transcript_novelty', y='read_length', data=data, color="grey", jitter = True) #add_stat_annotation(ax, data=data, x='DE_type', y=colname, #                box_pairs=[("Higher in Illumina", "Higher in PacBio")], #                test='Mann-Whitney', text_format='star', loc='outside', verbose=2) #ax = sns.violinplot(x='DE_type', y=colname, legend = False, #                    data=data, #                    #order=cat_order, #                    linewidth = 1, #                    inner = 'box', cut = 0) # Calculate number of obs per group & position labels # Add it to the plot #ymin = min(data.groupby(['transcript_novelty'])['read_length'].min().values) #plt.ylim(0, max(ypos)*1.1)
data
colname
mode
ymax
fname