Skip to content
Permalink
Browse files

Fix plotting bugs

  • Loading branch information...
rcalandrelli committed Apr 8, 2019
1 parent 3342439 commit 938991e35a9eda4c53cdfb3bd9bbd19f13e18f6f
Showing with 29 additions and 25 deletions.
  1. BIN .DS_Store
  2. +13 −15 scripts/HiCtool_full_map_analysis.py
  3. +16 −10 scripts/HiCtool_yaffe_tanay.py
BIN +0 Bytes (100%) .DS_Store
Binary file not shown.
@@ -718,7 +718,7 @@ def plot_map(input_matrix,
k = 0 # to consider the pixel occupied by the grid added after
for i in chromosomes_list:
d_chr_label_pos[i] = d_chr_dim_inc[i] - d_chr_dim[i]/2 + k
k+=1
k+=2

label_pos = []
label_name = []
@@ -773,22 +773,20 @@ def plot_map(input_matrix,
if cutoff_type == 'perc':
perc = np.percentile(output_vect[non_zero[0]],cutoff)
plt.imshow(matrix_data_full, cmap=my_cmap, interpolation='nearest', vmax=perc , vmin=0)
plt.title(data_type + ' contact map (' + bin_size_str + ')', fontsize=14)
cbar = plt.colorbar(extend='max')
cbar.cmap.set_over(max_color)
elif cutoff_type == 'contact':
perc = cutoff
plt.imshow(matrix_data_full, cmap=my_cmap, interpolation='nearest', vmax=perc , vmin=0)
plt.title(data_type + ' contact map (' + bin_size_str + ')', fontsize=14)
cbar = plt.colorbar(extend='max')
cbar.cmap.set_over(max_color)
elif cutoff_type == 'None':
plt.imshow(matrix_data_full, cmap=my_cmap, interpolation='nearest', vmin=0)
plt.title(data_type + ' contact map (' + bin_size_str + ')', fontsize=14)
cbar = plt.colorbar()

cbar.cmap.set_under('black')
cbar.ax.set_ylabel(data_type + ' contact counts', rotation=270, labelpad=20)
plt.title(data_type + ' contact map (' + bin_size_str + ')', fontsize=12)
plt.xticks(label_pos, label_name, rotation='vertical', fontsize = 6)
plt.yticks(label_pos, label_name, fontsize = 6)
plt.tick_params(axis='both', which='both', length=0)
@@ -814,10 +812,7 @@ def plot_map(input_matrix,
else:
matrix_data_full = copy.deepcopy(input_matrix)

print "Plotting..."
row = np.shape(matrix_data_full)[0]
col = np.shape(matrix_data_full)[1]

print "Plotting..."
chromosome_row = 'chr' + chr_row
chromosome_col = 'chr' + chr_col

@@ -884,8 +879,9 @@ def plot_map(input_matrix,
return

matrix_data_full = matrix_data_full[chr_row_bin[0]:chr_row_bin[1]+1,chr_col_bin[0]:chr_col_bin[1]+1]
row = np.shape(matrix_data_full)[0]
col = np.shape(matrix_data_full)[1]

row = np.shape(matrix_data_full)[0]
col = np.shape(matrix_data_full)[1]

output_vect = np.reshape(matrix_data_full,row*col,1)
non_zero = np.nonzero(output_vect)
@@ -901,6 +897,7 @@ def format_e(n):

plt.close("all")
plt.gcf().subplots_adjust(left=0.15)
plt.gcf().subplots_adjust(bottom=0.15)

if cutoff_type == 'perc':
perc = np.percentile(output_vect[non_zero[0]],cutoff)
@@ -933,10 +930,10 @@ def format_e(n):
cbar = plt.colorbar()
cbar.cmap.set_under(domain_color)

plt.title(data_type + ' contact map (' + bin_size_str + ')', fontsize=14)
plt.title(data_type + ' contact map (' + bin_size_str + ')', fontsize=12)
cbar.ax.set_ylabel(data_type + ' contact counts', rotation=270, labelpad=20)
plt.ylabel(chromosome_row + ' coordinate (bp)', fontsize=12)
plt.xlabel(chromosome_col + ' coordinate (bp)', fontsize=12)
plt.ylabel(chromosome_row + ' coordinate (bp)', fontsize=10)
plt.xlabel(chromosome_col + ' coordinate (bp)', fontsize=10)
if len(chr_row_coord) == 2 and len(chr_col_coord) == 2:
ticks_row = (np.arange(0, row, row/4) * bin_size) + chr_row_coord[0]
ticks_col = (np.arange(0, col, col/4) * bin_size) + chr_col_coord[0]
@@ -951,8 +948,9 @@ def format_e(n):
format_ticks_col = [format_e(i) for i in ticks_col.tolist()]
plt.yticks(np.arange(0, row, row/4), format_ticks_row)
plt.xticks(np.arange(0, col, col/4), format_ticks_col)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.tick_params(axis='both', which='both', direction='out', top=False, right=False)
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.savefig(my_filename + '.pdf', format = 'pdf', dpi=my_dpi)

# Plot of the histogram
@@ -455,6 +455,8 @@ def format_e(n):
return

plt.close("all")
#plt.gcf().subplots_adjust(left=0.15)
#plt.gcf().subplots_adjust(bottom=0.15)
if cutoff_type == 'None':
if topological_domains == '':
plt.imshow(matrix_data_full, cmap=my_cmap, interpolation='nearest')
@@ -475,16 +477,17 @@ def format_e(n):
cbar.cmap.set_over(max_color)
cbar.cmap.set_under(domain_color)

plt.title(data_type + ' contact map (' + my_bin_size + ')', fontsize=14)
plt.xlabel(chromosome + ' coordinate (bp)', fontsize=12)
plt.ylabel(chromosome + ' coordinate (bp)', fontsize=12)
plt.title(data_type + ' contact map (' + my_bin_size + ')', fontsize=12)
plt.xlabel(chromosome + ' coordinate (bp)', fontsize=10)
plt.ylabel(chromosome + ' coordinate (bp)', fontsize=10)
cbar.ax.set_ylabel(data_type + ' contact counts', rotation=270, labelpad=20)
ticks = (np.arange(0, n, n/4) * bin_size) + start_coord
format_ticks = [format_e(i) for i in ticks.tolist()]
plt.xticks(np.arange(0, n, n/4), format_ticks)
plt.yticks(np.arange(0, n, n/4), format_ticks)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.tick_params(axis='both', which='both', direction='out', top=False, right=False)
plt.tight_layout()
plt.savefig(output_filename + '.pdf', format = 'pdf', dpi=my_dpi)

@@ -786,11 +789,13 @@ def format_e(n):
my_bin_size = bin_size_str + ' kb'

plt.close("all")
#plt.gcf().subplots_adjust(left=0.15)
#plt.gcf().subplots_adjust(bottom=0.15)
norm = MidPointNorm(midpoint=0)
plt.imshow(matrix_data_full, cmap='seismic', interpolation='nearest', vmax=threshold_max, vmin=threshold_min, norm=norm)
plt.title('O/E contact map (' + my_bin_size + ')', fontsize=14)
plt.xlabel(chromosome + ' coordinate (bp)', fontsize=12)
plt.ylabel(chromosome + ' coordinate (bp)', fontsize=12)
plt.title('O/E contact map (' + my_bin_size + ')', fontsize=12)
plt.xlabel(chromosome + ' coordinate (bp)', fontsize=10)
plt.ylabel(chromosome + ' coordinate (bp)', fontsize=10)
cbar = plt.colorbar()
cbar.cmap.set_over('black') # loci where expected enrich values are zero (log not existing)
cbar.cmap.set_under('gray') # loci where observed values are zero (log equal to minus infinity)
@@ -799,8 +804,9 @@ def format_e(n):
format_ticks = [format_e(i) for i in ticks.tolist()]
plt.xticks(np.arange(0, n, n/4), format_ticks)
plt.yticks(np.arange(0, n, n/4), format_ticks)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.tick_params(axis='both', which='both', direction='out', top=False, right=False)
plt.tight_layout()
plt.savefig(output_filename + '.pdf', format = 'pdf', dpi = my_dpi)

0 comments on commit 938991e

Please sign in to comment.
You can’t perform that action at this time.