Coder Social home page Coder Social logo

ggprism's People

Contributors

csdaw avatar teunbrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ggprism's Issues

step.increase in add_y_position() is bad

I generate a lot of graphs of the same type. And they all have a different scale along the y-axis. And the step.increase default value is not suitable, because the lines on the graph with the p-value stick together. If I change the step.increase standard value, then the lines, on the contrary, diverge too much.

stat.test <- total %>% rstatix::wilcox_test(as.formula(paste(col_names[col_i], "group", sep="~" ))) %>% rstatix::add_y_position()
stat.test$y.position[3] = stat.test$y.position[1]

5    BDNF_99__27721798
6    BDNF_92__27721791
7    HTR2A_06__47471705
12    FKBP5_38__35558438
13    FKBP5_88__35558488
16    TRKB__87283470

adding new themes

Hi!

i chanced upon your package and was wondering how i can add new themes to it?

Thank you very much and look forward to hearing back from you.

Release ggprism 1.0.2

Need to release a patch so p-value vignette passes CRAN checks. Otherwise ggprism will get removed from CRAN ๐Ÿ˜ต

To do:

  • Fix p-values vignette
  • Increase test coverage

Prepare for resubmission:

  • Knit README.Rmd
  • R CMD check
  • devtools::check(remote = TRUE, manual = TRUE)
  • Update NEWS.md
  • Push final changes to trigger GitHub Actions
  • Review GitHub Actions results
  • devtools::check_win_devel()
  • rhub::check_for_cran()*
  • Update cran-comments.md
  • Push

*I used:

rhub::check_for_cran(
  platforms = c("fedora-clang-devel",
                "windows-x86_64-oldrel"),
  env_vars=c(
    `_R_CHECK_FORCE_SUGGESTS_` = "true",
    `_R_CHECK_CRAN_INCOMING_USE_ASPELL_` = "true", 
    R_COMPILE_AND_INSTALL_PACKAGES = "always"
  )
)

Submit to CRAN:

  • usethis::use_version("patch")
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Tweet

Release ggprism 1.0.4

Small release mainly to preserve compatibility with ggplot2 v3.4.0 (but also fixes a bug and adds a small feature, see NEWS.md).

Prepare for submission:

  • Update NEWS.md
  • url_checker::url_check()
  • R CMD check
  • devtools::check(remote = TRUE, manual = TRUE)
  • revdepcheck::revdep_check(num_workers = 4)
  • Push final changes to trigger GitHub Actions
  • Review GitHub Actions results

Optionally fix things that need fixing, then repeat the above.

