ggsurvfit
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (19.0%) to scientific vocabulary
Last synced: 9 months ago
·
JSON representation
Repository
Basic Info
- Host: GitHub
- Owner: pharmaverse
- License: other
- Language: R
- Default Branch: main
- Homepage: http://www.danieldsjoberg.com/ggsurvfit/
- Size: 33.4 MB
Statistics
- Stars: 90
- Watchers: 5
- Forks: 23
- Open Issues: 16
- Releases: 7
Created almost 4 years ago
· Last pushed 9 months ago
Metadata Files
Readme
Changelog
Contributing
License
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
warning = FALSE
)
```
# ggsurvfit
[](https://github.com/pharmaverse/ggsurvfit/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/pharmaverse/ggsurvfit)
[](https://CRAN.R-project.org/package=ggsurvfit)
[](https://cran.r-project.org/package=ggsurvfit)
[
](https://pharmaverse.org)
## Introduction
The **ggsurvfit** package eases the creation of time-to-event (aka survival) summary figures with ggplot2.
The concise and modular code creates images that are ready for publication or sharing.
Competing risks cumulative incidence is also supported via `ggcuminc()`.
## Why ggsurvfit?
- **Use ggplot2 functions:** Each **ggsurvfit** add-on function (e.g. `add_confidence_interval()`, `add_risktable()`, etc.) is written as a proper ggplot2 ['geom'](https://ggplot2.tidyverse.org/reference/index.html), meaning the package functions can be woven with ggplot2 functions seamlessly. You don't need to learn how to style the plot within the ggsurvfit functions: rather, rely on the suite of ggplot2 functions you already know.
- **Publishable Legends:** Raw variable names do not appear in the figure legend, e.g. `"sex=Female"`.
- **Limitless Customization:** You can modify the x-axis scales or any other plot feature and the risk table will still align with the plot.
- **Simple Saving:** Save individual images easily with `ggplot2::ggsave()`.
## Installation
Install **ggsurvfit** from CRAN with:
```r
install.packages("ggsurvfit")
```
You can install the development version from [GitHub](https://github.com/pharmaverse/ggsurvfit) with:
``` r
# install.packages("devtools")
devtools::install_github("pharmaverse/ggsurvfit")
```
## Examples
Review the [**figure gallery**](https://www.danieldsjoberg.com/ggsurvfit/articles/gallery.html) for many more examples.
The code below constructs a basic {ggsurvfit} figure without customization.
```{r example, fig.height=5.5}
library(ggsurvfit)
p <- survfit2(Surv(time, status) ~ surg, data = df_colon) |>
ggsurvfit(linewidth = 1) +
add_confidence_interval() +
add_risktable() +
add_quantile(y_value = 0.6, color = "gray50", linewidth = 0.75) +
scale_ggsurvfit()
```
Any figure created with {ggsurvfit} can be customized using {ggplot2} functions.
```{r}
p +
# limit plot to show 8 years and less
coord_cartesian(xlim = c(0, 8)) +
# update figure labels/titles
labs(
y = "Percentage Survival",
title = "Recurrence by Time From Surgery to Randomization",
)
```
## `survfit2()` vs `survfit()`
Both functions have identical inputs, so why do we need `survfit2()`?
The `survfit2()` tracks the environment from which the function was called, resulting in the following benefits.
- We can reliably remove the raw variable names from the figure legend, e.g. `SEX=Female`.
- P-values can be calculated with `survfit_p()` and added to figures.
- The items above are often *possible* using `survfit()`. However, by utilizing the calling [environment](https://adv-r.hadley.nz/environments.html) we are assured the correct elements are found, rather than crossing our fingers that the search path contains the needed elements.
## CDISC ADaM ADTTE
The package also includes gems for those using the [CDISC ADaM ADTTE v1.0](https://www.cdisc.org/standards/foundational/adam/adam-basic-data-structure-bds-time-event-tte-analyses-v1-0) data model.
If columns `"PARAM"` or `"PARAMCD"` are present in the data frame passed to `survfit2()`, their values will be used to construct default labels in the `ggsurvfit()` figure.
The event indicator in ADTTE data sets is named `"CNSR"` and is coded in the opposite way the survival package expects outcomes---`1 = 'censored'` and `0 = 'event'`.
This difference creates an opportunity for errors to be introduced in an analysis.
The **ggsurvfit** package exports a function called `Surv_CNSR()` to resolve this concern.
The function creates a survival object (e.g. `survival::Surv()`) that uses CDISC ADaM ADTTE coding conventions as the default values.
The function can be used in **ggsurvfit** as well as any other package that uses `survival::Surv()`.
```{r}
survfit(Surv_CNSR() ~ 1, adtte)
```
## Related Packages
```{r, related-pkgs, echo = FALSE}
gt_related_pkgs <-
dplyr::tribble(
~pkg, ~cran, ~survfit, ~survfit_risktable, ~cmprsk, ~cmprsk_risktable, ~ggplot2, ~gh_owner, ~gh_repo, ~gh_branch,
"ggsurvfit", "X", "X", "X", "X", "X", "X", "pharmaverse", "ggsurvfit", "main",
"survminer", "X", "X", "X", "X", "", "", "kassambara", "survminer", "master",
"KMunicate", "X", "X", "X", "", "", "", "ellessenne", "KMunicate-package", "master",
"GGally", "X", "X", "", "", "", "", "ggobi", "ggally", "master",
"ggfortify", "X", "X", "", "", "", "", "sinhrks", "ggfortify", "master",
"iwillsurvive", "", "X", "X", "", "", "", "ndphillips", "iwillsurvive", "master"
) |>
dplyr::mutate(
covr_badge =
sprintf(
"",
glue::glue("https://codecov.io/gh/{gh_owner}/{gh_repo}/branch/{gh_branch}/graph/badge.svg")
)
) |>
dplyr::select(-dplyr::starts_with("gh_")) |>
gt::gt() |>
gt::cols_label(
pkg = gt::md("**Package**"),
cran = gt::md("**CRAN**"),
survfit = gt::md("**Estimates**"),
survfit_risktable = gt::md("**Risktable**"),
cmprsk = gt::md("**Estimates**"),
cmprsk_risktable = gt::md("**Risktable**"),
ggplot2 = gt::md("**{ggplot2} \nIntegration**"),
covr_badge = gt::md("**Code Coverage**")
) |>
gt::tab_spanner(c(survfit, survfit_risktable), label = gt::md("**Kaplan-Meier**")) |>
gt::tab_spanner(c(cmprsk, cmprsk_risktable), label = gt::md("**Competing Risks**")) |>
gt::fmt_markdown(c(pkg, covr_badge)) |>
gt::tab_footnote(
footnote = "Use any {ggplot2} function to modify plot area (including scales) and the risktable will align with the plot.",
locations = gt::cells_column_labels(ggplot2)
) |>
gt::text_transform(
locations =
gt::cells_body(columns = c(cran, survfit, survfit_risktable, cmprsk, cmprsk_risktable, ggplot2)),
fn = function(x) {
ifelse(x == "X", emoji::emoji("check_mark"), x)
}
) |>
gt::cols_align(align = "center", columns = c(cran, survfit, survfit_risktable, cmprsk, cmprsk_risktable, ggplot2)) |>
gt::tab_options(table.font.size = 13, data_row.padding = gt::px(1),
summary_row.padding = gt::px(1), grand_summary_row.padding = gt::px(1),
footnotes.padding = gt::px(1), source_notes.padding = gt::px(1),
row_group.padding = gt::px(1))
```
```{r related-pkgs-save, include = FALSE}
gt::gtsave(gt_related_pkgs, filename = here::here("man", "figures" , "README-gt-related-pkgs.png"))
```
```{r echo=FALSE}
knitr::include_graphics(path = here::here("man", "figures" , "README-gt-related-pkgs.png"))
```
Owner
- Name: pharmaverse
- Login: pharmaverse
- Kind: organization
- Location: Switzerland
- Repositories: 25
- Profile: https://github.com/pharmaverse
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "ggsurvfit",
"description": "Ease the creation of time-to-event (i.e. survival) endpoint figures. The modular functions create figures ready for publication. Each of the functions that add to or modify the figure are written as proper 'ggplot2' geoms or stat methods, allowing the functions from this package to be combined with any function or customization from 'ggplot2' and other 'ggplot2' extension packages.",
"name": "ggsurvfit: Easy and Flexible Time-to-Event Figures",
"relatedLink": [
"http://www.danieldsjoberg.com/ggsurvfit/",
"https://CRAN.R-project.org/package=ggsurvfit"
],
"codeRepository": "https://github.com/ddsjoberg/ggsurvfit",
"issueTracker": "https://github.com/ddsjoberg/ggsurvfit/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.0.9001",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.2.1 (2022-06-23 ucrt)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"author": [
{
"@type": "Person",
"givenName": "Daniel D.",
"familyName": "Sjoberg",
"email": "danield.sjoberg@gmail.com",
"@id": "https://orcid.org/0000-0003-0862-2018"
},
{
"@type": "Person",
"givenName": "Mark",
"familyName": "Baillie",
"email": "bailliem@gmail.com"
}
],
"copyrightHolder": [
{
"@type": "Person",
"givenName": "Daniel D.",
"familyName": "Sjoberg",
"email": "danield.sjoberg@gmail.com",
"@id": "https://orcid.org/0000-0003-0862-2018"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Daniel D.",
"familyName": "Sjoberg",
"email": "danield.sjoberg@gmail.com",
"@id": "https://orcid.org/0000-0003-0862-2018"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "covr",
"name": "covr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=covr"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "scales",
"name": "scales",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=scales"
},
{
"@type": "SoftwareApplication",
"identifier": "spelling",
"name": "spelling",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=spelling"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "tidycmprsk",
"name": "tidycmprsk",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidycmprsk"
},
{
"@type": "SoftwareApplication",
"identifier": "vdiffr",
"name": "vdiffr",
"version": ">= 1.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=vdiffr"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.5"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "broom",
"name": "broom",
"version": ">= 1.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=broom"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "cli",
"name": "cli",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=cli"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"version": ">= 1.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "glue",
"name": "glue",
"version": ">= 1.6.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=glue"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "ggplot2",
"name": "ggplot2",
"version": ">= 3.3.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ggplot2"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "gtable",
"name": "gtable",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=gtable"
},
"8": {
"@type": "SoftwareApplication",
"identifier": "patchwork",
"name": "patchwork",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=patchwork"
},
"9": {
"@type": "SoftwareApplication",
"identifier": "rlang",
"name": "rlang",
"version": ">= 1.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rlang"
},
"10": {
"@type": "SoftwareApplication",
"identifier": "survival",
"name": "survival",
"version": ">= 3.4-0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=survival"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "tidyr",
"name": "tidyr",
"version": ">= 1.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tidyr"
},
"SystemRequirements": null
},
"fileSize": "2577.806KB",
"releaseNotes": "https://github.com/ddsjoberg/ggsurvfit/blob/master/NEWS.md",
"readme": "https://github.com/ddsjoberg/ggsurvfit/blob/main/README.md",
"contIntegration": [
"https://github.com/ddsjoberg/ggsurvfit/actions/workflows/R-CMD-check.yaml",
"https://app.codecov.io/gh/ddsjoberg/ggsurvfit?branch=main"
],
"developmentStatus": "https://lifecycle.r-lib.org/articles/stages.html#experimental"
}
GitHub Events
Total
- Create event: 11
- Issues event: 21
- Watch event: 15
- Delete event: 5
- Member event: 1
- Issue comment event: 51
- Push event: 48
- Pull request review event: 40
- Pull request review comment event: 38
- Pull request event: 26
- Fork event: 1
Last Year
- Create event: 11
- Issues event: 21
- Watch event: 15
- Delete event: 5
- Member event: 1
- Issue comment event: 51
- Push event: 48
- Pull request review event: 40
- Pull request review comment event: 38
- Pull request event: 26
- Fork event: 1
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Daniel Sjoberg | d****g@g****m | 285 |
| Mark Baillie | b****m@g****m | 8 |
| Dan Chaltiel | d****l@g****m | 2 |
| Teun van den Brand | 4****d | 1 |
| Matt Secrest | m****t@g****m | 1 |
| Kirina Sirohi | 8****7 | 1 |
| Avishai M Tsur | 5****r | 1 |
| Alan Haynes | a****s | 1 |
Packages
- Total packages: 1
-
Total downloads:
- cran 4,306 last-month
- Total docker downloads: 131
- Total dependent packages: 2
- Total dependent repositories: 1
- Total versions: 7
- Total maintainers: 1
cran.r-project.org: ggsurvfit
Flexible Time-to-Event Figures
- Homepage: https://github.com/pharmaverse/ggsurvfit
- Documentation: http://cran.r-project.org/web/packages/ggsurvfit/ggsurvfit.pdf
- License: MIT + file LICENSE
-
Latest release: 1.1.0
published about 2 years ago
Rankings
Downloads: 5.7%
Forks count: 6.3%
Stargazers count: 7.2%
Average: 13.1%
Docker downloads count: 17.3%
Dependent packages count: 18.1%
Dependent repos count: 23.8%
Maintainers (1)
Last synced:
9 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.5 depends
- broom >= 1.0.0 imports
- cli >= 3.0.0 imports
- dplyr >= 1.0.0 imports
- ggplot2 >= 3.3.0 imports
- gtable * imports
- patchwork * imports
- rlang >= 1.0.0 imports
- survival >= 3.4 imports
- tidyr >= 1.0.0 imports
- covr * suggests
- glue * suggests
- knitr * suggests
- rmarkdown * suggests
- scales * suggests
- spelling * suggests
- testthat >= 3.0.0 suggests
- tidycmprsk * suggests
- vdiffr >= 1.0.0 suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action 4.1.4 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite