Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .Rbuildignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
^CODE_OF_CONDUCT\.md$
^README\.Rmd$
^app\.R$
^R/surv_utils\.R$
^R/km_plot\.R$
^LICENSE\.md$
^.github$
Expand Down
Empty file modified .Rprofile
100644 → 100755
Empty file.
Empty file modified .github/.gitignore
100644 → 100755
Empty file.
Empty file modified .github/workflows/R-CMD-check.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/lint-changed-files.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/lint.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/pkgdown.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/styler.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/test-coverage.yaml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified CODE_OF_CONDUCT.md
100644 → 100755
Empty file.
69 changes: 69 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Contributing to {carver}

This outlines how to propose a change to {carver}.

## Making Changes

If you want to make a change, it's a good idea to first file an issue and make sure someone from the team agrees that it’s needed.
Per pfizer-opensource policies, only those listed as collaborators can raise issues.
If you’ve found a bug, please email the maintainer (`smriti.anand@pfizer.com`) illustrating the bug with a minimal
[reprex](https://www.tidyverse.org/help/#reprex) (this will also help you write a unit test, if needed).
Alternatively if you have access to the COSA community Slack channel for {carver}, you can raise it there.
See guide on [how to create a great issue](https://code-review.tidyverse.org/issues/) for more advice.

### Pull request process

* Fork the package and clone onto your computer.

* If needed, install all development dependencies with `devtools::install_dev_deps()`, and then make sure the package passes R CMD check by running `devtools::check()`.
If R CMD check doesn't pass cleanly, it's a good idea to ask for help before continuing.
* Create a Git branch for your pull request (PR).

* Make your changes, commit to git, and then create a PR.
The title of your PR should briefly describe the change.
The body of your PR should contain `Closes #issue-number`.

* For user-facing changes, add a bullet to the top of `NEWS.md` (i.e. just below the first header). Follow the style described in <https://style.tidyverse.org/news.html>.

### Code Style

* New code should follow the tidyverse [style guide](https://style.tidyverse.org).
You can use the [styler](https://CRAN.R-project.org/package=styler) package to apply these styles, but please don't restyle code that has nothing to do with your PR.

* To apply the appropriate style with styler please use `styler:::style_active_pkg()` or `styler::style_file()`

* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd-formatting.html), for documentation.

* We use [testthat](https://cran.r-project.org/package=testthat) for unit tests.
Contributions with test cases included are easier to accept.

* All helper/non-exported functions are documented with roxygen2 as indicated above.
Include `#' @keywords internal` to mark the function as internal.
Any helper functions that appear in examples will need to use the `carver:::`
prefix.

### Error Handling

TBD

### Package Dependencies

Additional package dependencies should be considered after exhausting other possibilities. If you do need to add one,
email the maintainer or collaborators/start a discussion to make a decision on the necessity of it.
Once agreed upon, the dependency can be added to the package via the relevant files.

## Scope

The {carver} package will be an open-source tool and package to enable generation of
common analysis reports (tables and interactive plots) for clinical
review and direct inclusion in submission for regulatory agencies

## Deprecation Cycle

TBD

## Code of Conduct

Please note that the carver project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this
project you agree to abide by its terms.
3 changes: 2 additions & 1 deletion DESCRIPTION
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Imports:
shinyjs (>= 2.1.0),
shinyWidgets (>= 0.7.6),
stringr (>= 1.5.0),
survival,
tibble (>= 3.2.1),
tidyr (>= 1.3.1)
Suggests:
Expand Down Expand Up @@ -65,4 +66,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Empty file modified LICENSE.md
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions NAMESPACE
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export(mentry)
export(msumstat)
export(multi_interval)
export(occ_tier_summary)
export(ph_plot)
export(plot_aes_opts)
export(plot_axis_opts)
export(plot_display_bign)
Expand All @@ -45,12 +46,15 @@ export(round_f)
export(run_app)
export(save_file)
export(scatter_plot)
export(schoenfeld_plot)
export(shape_to_sym)
export(split_data_by_var)
export(split_section_headers)
export(str_to_vec)
export(summary_functions)
export(summary_row_cat)
export(surv_pre_processor)
export(survfit_summary)
export(tbl_display)
export(tbl_processor)
export(tbl_risk_labels)
Expand All @@ -67,6 +71,7 @@ import(scales)
import(shiny)
import(shinyWidgets)
import(stringr)
import(survival)
import(tools)
importFrom(DT,addRow)
importFrom(DT,colReorder)
Expand Down
Empty file modified NEWS.md
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion R/adae_risk_summary.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ adae_risk_summary <- function(datain,
if (!is.na(cutoff_where) && str_detect(cutoff_where, "PCT|FREQ")) {
datain <- datain |>
left_join(select(ae_lsumm, all_of(c("BYVAR1", "CUTFL")), {{ lterm }} := "DPTVAL"),
by = c("BYVAR1", lterm)
by = c("BYVAR1", lterm), relationship = "many-to-many"
)
a_subset <- paste(na.omit(c(a_subset, "CUTFL == 'Y'")), collapse = "&")
}
Expand Down
Empty file modified R/adsl_summary.R
100644 → 100755
Empty file.
7 changes: 3 additions & 4 deletions R/ae_forestplot.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ ae_forest_plot <-
)
})
# Return single level list
return(flatten(nested_plots))
flatten(nested_plots)
}

#' Highlight Significant p-value points in forest plot
Expand Down Expand Up @@ -281,12 +281,11 @@ ae_forest_hlt_sig <- function(plotin,
aes(
x = .data[["PCT"]],
y = .data[["DPTVAL"]],
fill = .data[["EFFECT"]],
key = .data[["key"]]
fill = .data[["EFFECT"]]
),
inherit.aes = FALSE,
shape = 23,
size = pts_size,
linewidth = pts_size,
stroke = 0.2
) +
scale_fill_manual(name = "", values = hltfill)
Expand Down
2 changes: 1 addition & 1 deletion R/ae_pre_processor.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ae_pre_processor <- function(datain,
################### ENDax SEV/CTC##############

# Return processed dataframe and filter conditions
return(list(data = ungroup(data_pro), a_subset = filters))
list(data = ungroup(data_pro), a_subset = filters)
}

#' Create filter condition for Adverse Events from keyword
Expand Down
6 changes: 3 additions & 3 deletions R/ae_volcano_plot.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ ae_volcano_plot <- function(datain,
)
)
}
return(gplot)
gplot
}