Submit to CRAN:

  • devtools::check_win_devel()
  • rhub::check_for_cran()*
  • Update cran-comments.md
  • usethis::use_version("patch")
  • devtools::build_readme()
  • Commit
  • devtools::check(remote = TRUE, manual = TRUE)`
  • Push again
  • Review GitHub Actions results
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()

*I used:

rhub::check_for_cran(
  platforms = c("fedora-clang-devel", "windows-x86_64-oldrel"),
  env_vars=c(
    `_R_CHECK_FORCE_SUGGESTS_` = "true",
    `_R_CHECK_CRAN_INCOMING_USE_ASPELL_` = "true", 
    `R_COMPILE_AND_INSTALL_PACKAGES` = "always"
  )
)

Release ggprism 1.0.1

Prepare for release:

  • devtools::build_readme()
  • R CMD check
  • devtools::check(remote = TRUE, manual = TRUE)
  • Push final changes to trigger GitHub Actions
  • Review GitHub Actions results
  • devtools::check_win_devel()
  • rhub::check_for_cran()*
  • Update cran-comments.md and push

*I used:

rhub::check_for_cran(env_vars=c(`_R_CHECK_FORCE_SUGGESTS_` = "true",
  `_R_CHECK_CRAN_INCOMING_USE_ASPELL_` = "true", 
  R_COMPILE_AND_INSTALL_PACKAGES = "always"))

Submit to CRAN:

  • usethis::use_version("patch")
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

Need to fix issues and resubmit.

Release ggprism 1.0.3

Need to release a patch so tests won't fail when ggplot2 v3.4.0 is released.

Prepare for resubmission:

  • devtools::build_readme()
  • url_checker::url_check()
  • R CMD check
  • devtools::check(remote = TRUE, manual = TRUE)
  • Update NEWS.md
  • Push final changes to trigger GitHub Actions
  • Review GitHub Actions results
  • devtools::check_win_devel()
  • rhub::check_for_cran()*
  • Update cran-comments.md
  • Push

Submit to CRAN:

  • usethis::use_version("patch")
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Tweet

*I used:

rhub::check_for_cran(
  platforms = c("fedora-clang-devel", "windows-x86_64-oldrel"),
  env_vars=c(
    `_R_CHECK_FORCE_SUGGESTS_` = "true",
    `_R_CHECK_CRAN_INCOMING_USE_ASPELL_` = "true", 
    `R_COMPILE_AND_INSTALL_PACKAGES` = "always"
  )
)

Integrate `latex2exp::TeX` into `add_pvalue`?

Hi @csdaw,

I am using the add_pvalue function, and I am wondering whether it would be possible to have the P values nicely formatted as P = 1x10-10 rather than P=1e-10. For doing this, I usually use latex2exp::TeX but I don't understand how to integrate it into the add_pvalue function.

I am now using rstatix to both perform the statistical test and create the p-value table with the correct x and y position:

p <- ggplot(ToothGrowth, aes(x = factor(dose), y = len)) +
  geom_boxplot(aes(fill = dose), colour = "black") +
  theme_prism() +
  theme(legend.position = "none")
stat.test <- rstatix::t_test(ToothGrowth, len ~ dose, ref.group = "0.5") %>%
  rstatix::add_xy_position()

My first thought was to create a new field in stat.test to store the LaTeX expressions generated by latex2exp::TeX, as follows:

stat.test$p.latex <- latex2exp::TeX(stat.test$p.latex)

where p.latex Is a string vector containing LaTeX expressions (let's say "1 \\times 10^{-10}") which I generated with another function.
However, the stats.test object is not able to store expressions (as those outputted by latex2exp::TeX).

I then tried to modify the

p + add_pvalue(stat.test, label = "p = {p.latex}")

bit and the add_pvalue function to have the expression printed, but I have no idea on how to do this.

Would you be able to help me?
Many thanks in advance!

Issue with the next release of ggplot2

Hi

We are preparing the next version of ggplot2 and our tests show that ggprism is having issues with it. Specifically we now store the computed params in computed_geom_params and computed_stat_params. This means that these are the field you should be expecting in your tests if you feel it necessary to peek into the ggplot object.

The failing tests are:

----- FAILED[data]: test-annotation_ticks.R<66--66>
call| expect_true(g1$layers[[2]]$geom_params$colour == "red")
diff| Expected TRUE, got 'logical' of length 0
----- FAILED[data]: test-annotation_ticks.R<69--69>
call| expect_true(g2$layers[[2]]$geom_params$colour == "red")
diff| Expected TRUE, got 'logical' of length 0

where you should look at g1$layers[[2]]$computed_geom_params$colour instead

we plan to release the next version of ggplot2 on May 31st

Error on add_pvalue with geom_jitter() aes

Hey there,

I am currently running the following R code:

p_vals <- tibble::tribble(
  ~group1, ~group2, ~p.adj,   ~y.position,
  "audi",   "dodge",     0.01 , 3.99,
  "audi",   "chevrolet",  0.01,  3.5
)

mpg %>%
  mutate(displ = as.numeric(displ)) %>% 
  ggplot(aes(x = manufacturer, y = displ, fill = manufacturer))+
  geom_bar(position=position_dodge(), stat="identity") +
  geom_jitter(height = 0, width = 0.2, size = 4) +
  ylim(0,4) + 
  theme_prism(base_size = 16)+
  scale_fill_manual(values = cbbPalette)+ 
  theme(legend.position = "none") +
  add_pvalue(p_vals, label = "p = {p.adj}", tip.length = 0, label.size = 4)

And receiving the following error:

Error:
! Problem while computing aesthetics.
โ„น Error occurred in the 3rd layer.
Caused by error in `FUN()`:
! object 'manufacturer' not found
Backtrace:
  1. base (local) `<fn>`(x)
  2. ggplot2:::print.ggplot(x)
  4. ggplot2:::ggplot_build.ggplot(x)
  5. ggplot2:::by_layer(...)
 12. ggplot2 (local) f(l = layers[[i]], d = data[[i]])
 13. l$compute_aesthetics(d, plot)
 14. ggplot2 (local) compute_aesthetics(..., self = self)
 15. base::lapply(aesthetics, eval_tidy, data = data, env = env)
 16. rlang (local) FUN(X[[i]], ...)
Error in (function (mapping = NULL, data = NULL, stat = "bracket", position = "identity", :

โ„น Error occurred in the 3rd layer.
Caused by error in `FUN()`:
! object 'manufacturer' not found

When I run the same code without the add_pvalues() command, it creates the plot. I can also add pvalue lines with geom_signif(), but those stay small / don't get larger with the theme_prism(base_size=16) argument so I'd like to make the add_pvalues() arg work .

Thanks for any advice! Not sure how to fix this one~

Unable to display legend title

I tried to add the legend title to my data, but I found that if I added theme_prism(base_size = 14) my legend title would disappear, if I commented this out the legend title would appear again, I don't know what is wrong, can someone help me?
I used R4.1.3 and downloaded prism version 1.0.2

Planned features

ggprism

Things to include in the future:

  • Prism .pzfx file with examples and a vignette recreating them with this package. Or even a pkgdown site...
  • A vignette which downloads data from figshare or whatever and recreates the figures from a paper. Could also be a page on a future pkgdown site...
  • Examples which use packages that will go well with ggprism e.g. kassambara/rstatix, eclarke/ggbeeswarm

Other packages

Some features/functions of other packages would fit in ggprism, but I don't want to extend the dependencies of ggprism beyond those of ggplot2. So need to rewrite them into ggprism.

Release ggprism 1.0.5

Fixes compatibility with ggplot2 v3.5.0.

Prepare for submission:

  • Update NEWS.md
  • urlchecker::url_check()
  • R CMD check
  • devtools::check(remote = TRUE, manual = TRUE)
  • revdepcheck::revdep_check(num_workers = 4)
  • Push final changes to trigger GitHub Actions
  • Review GitHub Actions results

Optionally fix things that need fixing, then repeat the above.

Submit to CRAN:

  • devtools::check_win_devel()
  • rhub::check_for_cran()*
  • Update cran-comments.md
  • usethis::use_version("patch")
  • devtools::build_readme()
  • Commit
  • devtools::check(remote = TRUE, manual = TRUE)`
  • Push again
  • Review GitHub Actions results
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()

