marschall-lab / panacus

Panacus is a tool for computing statistics for GFA-formatted pangenome graphs
MIT License
73 stars 4 forks source link

Option to output plots in separate PNG files #10

Closed subwaystation closed 10 months ago

subwaystation commented 10 months ago

Hi @danydoerr,

could you please provide an option to output the plots in separate PNG files? @heringerp is working on making panacus a module for nf-core. However, in order for the results to be integrated into a MultiQC report, we need PNGs. PDFs are not supported.

Thanks!

Best, Simon

danydoerr commented 10 months ago

I could add an option to specify the output format (pdf/png). Separate PNGs... what do you mean by that?

subwaystation commented 10 months ago

The final output is one PDF with 3 Figures, if I am not mistaken. panacus.pdf In the MultiQC report, we would like to have 3 separate figures, so we would need each of them in its own PNG file.

subwaystation commented 10 months ago

The option specifying the output format sounds great!

danydoerr commented 10 months ago

Regarding the separation of figures: Panacus always produces 1 output file from 1 input file. But if you want to have the figures separated, it's super easy to have this done in a subsequent script that utilizes identify and convert from ImageMagick.

  1. identify gives you the dimensions of the image:
    identify panacus.png
    panacus.png PNG 9000x1800 9000x1800+0+0 8-bit sRGB 690629B 0.000u 0:00.000
  2. It's clear that each plot has same dimensions, so all you need to do is take with width and divide by 3 for cropping with convert:
    convert -crop 3000x1800+0+0 panacus.png panacus1.png
    convert -crop 3000x1800+3000+0 panacus.png panacus2.png
    convert -crop 3000x1800+6000+0 panacus.png panacus3.png

    panacus

danydoerr commented 10 months ago

(Also, there is a bug in the plotting script that draws the estimate of the 2nd plot at the wrong position; I just pushed a fix)

subwaystation commented 10 months ago

Yes, we also thought about ImageMagick. But that would mean more work downstream for us. A new nf-core module, more to maintain, etc. That's why we are wishing for 3 PNGs. If that's not possible, we will have to go for the ImageMagick option.

danydoerr commented 10 months ago

Everything is negotiable... My coding principles are hanging high enough so that I can limbo below every once in a while. If you're not happy with postprocessing, I'm also accepting pull requests with your solution :)

subwaystation commented 10 months ago

Please take a look at https://github.com/marschall-lab/panacus/pull/11/files @danydoerr

danydoerr commented 10 months ago

@subwaystation Thanks! Very helpful, I only have a few requests that I think will improve the usability.

danydoerr commented 10 months ago

It's now merged. Again, thanks @heringerp!

danydoerr commented 10 months ago

@heringerp @subwaystation made a minor change for the prefix argument, which is now called 'split_prefix', to associate it more closely with the split option