#' Volcano Plot axis Options
Expand Down Expand Up @@ -276,8 +276,8 @@ Favors {trt2_label} (N={N2}) --->\n{statistic}"
}
refval <- ifelse(grepl("Ratio", statistic), 1, 0)
xref <- c(refval, refval - xref_offset, refval + xref_offset)
return(list(
list(
xaxis_label = xlab, yaxis_label = ylab,
ylinearopts = ylinearopts, yaxis_scale = ytrans, xref = xref
))
)
}
Empty file modified R/app_config.R
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion R/app_server.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ app_server <- function(input, output, session) {
removeUI("#readData")
runjs("Shiny.setInputValue('data_upload', true);")
}
}) %>%
}) |>
bindEvent(adam_read())

rep_inputs <- mod_report_selection_server(
Expand Down
Empty file modified R/app_ui.R
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion R/bar_plot.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ bar_plot <- function(datain,
g_plot <- g_plot + coord_flip()
}
message("Bar Plot Success")
return(g_plot)
g_plot
}
2 changes: 1 addition & 1 deletion R/box_plot.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ box_plot <- function(datain,
)
}
message("Box Plot Success")
return(g_plot)
g_plot
}
Empty file modified R/carver-package.R
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions R/data.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@
#'
#' @format Data frame with 7510 rows and 21 variables
"cm"