*I used:

rhub::check_for_cran(
  platforms = c("fedora-clang-devel", "windows-x86_64-oldrel"),
  env_vars=c(
    `_R_CHECK_FORCE_SUGGESTS_` = "true",
    `_R_CHECK_CRAN_INCOMING_USE_ASPELL_` = "true", 
    `R_COMPILE_AND_INSTALL_PACKAGES` = "always"
  )
)

Issues with next version of ggplot2

Hi

We preparing the next release of ggplot2 and our reverse dependency checks show that your package is failing with the new version. Looking into it we see that your package somehow includes references to ggplot2 code from when it was build, either by reloading saved plot objects or by grabbing functions at build time. Please see https://www.tidyverse.org/blog/2022/09/playing-on-the-same-team-as-your-dependecy/ for some more info about why this can cause issues.

You can install the release candidate of ggplot2 using devtools::install_github('tidyverse/[email protected]') to test this out.

We plan to submit ggplot2 by the end of October and hope you can have a fix ready before then

Kind regards
Thomas

Cant hide legend

Hi first of all great package! However I have an issues with hiding the legend....adding:

plot + theme(legend.title = element_blank()) doesnt seem to work....adding show.legend = F to the aes of ggplot does work but every time I add plot + theme_prism() the legend pops back up

hide.NS option for add_pvalue function

This is an option in stat_pvalue_manual to hide insignificant p values from being plotted and seems to be missing from add_pvalue function. Would you be able to add it?

An "i" in the label string is forced to be capitalized.

Thank you for your great work.
I found a problem with the label.
The problem is that;
An "i" in the label string is forced to be capitalized.

iris %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species))+ geom_point()+ xlab("all small iiiiis")+ theme_prism()
image

iris %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species))+ geom_point()+ xlab("all small iiiiis")+ theme_bw()

image

my environment is;
Mac mini (M1)
R version 4.4.0 (2024-04-24) -- "Puppy Cup"
Rstudio (2024.04.0+735)
ggprism_1.0.5
ggplot2_3.5.1

To do before first release

