Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggsave throws error in example code #176

Closed
bkille opened this issue Feb 27, 2024 · 8 comments
Closed

ggsave throws error in example code #176

bkille opened this issue Feb 27, 2024 · 8 comments

Comments

@bkille
Copy link

bkille commented Feb 27, 2024

> library(gggenomes)

# to inspect the example data shipped with gggenomes
> data(package="gggenomes")

> gggenomes(
  genes = emale_genes, seqs = emale_seqs, links = emale_ava,
  feats = list(emale_tirs, ngaros=emale_ngaros, gc=emale_gc)) |> 
  add_sublinks(emale_prot_ava) |>
  sync() + # synchronize genome directions based on links
  geom_feat(position="identity", size=6) +
  geom_seq() +
  geom_link(data=links(2)) +
  geom_bin_label() +
  geom_gene(aes(fill=name)) +
  geom_gene_tag(aes(label=name), nudge_y=0.1, check_overlap = TRUE) +
  geom_feat(data=feats(ngaros), alpha=.3, size=10, position="identity") +
  geom_feat_note(aes(label="Ngaro-transposon"), data=feats(ngaros),
      nudge_y=.1, vjust=0) +
  geom_wiggle(aes(z=score, linetype="GC-content"), feats(gc),
      fill="lavenderblush4", position=position_nudge(y=-.2), height = .2) +
  scale_fill_brewer("Genes", palette="Dark2", na.value="cornsilk3")

runs just fine, but the final command throws an error

> ggsave("emales.png", width=8, height=4)
Error in guides$setup(scales, aesthetics, default = params$guide_default %||%  : 
  attempt to apply non-function

I've ran into this on both Ubuntu 22 and MacOS, both with R 4.3.2. Should I be using an earlier version of R? Thank you!

@buiguesj
Copy link

buiguesj commented Mar 1, 2024

I'm getting the same error using my data, any solution??

@thackl
Copy link
Owner

thackl commented Mar 1, 2024

Hi, thanks for reporting this. What ggplot version are you using?

@buiguesj
Copy link

buiguesj commented Mar 1, 2024

I'm using ggplot2 3.5.0

@thackl
Copy link
Owner

thackl commented Mar 1, 2024

OK, it cannot reproduce it in ggplot2 v3.4.4. Looking into v3.5.0 asap.

@Daniel-Ze
Copy link

For me running the example from the README.md file results in the same error as @bkille described however not after the ggsave command:

library(gggenomes)

# to inspect the example data shipped with gggenomes
data(package="gggenomes")

gggenomes(
  genes = emale_genes, seqs = emale_seqs, links = emale_ava,
  feats = list(emale_tirs, ngaros=emale_ngaros, gc=emale_gc)) |> 
  add_sublinks(emale_prot_ava) |>
  sync() + # synchronize genome directions based on links
  geom_feat(position="identity", size=6) +
  geom_seq() +
  geom_link(data=links(2)) +
  geom_bin_label() +
  geom_gene(aes(fill=name)) +
  geom_gene_tag(aes(label=name), nudge_y=0.1, check_overlap = TRUE) +
  geom_feat(data=feats(ngaros), alpha=.3, size=10, position="identity") +
  geom_feat_note(aes(label="Ngaro-transposon"), data=feats(ngaros),
                 nudge_y=.1, vjust=0) +
  geom_wiggle(aes(z=score, linetype="GC-content"), feats(gc),
              fill="lavenderblush4", position=position_nudge(y=-.2), height = .2) +
  scale_fill_brewer("Genes", palette="Dark2", na.value="cornsilk3")

ggsave("emales.png", width=8, height=4)

Output:

> data(package="gggenomes")
> gggenomes(
+   genes = emale_genes, seqs = emale_seqs, links = emale_ava,
+   feats = list(emale_tirs, ngaros=emale_ngaros, gc=emale_gc)) |> 
+   add_sublinks(emale_prot_ava) |>
+   sync() + # synchronize genome directions based on links
+   geom_feat(position="identity", size=6) +
+   geom_seq() +
+   geom_link(data=links(2)) +
+   geom_bin_label() +
+   geom_gene(aes(fill=name)) +
+   geom_gene_tag(aes(label=name), nudge_y=0.1, check_overlap = TRUE) +
+   geom_feat(data=feats(ngaros), alpha=.3, size=10, position="identity") +
+   geom_feat_note(aes(label="Ngaro-transposon"), data=feats(ngaros),
+                  nudge_y=.1, vjust=0) +
+   geom_wiggle(aes(z=score, linetype="GC-content"), feats(gc),
+               fill="lavenderblush4", position=position_nudge(y=-.2), height = .2) +
+   scale_fill_brewer("Genes", palette="Dark2", na.value="cornsilk3")
Transforming sublinks with "aa2nuc". Disable with `.transform = "none"`
Flipping: Cflag_017B,BVI_069,BVI_008A
wiggle boundsmid:  0.38low:  0.2high: 0.76
Error in guides$setup(scales, aesthetics, default = params$guide_default %||%  : 
  attempt to apply non-function
>

MacOS 13.6
Rstudio: Version 2023.12.1+402 (2023.12.1+402)
R: 4.3.2
ggplot2: 3.5.0

@EpfeiferNutri
Copy link

I am getting the same error using ggplot2 v3.5.0 and v3.4.4. (both in R: 4.3.2, RStudio Server 2023.03.1)

Hoping for a fast and easy solution...
thanks in advance (like this tool a lot!)!! :)

@thackl
Copy link
Owner

thackl commented Mar 4, 2024

Should be fixed now by #178.

ggplot 3.5.0 introduced additional ggprotos for guides and layout, which gggenomes now also creates.

@thackl thackl closed this as completed Mar 4, 2024
@EpfeiferNutri
Copy link

Thanks a lot! It is working now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants