Skip to content

Commit

Permalink
Merge pull request #111 from lldelisle/useAlphaMoreBroadly
Browse files Browse the repository at this point in the history
Use alpha more broadly
  • Loading branch information
bgruening authored Oct 24, 2019
2 parents 42e4815 + 55c8356 commit 55e41d2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
39 changes: 37 additions & 2 deletions pygenometracks/tests/test_data/alpha.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
file = bigwig2_X_2.5e6_3.5e6.bw
color = blue
height = 7
title = (bigwig color=blue 2000 bins) overlayed with (bigwig mean color=red alpha = 0.5 max over 300 bins) overlayed with (bigwig mean color=red alpha=0.5 200 bins)
title = (bigwig color=blue 2000 bins) overlayed with (bigwig color=red alpha = 0.5 max over 300 bins) overlayed with (bigwig mean color=green alpha=0.5 200 bins)
number of bins = 2000
min_value = 0
max_value = 30

[test bigwig max]
file = bigwig2_X_2.5e6_3.5e6.bw
Expand All @@ -29,8 +31,10 @@ overlay previous = share-y
file = bigwig2_X_2.5e6_3.5e6.bw
color = blue
height = 7
title = (bigwig color=blue 2000 bins) overlayed with (bigwig mean color=redmax over 300 bins) overlayed with (bigwig mean color=red 200 bins)
title = (bigwig color=blue 2000 bins) overlayed with (bigwig color=red max over 300 bins) overlayed with (bigwig mean color=green 200 bins)
number of bins = 2000
min_value = 0
max_value = 30

[test bigwig max]
file = bigwig2_X_2.5e6_3.5e6.bw
Expand All @@ -46,5 +50,36 @@ type = fill
number of bins = 200
overlay previous = share-y

[spacer]

[test bigwig]
file = bigwig2_X_2.5e6_3.5e6.bw
height = 7
title = (bigwig color=red alpha = 0.5 max) overlayed with (bigwig mean color=green alpha=0.5 line:2) overlayed with (bigwig min color=blue alpha=0.5 points:2)
color = red
color = red
alpha = 0.5
summary method = max
number of bins = 300
min_value = 0
max_value = 30

[test bigwig mean]
file = bigwig2_X_2.5e6_3.5e6.bw
color = green
type = line:2
alpha = 0.5
summary method = mean
number of bins = 300
overlay previous = share-y

[test bigwig min]
file = bigwig2_X_2.5e6_3.5e6.bw
color = blue
summary method = min
number of bins = 1000
type = points:3
alpha = 0.5
overlay previous = share-y

[x-axis]
Binary file modified pygenometracks/tests/test_data/master_alpha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions pygenometracks/tracks/BedGraphTrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,23 @@ def plot(self, ax, chrom_region, start_region, end_region):
else:
if self.plot_type == 'line':
if self.properties['color'] == self.properties['negative color']:
ax.plot(x_values, score_list, '-', linewidth=self.size, color=self.properties['color'])
ax.plot(x_values, score_list, '-', linewidth=self.size, color=self.properties['color'], alpha=self.properties['alpha'])
else:
import warnings
warnings.warn('Line plots with a different negative color might not look pretty')
pos_x_values = x_values.copy()
pos_x_values[score_list < 0] = np.nan
ax.plot(pos_x_values, score_list, '-', linewidth=self.size, color=self.properties['color'])
ax.plot(pos_x_values, score_list, '-', linewidth=self.size, color=self.properties['color'], alpha=self.properties['alpha'])

neg_x_values = x_values.copy()
neg_x_values[score_list >= 0] = np.nan
ax.plot(neg_x_values, score_list, '-', linewidth=self.size, color=self.properties['negative color'])
ax.plot(neg_x_values, score_list, '-', linewidth=self.size, color=self.properties['negative color'], alpha=self.properties['alpha'])

elif self.plot_type == 'points':
ax.plot(x_values[score_list >= 0], score_list[score_list >= 0], '.',
markersize=self.size, color=self.properties['color'])
markersize=self.size, color=self.properties['color'], alpha=self.properties['alpha'])
ax.plot(x_values[score_list < 0], score_list[score_list < 0], '.',
markersize=self.size, color=self.properties['negative color'])
markersize=self.size, color=self.properties['negative color'], alpha=self.properties['alpha'])

else:
ax.fill_between(x_values, score_list, linewidth=0.1, color=self.properties['color'],
Expand Down
16 changes: 10 additions & 6 deletions pygenometracks/tracks/BigWigTrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,28 @@ def plot(self, ax, chrom_region, start_region, end_region):
x_values = np.linspace(start_region, end_region, num_bins)
if self.plot_type == 'line':
if self.properties['color'] == self.properties['negative color']:
ax.plot(x_values, scores_per_bin, '-', linewidth=self.size, color=self.properties['color'])
ax.plot(x_values, scores_per_bin, '-', linewidth=self.size,
color=self.properties['color'], alpha=self.properties['alpha'])
else:
import warnings
warnings.warn('Line plots with a different negative color might not look pretty')
pos_x_values = x_values.copy()
pos_x_values[scores_per_bin < 0] = np.nan
ax.plot(pos_x_values, scores_per_bin, '-', linewidth=self.size, color=self.properties['color'])
ax.plot(pos_x_values, scores_per_bin, '-', linewidth=self.size,
color=self.properties['color'], alpha=self.properties['alpha'])

neg_x_values = x_values.copy()
neg_x_values[scores_per_bin >= 0] = np.nan
ax.plot(neg_x_values, scores_per_bin, '-', linewidth=self.size, color=self.properties['negative color'])
ax.plot(neg_x_values, scores_per_bin, '-', linewidth=self.size,
color=self.properties['color'], alpha=self.properties['alpha'])

elif self.plot_type == 'points':
ax.plot(x_values[scores_per_bin >= 0], scores_per_bin[scores_per_bin >= 0], '.',
markersize=self.size, color=self.properties['color'])
markersize=self.size, color=self.properties['color'],
alpha=self.properties['alpha'])
ax.plot(x_values[scores_per_bin < 0], scores_per_bin[scores_per_bin < 0], '.',
markersize=self.size, color=self.properties['negative color'])

markersize=self.size, color=self.properties['negative color'],
alpha=self.properties['alpha'])
else:
ax.fill_between(x_values, scores_per_bin, linewidth=0.1, color=self.properties['color'],
facecolor=self.properties['color'], where=scores_per_bin >= 0, interpolate=True,
Expand Down

0 comments on commit 55e41d2

Please sign in to comment.