#' survival
#'
#' Test Data for Schoenfeld Plot, Kaplan-Meir Plot, ph plot
#'
#' @format List of data frames containing `adsl` and `adtte` dataset
"survival"
Empty file modified R/data_read.R
100644 → 100755
Empty file.
Empty file modified R/dataset_merge.R
100644 → 100755
Empty file.
Empty file modified R/edish_plot.R
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion R/event_analysis.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ event_plotly <- function(p, ref_line, title_text) {

#' Overwrite plotly line shape without using `shapes` argument in `plotly::layout()`
#'
#' This is due to an existing bug in `plotly`.[https://community.rstudio.com/t/drawing-lines-from-layouts-doesnt-work-on-ggplotly/54116] # nolint
#' This is due to an existing bug in `plotly`.<https://community.rstudio.com/t/drawing-lines-from-layouts-doesnt-work-on-ggplotly/54116> # nolint
#'
#' @param p `ggplot` object
#' @param ref_line Reference line
Expand Down
26 changes: 13 additions & 13 deletions R/event_interval.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ interval_plot <- function(datain,
xaxislab = "Start and End Study Day",
yaxislab = "") {
# Filter subject and get info
ad_plot <- datain %>%
filter(USUBJID == subjectid) %>%
ad_plot <- datain |>
filter(USUBJID == subjectid) |>
mutate(Status = case_when(
(is.na(get(startvar)) & get(endvar) >= 0) ~ "End Day",
(is.na(get(endvar)) & get(startvar) >= 0) ~ "Start Day",
(!is.na(get(startvar)) & !is.na(get(endvar))) ~ "Complete",
TRUE ~ "Remove"
)) %>%
)) |>
filter(Status != "Remove")
# Check if no data left and return accordingly
if (nrow(ad_plot) == 0) {
Expand All @@ -81,8 +81,8 @@ interval_plot <- function(datain,
series_color <- g_seriescol(ad_plot, series_color, seriesvar)
}
# Hover Information:
ad_plot <- ad_plot %>%
select(all_of(c("USUBJID", startvar, endvar, yvar, seriesvar, "Status"))) %>%
ad_plot <- ad_plot |>
select(all_of(c("USUBJID", startvar, endvar, yvar, seriesvar, "Status"))) |>
mutate(
HOVER_TEXT = paste0(
!!sym(yvar), "\n",
Expand All @@ -94,15 +94,15 @@ interval_plot <- function(datain,
!!yvar := as.factor(!!sym(yvar))
)
# Use data with both dates present for segment plot
segmentdata <- ad_plot %>%
segmentdata <- ad_plot |>
filter(Status == "Complete")

# Use data with either Start or end dates only for scatter plot
scatterdata <- ad_plot %>%
filter(Status != "Complete" | !!sym(startvar) == !!sym(endvar)) %>%
tidyr::pivot_longer(all_of(c(startvar, endvar)), names_to = "key", values_to = "Value") %>%
filter(!is.na(Value)) %>%
select(-key) %>%
scatterdata <- ad_plot |>
filter(Status != "Complete" | !!sym(startvar) == !!sym(endvar)) |>
tidyr::pivot_longer(all_of(c(startvar, endvar)), names_to = "key", values_to = "Value") |>
filter(!is.na(Value)) |>
select(-key) |>
distinct(.keep_all = TRUE)

# Create ggplot object - segment plot for Complete intervals and scatter for incomplete
Expand All @@ -127,7 +127,7 @@ interval_plot <- function(datain,
color = !!sym(seriesvar)
),
position = position_dodge(width = 0.3),
size = 1.2
linewidth = 1.2
)
# Convert to plotly object
splotly <- plotly::ggplotly(gplot, tooltip = "text")
Expand Down Expand Up @@ -168,5 +168,5 @@ interval_plot <- function(datain,
splotly$x$data[[i]]$legendgroup <- splotly$x$data[[i]]$name
if (!legdf$is_first[[i]]) splotly$x$data[[i]]$showlegend <- FALSE
}
return(list(plot = gplot, ptly = splotly, rpt_data = ad_plot))
list(plot = gplot, ptly = splotly, rpt_data = ad_plot)
}
8 changes: 4 additions & 4 deletions R/forest_plot.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ forest_plot_base <- function(datain,
) +
ggstance::geom_errorbarh(
height = 0.1,
position = ggstance::position_dodgev(height = 0.6), linewidth = 0.5
position = ggstance::position_dodgev(height = 0.6), size = 0.5
) +
geom_point(
shape = 22,
Expand Down Expand Up @@ -135,7 +135,7 @@ forest_plot_base <- function(datain,
alpha = 0.5
)
}
return(gplot)
gplot
}

#' Scatter plot to be included within forest plot
Expand Down Expand Up @@ -254,7 +254,7 @@ forest_plot_scatter <- function(datain,
alpha = 0.5
)
}
return(gplot)
gplot
}

#' Display combined Forest Plot
Expand Down Expand Up @@ -399,5 +399,5 @@ forest_display <- function(plot_list,
rel_heights = c(0.85, 0.075, 0.075)
)
}
return(combine_plot)
combine_plot
}
10 changes: 9 additions & 1 deletion R/global.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,13 @@ globalVariables(c(
"Value",
"ASEV",
"TA",
"REPTYPE"
"REPTYPE",
"pred.x",
"trt",
"yhat",
"xx",
"zy",
"ylow",
"yup",
"combn"
))
4 changes: 2 additions & 2 deletions R/graph_utils.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ series_leg_lab <- function(datain,
series_var = "TRTVAR",
series_labelvar = "TRTTXT") {
if (series_labelvar != series_var && is.factor(datain[[series_labelvar]])) {
return(sort(unique(datain[[series_labelvar]])))
sort(unique(datain[[series_labelvar]]))
} else {
return(waiver())
waiver()
}
}
Empty file modified R/km_plot.R
100644 → 100755
Empty file.
Empty file modified R/lab_abnormality.R
100644 → 100755
Empty file.
Empty file modified R/line_plot.R
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion R/mcatstat.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,5 @@ calc_denom <- function(counts,
df <- df |>
mutate(CVALUE = ifelse(FREQ == 0, "0", glue(cstat)))
}
return(df |> ungroup())
df |> ungroup()
}
Empty file modified R/mentry.R
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion R/mod_data_check.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mod_data_check_server <- function(id, sourcedata, domain) {
{
req(input$data_varlist)

data_lkup <- sourcedata()[[domain()]] %>%
data_lkup <- sourcedata()[[domain()]] |>
select(unlist(strsplit(paste(input$data_varlist, collapse = ","), ",")))

datatable(
Expand Down
2 changes: 1 addition & 1 deletion R/mod_data_read.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mod_data_read_server <-
ui_data_source = source(),
ui_adam_data = adam_data
)
}) %>%
}) |>
bindEvent(read_btn())
})
}
2 changes: 1 addition & 1 deletion R/mod_download_report.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod_download_report_server <- function(id, repType, repName, repNum, save_fmt, t
}
}
print("save report object created")
}) %>%
}) |>
bindEvent(list(repType(), toutput(), goutput(), save_fmt()))

observe({
Expand Down
Loading
Loading