Skip to content

Commit

Permalink
updated cmp usage to fit the recent mpl updates. (#1001)
Browse files Browse the repository at this point in the history
* updated cmp usage to fit the recent mpl updates.

* updated the requirements.txt
  • Loading branch information
LeilyR authored Sep 18, 2020
1 parent f773fdf commit ec2a730
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion deeptools/correlation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import itertools
import copy
import numpy as np
import scipy.cluster.hierarchy as sch
import scipy.stats
Expand Down Expand Up @@ -291,7 +292,7 @@ def plot_correlation(self, plot_filename, plot_title='', vmax=None,
link_color_func=lambda k: 'darkred')
axdendro.set_xticks([])
axdendro.set_yticks([])
cmap = plt.get_cmap(colormap)
cmap = copy.copy(plt.get_cmap(colormap))

# this line simply makes a new cmap, based on the original
# colormap that goes from 0.0 to 0.9
Expand Down
3 changes: 2 additions & 1 deletion deeptools/correlation_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import scipy.cluster.hierarchy as sch
from matplotlib import rcParams
import matplotlib.colors as pltcolors
import copy

rcParams['pdf.fonttype'] = 42
rcParams['svg.fonttype'] = 'none'
Expand Down Expand Up @@ -43,7 +44,7 @@ def plot_correlation(corr_matrix, labels, plotFileName, vmax=None,
link_color_func=lambda k: 'darkred')
axdendro.set_xticks([])
axdendro.set_yticks([])
cmap = plt.get_cmap(colormap)
cmap = copy.copy(plt.get_cmap(colormap))

# this line simply makes a new cmap, based on the original
# colormap that goes from 0.0 to 0.9
Expand Down
14 changes: 7 additions & 7 deletions deeptools/plotHeatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
matplotlib.use('Agg')
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['svg.fonttype'] = 'none'
from deeptools import cm # noqa: F401
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import matplotlib.gridspec as gridspec
from matplotlib import ticker

import copy
import sys
import plotly.offline as py
import plotly.graph_objs as go

# own modules
from deeptools import cm # noqa: F401
from deeptools import parserCommon
from deeptools import heatmapper
from deeptools.heatmapper_utilities import plot_single, plotly_single
Expand Down Expand Up @@ -477,7 +477,8 @@ def plotMatrix(hm, outFileName,
if colorMapDict['colorMap']:
cmap = []
for color_map in colorMapDict['colorMap']:
cmap.append(plt.get_cmap(color_map))
copy_cmp = copy.copy(plt.get_cmap(color_map))
cmap.append(copy_cmp)
cmap[-1].set_bad(colorMapDict['missingDataColor']) # nans are printed using this color

if colorMapDict['colorList'] and len(colorMapDict['colorList']) > 0:
Expand Down Expand Up @@ -529,7 +530,6 @@ def plotMatrix(hm, outFileName,
else:
color_list = cmap_plot(np.arange(numgroups) / numgroups)
alpha = colorMapDict['alpha']

if image_format == 'plotly':
return plotlyMatrix(hm,
outFileName,
Expand Down Expand Up @@ -735,7 +735,7 @@ def plotMatrix(hm, outFileName,
col = sample
ax = fig.add_subplot(grids[-1, col])
tick_locator = ticker.MaxNLocator(nbins=3)
cbar = fig.colorbar(img, cax=ax, alpha=alpha, orientation='horizontal', ticks=tick_locator)
cbar = fig.colorbar(img, cax=ax, orientation='horizontal', ticks=tick_locator)
labels = cbar.ax.get_xticklabels()
ticks = cbar.ax.get_xticks()
if ticks[0] == 0:
Expand All @@ -759,15 +759,15 @@ def plotMatrix(hm, outFileName,
grid_start = 0

ax = fig.add_subplot(grids[grid_start:, -1])
fig.colorbar(img, cax=ax, alpha=alpha)
fig.colorbar(img, cax=ax)

if box_around_heatmaps:
plt.subplots_adjust(wspace=0.10, hspace=0.025, top=0.85, bottom=0, left=0.04, right=0.96)
else:
# When no box is plotted the space between heatmaps is reduced
plt.subplots_adjust(wspace=0.05, hspace=0.01, top=0.85, bottom=0, left=0.04, right=0.96)

plt.savefig(outFileName, bbox_inches='tight', pdd_inches=0, dpi=dpi, format=image_format)
plt.savefig(outFileName, bbox_inches='tight', pad_inches=0.1, dpi=dpi, format=image_format)
plt.close()


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy>=1.9.0
scipy>=0.17.0
matplotlib>=3.1.0
matplotlib>=3.3.0
pysam>=0.14.0
py2bit>=0.2.0
numpydoc>=0.5
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def openREADME():
install_requires=[
"numpy >= 1.9.0",
"scipy >= 0.17.0",
"matplotlib >= 3.1.0",
"matplotlib >= 3.3.0",
"pysam >= 0.14.0",
"numpydoc >= 0.5",
"pyBigWig >= 0.2.1",
Expand Down

0 comments on commit ec2a730

Please sign in to comment.