In no particular order

  • Clean up guide_prism_minor and make changes more explicit
  • Remove ggplot-internal.R and replace with pulls from ggplot2 NAMESPACE (see teunbrand/ggh4x)
  • Decide if annotation_ticks is useful or can be removed
  • Fix tick length determination/defaults in annotation_ticks
  • Decide if imports can stay in ggprism-package.R or should be moved to the functions in which they are used
  • Check that scale_fill_prism has the correct structure
  • Check that scale_shape_prism has the correct structure
  • Make line elements in theme_prism inherit from base_line_size? Not sure about this one...
  • Make axes automatically disappear if frame = TRUE in theme_prism, or at least play around with panel.border
  • Add Makefile for package build
  • Improve Makefile to make life easier
  • Add scale_colour/color_prism functions
  • Add the colour palettes that underlie scale_colour_prism
  • Make file names in data-raw more consistent
  • Put schemes all in the same directory
  • Make README more informative
  • Recreate a figure from a paper in the README
  • Add .pdf with all colour schemes
  • Add useful packages to suggests e.g. rstatix, ggbeeswarm, etc.
  • Recreate some common figure types in a vignette

Document and add examples for:

  • annotation_ticks
  • ggprism-package
  • ggprism_data
  • guide_prism_minor
  • scale_fill_prism
  • scale_colour_prism
  • scale_shape_prism
  • theme_prism

Add tests for:

  • annotation_ticks
  • guide_prism_minor
  • scale_fill_prism
  • scale_colour_prism
  • scale_shape_prism
  • theme_prism

theme_prism() not working with ggplot2

Hello

I have been using your wonderful package, unfortunately, I started getting errors across all of my Rmarkdown and scripts. This started happening about a week ago.

For example:

p_HR_all <- final_result %>% ggplot(aes(x = Time, y = HR, color=Group)) + geom_smooth(method = "loess", se = TRUE) + labs(title = "", x = "Time (seconds)", y = "HR (bpm)") + theme_prism() + scale_x_continuous(limits = c(0, 180), breaks = seq(0, 180, 60)) p_HR_all

and the error would be:

Error in plot_theme():
! The legend.text.align theme element is not defined in the element hierarchy.
Backtrace:

  1. base (local) <fn>(x)
  2. ggplot2:::print.ggplot(x)
  3. ggplot2:::ggplot_gtable.ggplot_built(data)
  4. ggplot2:::plot_theme(plot)
    Error in plot_theme(plot) :

hopefully is a quick fix. Thank you

Can't seem to adjust x-position for brackets in interaction plots with add_pvalue

Hello,

I'm new to plotting p-values on interaction plots, and I've been working off the piece of code below (source).

I've been trying to adjust the x-position of the brackets, such that for each pairwise comparison, the left end of the bracket is aligned with the middle of the first boxplot being considered, and the right end of the bracket is aligned with the middle of the second boxplot being considered.

In other words, I would like xmin in df_p_val to reflect the dose & supp combination of the first group in the pairwise comparison -- not just its dose.

Thank you very much in advance for any guidance you may be able to provide!

df_p_val <- ToothGrowth %>% 
  rstatix::group_by(supp) %>% 
  rstatix::t_test(len ~ dose) %>% 
  rstatix::add_xy_position()

p <- ggplot(ToothGrowth, aes(x = factor(dose), y = len)) + 
  geom_boxplot(aes(fill = supp)) + 
  theme_prism()

# remember colour and step.group.by are referring to a column name in df_p_val
p + add_pvalue(df_p_val, 
               label = "p = {p.adj}",
               colour = "supp",
               fontface = "bold",
               step.group.by = "supp",
               step.increase = 0.1,
               tip.length = 0,
               bracket.colour = "black",
               show.legend = FALSE)

adding scale_y_log10 changes y-axis to a weird range

add_pvalue function affects scale_y_log10's behavior, e.g.

tg <- ToothGrowth
tg$dose <- as.factor(tg$dose)
tg$group <- factor(rep(c("grp1", "grp2"), 30))
two.means <- tibble::tribble(
~group1, ~group2, ~p, ~y.position,
"OJ", "VC", 0.0606, 36)

Without scale_y_log10, add_pvalue works as expected
ggplot(tg, aes(x = supp, y = len)) + geom_boxplot() + add_pvalue(two.means)

With scale_y_log10, y-axis become extremely large and original plots are squeezed to the bottom
ggplot(tg, aes(x = supp, y = len)) + geom_boxplot() + add_pvalue(two.means) + scale_y_log10()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.