Skip to content

Commit

Permalink
Merge pull request #22 from mmiladi/v1.2.1
Browse files Browse the repository at this point in the history
V1.2.1
  • Loading branch information
mmiladi authored Mar 11, 2020
2 parents c9b4ad8 + 2a54c34 commit a499cf4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
20 changes: 10 additions & 10 deletions bin/MutaRNA-plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ def plot_up_dict(up_dic, plot_lims=None, title='XX', fig=None, diff=False,tidy=F
ticks_label_step = 50
ticks_step = 10

minor_ticks = np.arange(min(x), max(x), 1)
minor_ticks = np.arange(min(x), max(x), 10)
major_ticks = np.arange(min(x)-min(x)%ticks_step, max(x), ticks_step)

ax.set_xticks(minor_ticks, minor=True)
#ax.set_xticks(minor_ticks, minor=True)
ax.set_xticks(major_ticks)


Expand All @@ -310,11 +310,11 @@ def plot_up_dict(up_dic, plot_lims=None, title='XX', fig=None, diff=False,tidy=F
# ax.grid(which='both')

# or if you want different settings for the grids:
ax.grid(which='minor', alpha=0.5)
ax.grid(which='major', axis='x', alpha=0.5)
ax.axhline(0)

if mutation_pos is not None:
ax.axvline(mutation_pos-0.5, color='r', alpha=0.5)
ax.axvline(mutation_pos, color='r', alpha=0.3, linestyle='--')
# ax.axhline(0, linestyle='--', color='k', alpha=0.5) # horizontal lines
# ax.axhline(1, linestyle='--', color='k', alpha=0.5) # horizontal lines

Expand All @@ -331,11 +331,11 @@ def plot_up_dict(up_dic, plot_lims=None, title='XX', fig=None, diff=False,tidy=F



if ticks_label_step != ticks_step:
labels = [item.get_text() for item in ax.get_xticklabels()]
labels_locs = ax.get_xticks()
pruned_labels = [str(loc) if ((loc%ticks_label_step)==0 and loc!=0) else '' for loc, lab in zip(labels_locs, labels)]
ax.set_xticklabels(pruned_labels)
#if ticks_label_step != ticks_step:
labels = [item.get_text() for item in ax.get_xticklabels()]
labels_locs = ax.get_xticks()
pruned_labels = [str(loc) if ((loc%ticks_label_step)==0 and loc!=0) else '' for loc, lab in zip(labels_locs, labels)]
ax.set_xticklabels(pruned_labels)



Expand Down Expand Up @@ -559,7 +559,7 @@ def plot_circos_seq_SNP(rec_wild, SNP_tag, rec_mut, do_local=True,do_global=Fals
#ldp.plot_heat_maps(None, ldp.parse_dp_ps(dpintroduce), filename=ID+'-INTRODUCED', title_suffix=ID+'-INTRODUCED', what='basepairs',inverse=True, out_dir=out_dir)

ldp.plot_heat_maps(None, ldp.parse_dp_ps(dp_wild)+ldp.parse_dp_ps(dp_mut).transpose(), filename=ID+'-WT-MUT', what='basepairs',
inverse=True, interactive=False, gene_loc=None,title_suffix=ID+'-'+SNP_tag+'\n'r'$P({\rm WT})$, $P({\rm mutant})$', out_dir=out_dir, upper_triangle_txt='wt',lower_triangle_txt='mut', mutation_pos=snp_loc)
inverse=True, interactive=False, gene_loc=None,title_suffix=ID+'-'+SNP_tag+'\n'r'$P({\rm WT})$, $P({\rm mutant})$', out_dir=out_dir, upper_triangle_txt='WT',lower_triangle_txt='MUT', mutation_pos=snp_loc)

ldp.plot_heat_maps(None, ldp.parse_dp_ps(dpremove)+ldp.parse_dp_ps(dpintroduce).transpose(), filename=ID+'-REMOVED-INTRODUCED', what='basepairs',
inverse=True, interactive=False, gene_loc=None,title_suffix=ID+'\n'+r'$|\Delta| = |P({\rm WT})-P({\rm mutant})|$', out_dir=out_dir, upper_triangle_txt='weakened\n' + r' $\Delta>0$',lower_triangle_txt='increased\n' + r' $\Delta<0$', mutation_pos=snp_loc)
Expand Down
38 changes: 23 additions & 15 deletions lib/local_dotplot/local_dotplot_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,38 +257,46 @@ def my_heatmap(mat, fig, ax, title='', vmin=1e-2,vmax=1.0, inverse=True, interac
# plt.colorbar(heatmap)

ax.set_title(title)
incrementticks = np.arange(0, mat.shape[0], 1)
incrementticks = np.arange(0, mat.shape[0], 10)-1
ax.set_xticks(incrementticks)
ax.set_yticks(incrementticks)

ticks = np.arange(0, mat.shape[0], 10)
#ax.set_xticks(ticks-0.5, minor=True)
#ax.set_yticks(ticks-0.5, minor=True)
# ax.grid(True, which='minor',color='gray',linewidth=0.0001 )
ax.grid(False, which='major') # ,color='gray',linewidth=0.001 )
# ax.gca().patch.set_facecolor('0.8')
# ax.tick_params(length=0,
# axis='both', # changes apply to the x-axis
# which='major', # both major and minor ticks are affected
# bottom='off', # ticks along the bottom edge are off
# top='off', # ticks along the top edge are off
# labelbottom='off')

ticks = np.arange(0, mat.shape[0], 50)-1
ax.set_xticks(ticks, minor=True)
ax.set_yticks(ticks, minor=True)
ax.grid(True, which='minor' ,color='gray',linewidth=0.05,alpha=0.3 )

# ax.grid(True, which='minor',color='gray',linewidth=0.0001 )
# ax.gca().patch.set_facecolor('0.8')

prune_labels = True
ticks_label_step = 10
if seq_len > 101:
ticks_label_step = 50
if prune_labels == True:
labels = [item.get_text() for item in ax.get_xticklabels()]
labels_locs = ax.get_xticks()
pruned_labels = [str(loc) if ((loc%ticks_label_step)==0 and loc!=0) else '' for loc, lab in zip(labels_locs, labels)]
pruned_labels = [str(int(loc+1)) if (((loc+1)%ticks_label_step)==0 and (loc+0.5)!=0) else '' for loc, lab in zip(labels_locs, labels)]
ax.set_xticklabels(pruned_labels)
# ax.set_xticks = [l-0.5 for l in labels_locs]

labels = [item.get_text() for item in ax.get_yticklabels()]
labels_locs = ax.get_yticks()
pruned_labels = [str(loc) if ((loc%ticks_label_step)==0 and loc!=0) else '' for loc, lab in zip(labels_locs, labels)]
pruned_labels = [str(int(loc+1)) if (((loc+1)%ticks_label_step)==0 and (loc+0.5)!=0) else '' for loc, lab in zip(labels_locs, labels)]
ax.set_yticklabels(pruned_labels)
# ax.set_yticks = [l-0.5 for l in labels_locs]

ax.tick_params(#length=0,
axis='both', # changes apply to the x-axis
which='major', # both major and minor ticks are affected
bottom=True, # ticks along the bottom edge are off
top=True, # ticks along the top edge are off
right=True,
labelbottom=True,
labeltop=False,
)

ax.set_xlim((-0.5, seq_len-0.5))
# ax.set_ylim((-0.5,seq_len-0.5))
ax.set_ylim((seq_len-0.5, -0.5))
Expand Down

0 comments on commit a499cf4

Please sign in to comment.