Skip to content

Commit

Permalink
Documentation edits (#38)
Browse files Browse the repository at this point in the history
* use `scales::label_percent()` instead of superseded `scales::percent_format()`.

* Update documentation and add more cross-references

* add backticks for better cross linking on website

* add roxygen md docs

---------

Co-authored-by: Samer Mouksassi <samermouksassi@gmail.com>
  • Loading branch information
olivroy and smouksassi committed Jan 15, 2024
1 parent b369aa9 commit d20a78f
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 145 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.3.0
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ importFrom(rlang,.data)
importFrom(rlang,sym)
importFrom(scales,identity_trans)
importFrom(scales,label_parse)
importFrom(scales,label_percent)
importFrom(scales,label_wrap)
importFrom(scales,math_format)
importFrom(scales,muted)
importFrom(scales,parse_format)
importFrom(scales,percent)
importFrom(scales,percent_format)
importFrom(scales,trans_breaks)
importFrom(scales,trans_format)
importFrom(stats,median)
Expand Down
29 changes: 16 additions & 13 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# ggquickeda 0.3.1

* rebuilt docs fixed broken link
* fixing some regressions introduced by bookmarking
* fixing some errors by the new R rules for logical comparison length with `|` versus `||`
* fixing error in aspect.ratio not numeric (was also fixed in ggplot2)
* fixing other regressions with ggpairs color and group
* fixing error in `aspect.ratio` not numeric (was also fixed in ggplot2)
* fixing other regressions with `GGally::ggpairs()` color and group
* added support of pasting values of two/three variables where it was just a placeholder
* added function `ggkmrisktable()` to add facetable risk tables, km and by ntiles split exposures
* added function `gglogisticexpdist()` and `ggcontinuousexpdist()` to add facetable logistic/linear regression with exposures split to ntiles with exposure distributions by dose/group and optional y axis projections
* added function `gglogisticexpdist()` and `ggcontinuousexpdist()` to add facetable logistic/linear regression with exposures split to ntiles with exposure distributions by dose/group and optional y axis projections
* added link to github pages in description thanks to @olivroy
* Fix part of ggplot2 3.4.0 deprecation warnings. (#27, @olivroy)

# ggquickeda 0.3.0

* added options to drop levels for user discrete shape and linetype scales
* fixed ggpairs group input and added ability to combine y variables
* fixed `GGally::ggpairs()` group input and added ability to combine y variables
* fixed issue with barplot flip applied to bivariate plots
* fixed issues with barplot percent labels when position is fill
* added checkboxes to parse x and y axis labels text
* added ability to regenerate state of apps to have a better UX workflow in Phoenix (James Craig)
* added ability to regenerate state of apps to have a better UX workflow in Phoenix (James Craig, #28)
* removed Welcome message and added padding
* James Craig added as a co-author

Expand All @@ -28,7 +30,7 @@
* restored target window annotations to work with factor/character x axis
* added the possibility to change the size and linetype of density plots
* added the possibility to choose the shape of boxplot outlier points
* added options for x and y scale tick formatting are now visible when pairs plot are active
* added options for `x` and `y` scale tick formatting are now visible when pairs plot are active
* added options for identity line and for placement of custom/target text at plot edges
* added checkbox to recode numeric variables with -99 to missing
* removed ggstance dependency by adding needed positions to global.r
Expand Down Expand Up @@ -143,31 +145,32 @@
* added possibility to divide multiple columns by a specified one (e.g. dose normalization)
* "Treat as Categories:" now accepts character variables in addition to numeric.
* "Treat as Numeric:" added to enable converting columns read as factors.
* updated the docs for geom and stat_km stat_kmband stat_kmticks.
* updated the docs for geom and `stat_km()` `stat_kmband()` `stat_kmticks()`.


# ggquickeda 0.1.3

* UI and options improvements for KM (line sizes, transparency, ignore group and color), linetype mappping
* changed default error in stat_kmbands, borrowed stairstepn from ggalt and applying zoo::na.locf to deal with na
* changed default error in `stat_kmbands()`, borrowed stairstepn from ggalt and applying `zoo::na.locf()` to deal with `NA`.
* added the possibility to add median survival with or without CI
* Using stat_cor from ggpubr to compute correlations for more flexibility and margin in facets
* Using `ggpubr::stat_cor()` to compute correlations for more flexibility and margin in facets
* added ability to ignore grouping and or ignore color mapping for correlation coefficient
* added possibility to dodge means and medians
* added possibility to specify means and medians N and Values transparency and a default seed for text_repel
* geom text,label, withe repel variants and position dodge for median and mean labels
* geom text,label, with repel variants and position dodge for median and mean labels
* added transparency control for densities and histograms as well as linetype mappping
* added binwidth control for histogram (user defined or auto), and position dodge
* added window adjustment control for densities
* linetypes for predefined quantiles
* added the possibility to add one more therapeutic window and fixed a bug with categorical x axis
* added possibility to remove x/y axis tick labels
* fixes for continuous scales logic
* Added initial support for ggpairs
* Added initial support for `GGally::ggpairs()`



# ggquickeda 0.1.2
* bug fixed where in some cases plotdata did not apply filtering
* bug fixed where in some cases plot data did not apply filtering
* updated and expanded merge multiple levels of a factor
* added mappings by shape for points and linetypes of lines and associated custom legends and possibility to ignore it
* added the possibility of choosing more linetypes for lines
Expand All @@ -177,7 +180,7 @@
* fixed bug in median line not honoring transparency when Median\PI selected with some UI tweaks
* added more options for boxplot outliers (size and transparency)
* separate color control for major and minor gridlines with the possibility to remove them
* added annotation_logticks
* added `annotation_logticks()`
* make faceting less prone to fail when user mistakenly choose the same variable in rows and columns
* make user defined color/fill scales

Expand Down
5 changes: 4 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
#' \item{AGECAT}{age category of the subject, a variable cutting Age into two values 0/1}
#' }
#' @source "sd_oral_richpk" from 'PKPDmisc' R package with an additional AGECAT variable
"sample_data"
#' @examples
#' sample_data
#'
"sample_data"
11 changes: 6 additions & 5 deletions R/ggcontinuousexpdist.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ summary_df_cont <- function(x,y, probs = c(0.25,0.75,0.90,0.10)) {
}
plogis <- function(x) exp(x)/(1+exp(x))

#' ggcontinuousexpdist
#'
#' Create a continuous exposure fit plot
#'
#' Produces a logistic fit plot with a facettable exposures/quantiles/distributions in ggplot2
#'
#' @param data Data to use with multiple endpoints stacked into Endpoint(endpoint name), response 0/1
#' @param response name of the column holding the valuesresponse 0/1
#' @param endpoint name of the column holding the name/key of the endpoint default to `Endpoint`
Expand All @@ -41,19 +42,19 @@ plogis <- function(x) exp(x)/(1+exp(x))
#' @param ylab text to be used as y axis label
#' @param mean_text_size mean text size default to 5
#' @param mean_obs_bydose observed mean by dose TRUE/FALSE
#' @param N_text_size N responders/Ntotal by exposure bin text size default to 5
#' @param N_text_size N respondents/Ntotal by exposure bin text size default to 5
#' @param binlimits_text_size 5 binlimits text size
#' @param binlimits_ypos binlimits y position default to 0
#' @param binlimits_color binlimits text color default to "gray70"
#' @param dist_position_scaler space occupied by the distribution default to 0.2
#' @param dist_offset offset where the distribution position starts 0
#' @param lineranges_ypos where to put the lineranges -1
#' @param lineranges_dodge lineranges vertical dodge value 1
#' @param yproj project the probabilities on y axis TRUE/FALSE
#' @param yproj project the probabilities on y axis `TRUE`/`FALSE`
#' @param yproj_xpos y projection x position 0
#' @param yproj_dodge y projection dodge value 0.2
#' @param yaxis_position where to put y axis "left" or "right"
#' @param facet_formula facet formula to be use otherwise endpoint ~ expname
#' @param facet_formula facet formula to be use otherwise `endpoint ~ expname`
#' @param theme_certara apply certara colors and format for strips and default colour/fill
#' @examples
#' # Example 1
Expand Down
28 changes: 14 additions & 14 deletions R/ggkm.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @importFrom scales trans_breaks
#' @importFrom scales trans_format
#' @importFrom scales math_format
#' @importFrom scales percent_format
#' @importFrom scales label_percent
#' @importFrom scales parse_format
#' @importFrom scales percent
#' @importFrom scales label_parse
Expand Down Expand Up @@ -121,21 +121,22 @@ GeomKmticks <- ggplot2::ggproto("GeomKmticks", ggplot2::Geom,
#' \code{geom_km} understands the following aesthetics (required aesthetics
#' are in bold):
#' \itemize{
#' \item \strong{\code{x}} The survival/censoring times. This is automatically mapped by \link{stat_km}
#' \item \strong{\code{y}} The survival probability estimates. This is automatically mapped by \link{stat_km}
#' smallest level in sort order is assumed to be 0, with a warning
#' \item \strong{\code{x}} The survival/censoring times. This is automatically mapped by [stat_km()]
#' \item \strong{\code{y}} The survival probability estimates. This is automatically mapped by [stat_km()]
#' smallest level in sort order is assumed to be 0, with a warning.
#' \item \code{alpha}
#' \item \code{color}
#' \item \code{linetype}
#' \item \code{size}
#' }
#'
#' @inheritParams ggplot2::geom_point
#' @seealso The default stat for this geom is \code{\link{stat_km}} see
#' @seealso The default stat for this geom is [stat_km()] see
#' that documentation for more options to control the underlying statistical transformation.
#' @export
#' @examples
#' library(ggplot2)
#' set.seed(123)
#' sex <- rbinom(250, 1, .5)
#' df <- data.frame(time = exp(rnorm(250, mean = sex)), status = rbinom(250, 1, .75), sex = sex)
#' ggplot(df, aes(time = time, status = status, color = factor(sex))) + geom_km()
Expand All @@ -157,8 +158,8 @@ geom_km <- function(mapping = NULL, data = NULL, stat = "km",
#' \code{geom_kmband} understands the following aesthetics (required aesthetics
#' are in bold):
#' \itemize{
#' \item \strong{\code{x}} The survival/censoring times. This is automatically mapped by \link{stat_kmband}
#' \item \strong{\code{y}} The survival probability estimates. This is automatically mapped by \link{stat_kmband}
#' \item \strong{\code{x}} The survival/censoring times. This is automatically mapped by [stat_kmband()]
#' \item \strong{\code{y}} The survival probability estimates. This is automatically mapped by [stat_kmband()]
#' smallest level in sort order is assumed to be 0, with a warning
#' \item \code{alpha}
#' \item \code{color}
Expand All @@ -167,7 +168,7 @@ geom_km <- function(mapping = NULL, data = NULL, stat = "km",
#' }
#'
#' @inheritParams ggplot2::geom_point
#' @seealso The default stat for this geom is \code{\link{stat_kmband}} see
#' @seealso The default stat for this geom is [stat_kmband()]. See
#' that documentation for more options to control the underlying statistical transformation.
#' @export
#' @examples
Expand Down Expand Up @@ -196,8 +197,8 @@ geom_kmband <- function(mapping = NULL, data = NULL, stat = "kmband",
#' \code{geom_kmticks} understands the following aesthetics (required aesthetics
#' are in bold):
#' \itemize{
#' \item \strong{\code{x}} The survival/censoring times. This is automatically mapped by \link{stat_km}
#' \item \strong{\code{y}} The survival probability estimates. This is automatically mapped by \link{stat_km}
#' \item \strong{\code{x}} The survival/censoring times. This is automatically mapped by [stat_kmticks()]
#' \item \strong{\code{y}} The survival probability estimates. This is automatically mapped by [stat_kmticks()]
#' smallest level in sort order is assumed to be 0, with a warning
#' \item \code{alpha}
#' \item \code{color}
Expand All @@ -206,10 +207,9 @@ geom_kmband <- function(mapping = NULL, data = NULL, stat = "kmband",
#' }
#'
#' @inheritParams ggplot2::geom_point
#' @seealso The default stat for this geom is \code{\link{stat_kmticks}} see
#' @seealso The default stat for this geom is [stat_kmticks] see
#' that documentation for more options to control the underlying statistical transformation.
#' @export
#' @rdname geom_kmticks
#' @examples
#' library(ggplot2)
#' sex <- rbinom(250, 1, .5)
Expand Down Expand Up @@ -337,7 +337,7 @@ StatKmband <- ggplot2::ggproto("StatKmband", ggplot2::Stat,
#' to "identity". Other options include "event", "cumhaz", "cloglog", or
#' define your own using \link{trans_new}.
#' @param firstx,firsty the starting point for the survival curves. By default,
#' the plot program obeys tradition by having the plot start at (0,1).
#' the plot program obeys tradition by having the plot start at `(0,1)`.
#' @param start.time numeric value specifying a time to start calculating survival information.
#' The resulting curve is the survival conditional on surviving to start.time.
#' @param type an older argument that combined stype and ctype, now deprecated. Legal values were
Expand Down Expand Up @@ -412,7 +412,7 @@ stat_km <- function(mapping = NULL, data = NULL, geom = "km",
#' @inheritParams ggplot2::stat_identity
#' @param trans Transformation to apply to the survival probabilities. Defaults
#' to "identity". Other options include "event", "cumhaz", "cloglog", or
#' define your own using \link{trans_new}.
#' define your own using [scales::trans_new()].
#' @param firstx,firsty the starting point for the survival curves. By default,
#' the plot program obeys tradition by having the plot start at (0,1).
#' @inheritParams survival::survfit.formula
Expand Down
10 changes: 5 additions & 5 deletions R/ggkmrisktable.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ lung_long$facetdum <- "(all)"
.trim <- function(x){gsub("^\\s+|\\s+$", "", x)}
# from survminer

#' ggkmrisktable
#' Create a Kaplan-Meier plot with risk table
#'
#' Produces a km plot with a facettable risk table in ggplot2
#'
Expand Down Expand Up @@ -183,10 +183,10 @@ lung_long$facetdum <- "(all)"
#' dplyr::filter(!is.na(ph.karno))|>
#' dplyr::filter(!is.na(pat.karno))|>
#' dplyr::filter(!is.na(ph.ecog))
#'lung_long$ph.ecog <- ifelse(lung_long$ph.ecog>1,2,lung_long$ph.ecog)
#'lung_long$ph.ecog <- as.factor(lung_long$ph.ecog )
#'lung_long$ph.ecog <- as.factor(lung_long$ph.ecog )
#'lung_long$facetdum <- "(all)"
#' lung_long$ph.ecog <- ifelse(lung_long$ph.ecog>1,2,lung_long$ph.ecog)
#' lung_long$ph.ecog <- as.factor(lung_long$ph.ecog )
#' lung_long$ph.ecog <- as.factor(lung_long$ph.ecog )
#' lung_long$facetdum <- "(all)"
#'
#' ggkmrisktable(data = lung_long, time= "time", status ="DV",
#' exposure_metrics =c("age","ph.karno"),
Expand Down
10 changes: 5 additions & 5 deletions R/gglogisticexpdist.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ summary_df <- function(x,y, probs = c(0.25,0.75,0.90,0.10)) {
}
plogis <- function(x) exp(x)/(1+exp(x))

#' gglogisticexpdist
#' Create a logistic fit plot
#'
#' Produces a logistic fit plot with a facettable exposures/quantiles/distributions in ggplot2
#' @param data Data to use with multiple endpoints stacked into Endpoint(endpoint name), response 0/1
#' @param response name of the column holding the valuesresponse 0/1
#' @param response name of the column holding the values response 0/1
#' @param endpoint name of the column holding the name/key of the endpoint default to `Endpoint`
#' @param DOSE name of the column holding the DOSE values default to `DOSE`
#' @param color_fill name of the column to be used for color/fill default to DOSE column
Expand All @@ -40,7 +40,7 @@ plogis <- function(x) exp(x)/(1+exp(x))
#' @param xlab text to be used as x axis label
#' @param ylab text to be used as y axis label
#' @param prob_text_size probability text size default to 5
#' @param prob_obs_bydose observed probability by dose TRUE/FALSE
#' @param prob_obs_bydose observed probability by dose `TRUE`/`FALSE`
#' @param N_text_size N responders/Ntotal by exposure bin text size default to 5
#' @param binlimits_text_size 5 binlimits text size
#' @param binlimits_ypos binlimits y position default to 0
Expand All @@ -49,11 +49,11 @@ plogis <- function(x) exp(x)/(1+exp(x))
#' @param dist_offset offset where the distribution position starts 0
#' @param lineranges_ypos where to put the lineranges -1
#' @param lineranges_dodge lineranges vertical dodge value 1
#' @param yproj project the probabilities on y axis TRUE/FALSE
#' @param yproj project the probabilities on y axis `TRUE`/`FALSE`
#' @param yproj_xpos y projection x position 0
#' @param yproj_dodge y projection dodge value 0.2
#' @param yaxis_position where to put y axis "left" or "right"
#' @param facet_formula facet formula to be use otherwise endpoint ~ expname
#' @param facet_formula facet formula to be use otherwise `endpoint ~ expname`
#' @param theme_certara apply certara colors and format for strips and default colour/fill
#' @examples
#' # Example 1
Expand Down
2 changes: 2 additions & 0 deletions R/logisticdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
#' \item{ICGI7}{response 1 to 7}
#' }
#' @source inspired from a real data submission
#' @examples
#' logistic_data
"logistic_data"
12 changes: 6 additions & 6 deletions inst/shinyapp/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -6325,7 +6325,7 @@ function(input, output, session) {
p <- p +
scale_y_continuous(expand = expansionobjy,
breaks = waiver(),
labels = scales::percent_format())
labels = scales::label_percent())
}
if(input$yaxisformat=="scientificy"){
p <- p +
Expand All @@ -6348,7 +6348,7 @@ function(input, output, session) {
p <- p +
scale_x_continuous(expand = expansionobjx,
breaks = waiver(),
labels = scales::percent_format())
labels = scales::label_percent())
}
if(input$xaxisformat=="scientificx"){
p <- p +
Expand Down Expand Up @@ -6449,7 +6449,7 @@ function(input, output, session) {
input$yaxisformat=="percenty"){
if (!input$addrisktable){
p <- p +
scale_y_continuous(labels=scales::percent_format(), expand = expansionobjy)
scale_y_continuous(labels=scales::label_percent(), expand = expansionobjy)
}#norisktable
if (input$KM!="None" && input$addrisktable){
p <- p +
Expand Down Expand Up @@ -6526,7 +6526,7 @@ function(input, output, session) {
!input$customytickslabel &&
input$yaxisformat=="percenty" ) {
p <- p +
scale_y_continuous(labels=scales::percent_format(),
scale_y_continuous(labels=scales::label_percent(),
breaks=as.numeric(unique(unlist (strsplit(input$yaxisbreaks, ","))) ),
minor_breaks = as.numeric(unique(unlist (strsplit(input$yaxisminorbreaks, ","))) ) ,
expand = expansionobjy)
Expand Down Expand Up @@ -6637,12 +6637,12 @@ function(input, output, session) {
input$xaxisformat=="percentx"){
if(!input$customxticks){
p <- p +
scale_x_continuous(labels=scales::percent_format() ,
scale_x_continuous(labels=scales::label_percent() ,
expand = expansionobjx)
}
if(input$customxticks){
p <- p +
scale_x_continuous(labels=scales::percent_format(),
scale_x_continuous(labels=scales::label_percent(),
breaks=as.numeric(unique(unlist (strsplit(input$xaxisbreaks, ","))) ),
minor_breaks = as.numeric(unique(unlist (strsplit(input$xaxisminorbreaks, ","))) ),
expand = expansionobjx)
Expand Down
Loading

0 comments on commit d20a78f

Please sign in to comment.