diff --git a/deeptools/parserCommon.py b/deeptools/parserCommon.py index fc47217564..310a21bab9 100755 --- a/deeptools/parserCommon.py +++ b/deeptools/parserCommon.py @@ -704,15 +704,17 @@ def heatmapperOptionalArgs(mode=['heatmap', 'profile'][0]): default=None, help='Minimum value for the heatmap intensities. Multiple values, separated by ' 'spaces can be set for each heatmap. If the number of zMin values is smaller than' - 'the number of heatmaps the values are recycled.', - type=float, + 'the number of heatmaps the values are recycled. If a value is set to "auto", it will be set ' + ' to the first percentile of the matrix values.', + type=str, nargs='+') optional.add_argument('--zMax', '-max', default=None, help='Maximum value for the heatmap intensities. Multiple values, separated by ' 'spaces can be set for each heatmap. If the number of zMax values is smaller than' - 'the number of heatmaps the values are recycled.', - type=float, + 'the number of heatmaps the values are recycled. If a value is set to "auto", it will be set ' + ' to the 98th percentile of the matrix values.', + type=str, nargs='+') optional.add_argument('--heatmapHeight', help='Plot height in cm. The default for the heatmap ' diff --git a/deeptools/plotHeatmap.py b/deeptools/plotHeatmap.py index f477fc6891..aee0a6280e 100644 --- a/deeptools/plotHeatmap.py +++ b/deeptools/plotHeatmap.py @@ -412,6 +412,16 @@ def plotMatrix(hm, outFileName, zMin = [None] else: zMin = [zMin] # convert to list to support multiple entries + elif 'auto' in zMin: + matrix_flatten = hm.matrix.flatten() + auto_min = np.percentile(matrix_flatten, 1.0) + if np.isnan(auto_min): + auto_min = None + new_mins = [float(x) if x != 'auto' else auto_min for x in zMin] + zMin = new_mins + else: + new_mins = [float(x) for x in zMin] + zMin = new_mins if zMax is None: if matrix_flatten is None: @@ -422,6 +432,23 @@ def plotMatrix(hm, outFileName, zMax = [None] else: zMax = [zMax] + elif 'auto' in zMax: + matrix_flatten = hm.matrix.flatten() + auto_max = np.percentile(matrix_flatten, 98.0) + if np.isnan(auto_max): + auto_max = None + new_maxs = [float(x) if x != 'auto' else auto_max for x in zMax] + zMax = new_maxs + else: + new_maxs = [float(x) for x in zMax] + zMax = new_maxs + if (len(zMin) > 1) & (len(zMax) > 1): + for index, value in enumerate(zMax): + if value <= zMin[index]: + sys.stderr.write("Warnirng: In bigwig {}, the given zmin ({}) is larger than " + "or equal to the given zmax ({}). Thus, it has been set " + "to None. \n".format(index + 1, zMin[index], value)) + zMin[index] = None if yMin is None: yMin = [None] diff --git a/galaxy/wrapper/plotPCA.xml b/galaxy/wrapper/plotPCA.xml index 1bfaacd774..ebf5905cc6 100644 --- a/galaxy/wrapper/plotPCA.xml +++ b/galaxy/wrapper/plotPCA.xml @@ -78,7 +78,7 @@ - +