lczech / grenedalf

Toolkit for Population Genetic Statistics from Pool-Sequenced Samples, e.g., in Evolve and Resequence experiments
GNU General Public License v3.0
35 stars 2 forks source link

Error: Svg axis label position out of [ 0.0, 1.0 ] #23

Closed peterdfields closed 5 months ago

peterdfields commented 5 months ago

I'm trying to make a cathedral plot on a couple of different chromosomes. A subset are creating the following error:

Plotting cathedral-plot-scaffold_6.csv
Error: Svg axis label position out of [ 0.0, 1.0 ]

terminate called after throwing an instance of 'std::runtime_error'
  what():  Svg axis label position out of [ 0.0, 1.0 ]
Aborted (core dumped)

I have tried using the --clip and --min, --max flags but am still getting the same error message. Please let me know if any additional information would be helpful.

lczech commented 5 months ago

Hey @peterdfields,

hm interesting. Could you maybe share the csv and json file that produce this error? Otherwise it's hard to replicate this for me. I guess it's just a small numerical issue, but I'd need to investigate.

Cheers and so long Lucas

peterdfields commented 5 months ago

Hi @lczech. You can use the following link to download the csv and json file for one of the molecules creating the error: https://www.dropbox.com/t/dcjz63RgXBxVKlo2. Thank you again for your help!

lczech commented 5 months ago

Hi @peterdfields,

yep, it was just a too narrow check - the issue was a value of 1.00000000000000022... I've now relaxed that a bit, and it works with your test data, thanks for that, and thanks for reporting this!

The main branch contains the fix now, if you want to compile yourself already. Otherwise, this will be in release v0.5.2.

Cheers Lucas

lczech commented 5 months ago

Oh also, looking at the result from your plot:

Screenshot from 2024-06-18 23-47-24

I've run this with --clip-under --min-value -0.01, as there were quite some negative values in the plot that were hiding the actually interesting part. There is a patch of pure yellow around position 7.5e7, which consists of clipped negative values < 0.1. I assume that this is because of small pool sizes? Quite interesting :-)

peterdfields commented 5 months ago

@lczech Thank you for the fix! I'll pull the repo and try the new binaries on the other scaffolds this evening with the suggested values. The pool size is definitely on the small size. On a related note, how are you rendering the plot as the one you've linked to? Are you just converting the svg to png from the standard output? My plots definitely do not look this nice in preview :(

lczech commented 5 months ago

Okay, the release is now processed and published, see here.

As for:

try the new binaries on the other scaffolds this evening with the suggested values.

Feel free to play around with the options. The ones I mentioned above are not necessarily the best for your purpose - they were just a first attempt at filtering out the abundance of very low values in that one part along the scaffold. Whatever gives you visually interpretable results works. The whole idea of a cathedral plot is to be a visual exploration ;-)

On a related note, how are you rendering the plot as the one you've linked to? Are you just converting the svg to png from the standard output? My plots definitely do not look this nice in preview :(

For the plot posted above, I just opened the produced svg with the default Ubuntu Image Viewer and grabbed a screen shot of that. For more serious work on svg, I'm using Inkscape.

What does not look as nice in your plots though? Could you post an example maybe? These things are hard for me to test on other systems, so if it looks different for you, that would be valuable feedback for me!

Thanks and so long Lucas

peterdfields commented 5 months ago

@lczech Here is a screenshot of what a svg looks like on a scaffold I think has some interesting things going on when I open it directly in Inkscape for mac:

Screenshot 2024-06-18 at 8 11 51 PM

And here is what the bmp looks like when directly rendered in preview:

Screenshot 2024-06-18 at 8 16 23 PM

However, this is what the scaffold looks like with the new version you just released:

Screenshot 2024-06-18 at 8 23 26 PM

So I think it was probably those negative values causing the problems?

lczech commented 5 months ago

The only difference that I can see between them is the lower end of the values that the colors represent. In the top two plots, negative values are filtered out, while the third plot goes down to -0.01. My guess is that you used --min-value 0.0 and --min-value -0.01 respectively? Other than that, the new version of grenedalf should behave the same as v0.5.0 and v0.51. Or what do you mean by "what the scaffold looks like with the new version you just released"? Which version did you use before, and with which options?

Either way, as said, I recommend to play around a bit with the options to see which ones allow you to see the range of values in a meaningful way. It is hard to determine that programatically, as "looks good" is not really a criterion I can code :-) - by default, the values are just taken as they are, min and max as found in the data, and put on the scale. But in your case, with many low and negative values of FST (due to the pool seq corrections) it makes sense to limit that range a bit, as above. Hope that helps.