montilab / hypeR

An R Package for Geneset Enrichment Workflows
https://montilab.github.io/hypeR-docs/
GNU General Public License v3.0
75 stars 11 forks source link

multihyp dot plot significance legend is not showing properly (solution included) #56

Open Vanessa104 opened 3 months ago

Vanessa104 commented 3 months ago

When drawing dot plot Function hyp_dots() when used for a mylti_hyp object. See the significance legend: image

This is likely due to the newer version of the package scales. Unsure which version exactly, but it seems like internal function .reverselog_trans() which is based on scales::trans_new() is not working well.

Solution: https://github.com/montilab/hypeR/blob/master/R/hyp_dots.R Line 111. Change this line to: scale_color_continuous(high = "#114357", low = "#E53935", trans = scales::log10_trans(), guide = guide_colorbar(reverse = TRUE))

Or, add this after using hyp_dots() to overwrite the existing function. hyp_dots(...) + scale_color_continuous(...insert above...)

Example output: image

tetomonti commented 3 months ago

Thanks for catching it @Vanessa104. While your solution works, it outputs the warning

Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

We need to find a more 'radical' solution.

anfederico commented 3 months ago

What about trans=c("log10", "reverse")?

Vanessa104 commented 3 months ago

Thanks for catching it @Vanessa104. While your solution works, it outputs the warning

Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.

We need to find a more 'radical' solution.

The warning is because scale_color_manual is already defined in the hyp_dots() function (at line 111), so defining it again will give you a warning. If we replace the current line 111 with the new code, then there will be no warnings. I didn’t commit the change and created this issue instead, in case there is a better solution or in case there are other developments going on.