thackl / gggenomes

A grammar of graphics for comparative genomics
https://thackl.github.io/gggenomes/
Other
587 stars 65 forks source link

Examples do not work - issue with pick #199

Open SergejRuff opened 1 week ago

SergejRuff commented 1 week ago

Examples where pick() is utilized do not work and return the following error:

Error in pick(): ! Must only be used inside data-masking verbs like mutate(), filter(), and group_by().

Examples can be found in the position functions such as gggenomes::position_strand'.

thackl commented 1 week ago

This looks like you are using dplyr::pick() here. dplyr recently introduced a new function with that name. You need to either load library(gggenomes) after library(tidyverse/dplyr), or explicitly call gggenomes::pick() to get the right function.

SergejRuff commented 6 days ago

Right, but is pick attached or loaded. If pick is included in the NAMESPACE of the function (@importfrom package pick) than that shouldnt happen, right? Is pick loaded into the enviroment?

SergejRuff commented 6 days ago

I just checked and realized that there is a function called pick: https://github.com/thackl/gggenomes/blob/976bb831975b505964086a19dd5371163abec991/R/pick.R#L93. is it possible to rename it for future versions into a unique name that does not conflict with other pick functions (gggene_pick for example)?

thackl commented 6 days ago

The somewhat mean thing here is that gggenomes' pick() function was actually there first (https://thackl.github.io/gggenomes/reference/pick.html). I had chosen pick() as function name for gggenomes in part because it had no overlap with other tidyverse functions. But now dplyr has added it's own pick function. I might rename pick, but generally speaking, I also don't want to rename existing functions anytime someone else releases a new function with the same name.

Regarding unique name, well it is easy to use the name in a unique fashion, just explicitly write gggenomes::pick() and dplyr::pick(), which isn't much different from something like gggenomes_pick().

And as a quick workaround you can of course always simply use your own function names, just put something like this in your code

pick_bins <- gggenomes::pick
pick_bins()