deeptools / pyGenomeTracks

python module to plot beautiful and highly customizable genome browser tracks
GNU General Public License v3.0
758 stars 111 forks source link

using two identical bedgraph files with max_value set to different values does not work #468

Open yonniejon opened 9 months ago

yonniejon commented 9 months ago

First of all, great tool.

pyGenomeTracks --version python --version pyGenomeTracks 3.8 Python 3.10.12

When I have a configuration file with one bed graph with max_value set to auto I get the following image:

[x-axis]
[spacer]
height = 0.5
[bg2]
file = issue.bw
title = count
height = 2
#overlay_previous = yes
color = orange
min_value = 0
number_of_bins = 1000
nans_to_zeros = true
summary_method = mean
show_data_range = true
grid = true
file_type = bigwig

pyGenomeTracks --tracks issue.one_file.ini --region chr1:50000000-100000000 -o issue.one_file.png --dpi 130 issue one_file

However, I want to set a max value of 10 and then add magenta to the top indicating that the peak goes above the max value.

So I use two bedgraphs coming from the same file, the first one with max_value set to something higher than 10 and the second one with max_value set to 10 and over_previous set to true:

[x-axis]
[spacer]
height = 0.5
[bg1]
file = issue.bw
title = count
height = 2
#overlay_previous = yes
color = magenta
min_value = 0
max_value = 15
number_of_bins = 1000
nans_to_zeros = true
summary_method = mean
show_data_range = false
file_type = bigwig

[bg2]
file = issue.bw
title = count
height = 2
overlay_previous = share-y
color = orange
min_value = 0
max_value = 10
number_of_bins = 1000
nans_to_zeros = true
summary_method = mean
show_data_range = true
grid = true
file_type = bigwig

pyGenomeTracks --tracks issue.ini --region chr1:50000000-100000000 -o issue.png --dpi 130 and then there are two bugs: issue

The first is that the first bed graph does not go above the max_value 10 even though it has a max_value set to 15. The second bug is that the two tracks should be identical, with orange overlaying the magenta. There should not be any magenta at all unless the height of the track is above 10.

If I am missing something and this is not a bug, I would like to know.

Thank you for the great tool!

yonniejon commented 9 months ago

Also, there is a bug I think when I do share-y the y-axis label uses the max value of the overlayed track even though the actual value is the original track's max_value.

lldelisle commented 8 months ago

Hi, The logic of overlaying track is not easy to catch as the one of min_value max_value. With the ini file you provided, the software.

  1. Create a track space of 2cm (height = 2 in the [bg1]).
  2. Plots in magenta the bigwig and fix the plotting value (y axis) to 0-15
  3. As you put overlay_previous = share-y, the second [bg2] instructions are plotted into the same 2cm track space. So it plots in orange using the same y-axis as the first track (share-y) and at the end it put the plotting value of the track space (so impact both the magenta and the orange) to 0-10.

pyGenomeTracks only display data, do not 'modify' them so it cannot 'cut'.

If I understand well what you want, you should not overlay them. I would do:

[x-axis]
[spacer]
height = 0.5
[bg1]
file = issue.bw
height = 0.2
color = magenta
min_value = 10
max_value = 15
number_of_bins = 1000
nans_to_zeros = true
summary_method = mean
show_data_range = false
file_type = bigwig

[bg2]
file = issue.bw
title = count
height = 2
color = orange
min_value = 0
max_value = 10
number_of_bins = 1000
nans_to_zeros = true
summary_method = mean
show_data_range = true
grid = true
file_type = bigwig

Tell me if it is clearer for you and if this works.