Mercurial > repos > glogobyte > isoread
diff mirgene_graphs.py @ 17:0cdc0c3c821e draft
Uploaded
author | glogobyte |
---|---|
date | Wed, 20 Oct 2021 08:44:20 +0000 |
parents | d58f050acd18 |
children | 01679b6e886a |
line wrap: on
line diff
--- a/mirgene_graphs.py Wed Oct 20 08:43:37 2021 +0000 +++ b/mirgene_graphs.py Wed Oct 20 08:44:20 2021 +0000 @@ -81,23 +81,23 @@ fig = plt.figure(figsize=(7,5)) - labels = 'miRNA RefSeq','Template', 'Unassigned' ,'Non-template' + labels = 'miRNA RefSeq','templated', 'unassigned' ,'non-templated' sizes = [c_mat_counts, c_tem_counts, c_unmap_counts,c_non_counts] colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue'] # Plot ax1 = plt.subplot2grid((1,2),(0,0)) patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8) - [x.set_fontsize(8) for x in texts] - plt.title(group_name1 + ' Group (reads)',fontsize=12) + [x.set_fontsize(10) for x in texts] + plt.title(group_name1.capitalize() + ' group (reads)',fontsize=12) - labels = 'miRNA RefSeq','Template', 'Unassigned','non-template' + labels = 'miRNA RefSeq','templated', 'unassigned','non-templated' sizes = [t_mat_counts, t_tem_counts, t_unmap_counts, t_non_counts] colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue'] # Plot ax2 = plt.subplot2grid((1,2),(0,1)) patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8) - [x.set_fontsize(8) for x in texts] - plt.title(group_name2 + ' Group (reads)', fontsize=12) + [x.set_fontsize(10) for x in texts] + plt.title(group_name2.capitalize() + ' group (reads)', fontsize=12) plt.savefig('pie_non.png',dpi=300) #################################################################################################################################################################################################################### @@ -160,24 +160,24 @@ fig = plt.figure() - labels = 'miRNA RefSeq','Template', 'Unassigned' + labels = 'miRNA RefSeq','templated', 'unassigned' sizes = [c_mat_counts, c_tem_counts, c_unmap_counts] colors = ['gold', 'yellowgreen', 'lightskyblue'] explode = (0.2, 0.05, 0.1) # Plot ax1 = plt.subplot2grid((1,2),(0,0)) patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8) - [x.set_fontsize(8) for x in texts] - plt.title(group_name1 + ' group (reads)', fontsize=12) - labels = 'miRNA RefSeq','Template', 'Unassigned' + [x.set_fontsize(10) for x in texts] + plt.title(group_name1.capitalize() + ' group (reads)', fontsize=12) + labels = 'miRNA RefSeq','templated', 'Unassigned' sizes = [t_mat_counts, t_tem_counts, t_unmap_counts] colors = ['gold', 'yellowgreen', 'lightskyblue'] explode = (0.2, 0.05, 0.1) # Plot ax2 = plt.subplot2grid((1,2),(0,1)) patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8) - [x.set_fontsize(8) for x in texts] - plt.title(group_name2 + ' group (reads)',fontsize = 12) + [x.set_fontsize(10) for x in texts] + plt.title(group_name2.capitalize() + ' group (reads)',fontsize = 12) plt.savefig('pie_tem.png',dpi=300) ################################################################################################################################################################################################################### @@ -336,20 +336,20 @@ radar_max_counts = max(c_5_counts,c_3_counts,c_both_counts,c_mat_counts,c_exception_counts,t_5_counts,t_3_counts,t_both_counts,t_mat_counts,t_exception_counts) df=pd.DataFrame({ - 'group':[group_name1,group_name2], + 'group':[group_name1.capitalize(),group_name2.capitalize()], """5'3'-isomiRs""":[c_both,t_both], """3'-isomiRs""":[c_3,t_3], 'RefSeq miRNA':[c_mature,t_mature], """5'-isomiRs""":[c_5,t_5], - 'Others*':[c_exception,t_exception]}) + 'others*':[c_exception,t_exception]}) df1=pd.DataFrame({ - 'group':[group_name1,group_name2], + 'group':[group_name1.capitalize(),group_name2.capitalize()], """5'-3'-isomiRs""":[c_both_counts,t_both_counts], """3'-isomiRs""":[c_3_counts,t_3_counts], 'RefSeq miRNA':[c_mat_counts,t_mat_counts], """5'-isomiRs""":[c_5_counts,t_5_counts], - 'Others*':[c_exception_counts,t_exception_counts]}) + 'others*':[c_exception_counts,t_exception_counts]}) spider_last(df,radar_max,1,group_name1,group_name2) spider_last(df1,radar_max_counts,2,group_name1,group_name2) @@ -376,14 +376,14 @@ ax.set_theta_direction(-1) # Draw one axe per variable + add labels labels yet - plt.xticks(angles[:-1], categories, fontsize=11) + plt.xticks(angles[:-1], categories, fontsize=13) # Draw ylabels radar_max=round(radar_max+radar_max*0.1) mul=len(str(radar_max))-1 maxi=int(math.ceil(radar_max / pow(10,mul))) * pow(10,mul) sep = round(maxi/4) - plt.yticks([sep, 2*sep, 3*sep, 4*sep, 5*sep], [str(sep)+'%', str(2*sep)+'%', str(3*sep)+'%', str(4*sep)+'%', str(5*sep)+'%'], color="grey", size=10) + plt.yticks([sep, 2*sep, 3*sep, 4*sep, 5*sep], [str(sep)+'%', str(2*sep)+'%', str(3*sep)+'%', str(4*sep)+'%', str(5*sep)+'%'], color="grey", size=12) plt.ylim(0, maxi) # ------- PART 2: Add plots @@ -394,21 +394,21 @@ # Ind1 values=df.loc[0].drop('group').values.flatten().tolist() values += values[:1] - ax.plot(angles, values,'-o', linewidth=1, linestyle='solid', label=group_name1) + ax.plot(angles, values,'-o', linewidth=1, linestyle='solid', label=group_name1.capitalize()) ax.fill(angles, values, 'b', alpha=0.1) # Ind2 values=df.loc[1].drop('group').values.flatten().tolist() values += values[:1] - ax.plot(angles, values, '-o' ,linewidth=1, linestyle='solid', label=group_name2) + ax.plot(angles, values, '-o' ,linewidth=1, linestyle='solid', label=group_name2.capitalize()) ax.fill(angles, values, 'r', alpha=0.1) # Add legend if flag==1: - plt.legend(loc='upper right', bbox_to_anchor=(0.0, 0.1)) + plt.legend(loc='upper right', prop={'size': 11}, bbox_to_anchor=(0.0, 0.1)) plt.savefig('spider_non_red.png',dpi=300) else: - plt.legend(loc='upper right', bbox_to_anchor=(0.0, 0.1)) + plt.legend(loc='upper right', prop={'size': 11}, bbox_to_anchor=(0.0, 0.1)) plt.savefig('spider_red.png',dpi=300) ############################################################################################################################################################################################################# @@ -421,9 +421,9 @@ seq=[] if flag == "c": - title = "Length Distribution of "+group+" group (Redudant reads)" + title = "Length distribution of "+group.lower()+" group (redundant reads)" if flag == "t": - title = "Length Distribution of "+group+" group (Redudant reads)" + title = "Length distribution of "+group.lower()+" group (redundant reads)" for i in samples: for x in i: @@ -492,11 +492,11 @@ def logo_seq_red(merge, flag, group): if flag=="c": - titlos = group + " group (Redundant)" + titlos = group + " group (redundant)" file_logo = "c_logo.png" file_bar = "c_bar.png" if flag=="t": - titlos = group + " group (Redundant)" + titlos = group + " group (redundant)" file_logo = "t_logo.png" file_bar = "t_bar.png" @@ -595,7 +595,7 @@ pdf.set_font('Arial', 'B', 20.0) # Page header - pdf.cell(pdf.w-0.5, 0.5, 'IsomiR Profile Report',align='C') + pdf.cell(pdf.w-0.5, 0.5, 'IsomiR profile report',align='C') pdf.ln(0.7) pdf.set_font('Arial','', 16.0) pdf.cell(pdf.w-0.5, 0.5, 'sRNA length distribution',align='C') @@ -613,10 +613,10 @@ # Image caption pdf.cell(0.2) - pdf.cell(3.0, 0.0, " Mapped and unmapped reads to custom precussor arm reference DB (5p and 3p arms) in "+group_name1) + pdf.cell(3.0, 0.0, " Mapped and unmapped reads to custom precursor arm reference DB (5p and 3p arms) in "+group_name1.lower()) pdf.ln(0.2) pdf.cell(0.2) - pdf.cell(3.0, 0.0, " (left) and "+group_name2+" (right) groups") + pdf.cell(3.0, 0.0, " (left) and "+group_name2.lower()+" (right) groups") pdf.ln(0.5) @@ -635,13 +635,13 @@ pdf.cell(3.0, 0.0, " RefSeq miRNAs, templated isomiRs, non-templated isomiRs and unassigned sequences as percentage") pdf.ln(0.2) pdf.cell(0.2) - pdf.cell(3.0, 0.0, " of total sRNA reads in "+group_name1+" (left) and "+group_name2+" (right) groups") + pdf.cell(3.0, 0.0, " of total sRNA reads in "+group_name1.lower()+" (left) and "+group_name2.lower()+" (right) groups") else: pdf.cell(3.0, 0.0, " RefSeq miRNAS, Templated isomiRs and unassigned sequences as percentage of total sRNA reads in") pdf.ln(0.2) pdf.cell(0.2) - pdf.cell(3.0, 0.0, " "+group_name1+" (left) and "+group_name2+" (right) groups") + pdf.cell(3.0, 0.0, " "+group_name1.lower()+" (left) and "+group_name2.lower()+" (right) groups") pdf.add_page() pdf.set_font('Arial', 'B', 18.0)