Skip to content

Commit

Permalink
customize issue templates for GH (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinteractive authored Mar 11, 2024
1 parent 86e0373 commit 3fa9c60
Show file tree
Hide file tree
Showing 24 changed files with 372 additions and 144 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ init.sh
workflows.md
images
^data-raw$
^\.gitleaksignore$
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: 🐞 Bug Report
description: File a bug report
title: "[Bug]: <title>"
labels: ["bug"]
assignees:
- danielinteractive
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
- type: checkboxes
id: code-of-conduct
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct.](https://github.com/insightsengineering/.github/blob/main/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct.
required: true
- type: checkboxes
id: contributor-guidelines
attributes:
label: Contribution Guidelines
description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://github.com/insightsengineering/.github/blob/main/CONTRIBUTING.md)
options:
- label: I agree to follow this project's Contribution Guidelines.
required: true
- type: checkboxes
id: security-policy
attributes:
label: Security Policy
description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/.github/security/policy)
options:
- label: I agree to follow this project's Security Policy.
required: true
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
blank_issues_enabled: true

contact_links:
- name: We are hiring!
url: https://careers.gene.com/
about: Genentech and Roche are hiring!
- name: openstatsware
url: https://openstatsware.org/
about: Software Engineering in Biostatistics
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: ✨ Feature Request
description: Request or propose a new feature
title: "[Feature Request]: <title>"
labels: ["enhancement"]
assignees:
- danielinteractive
body:
- type: textarea
attributes:
label: Feature description
validations:
required: true
- type: checkboxes
id: code-of-conduct
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct.](https://github.com/insightsengineering/.github/blob/main/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct.
required: true
- type: checkboxes
id: contributor-guidelines
attributes:
label: Contribution Guidelines
description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://github.com/insightsengineering/.github/blob/main/CONTRIBUTING.md)
options:
- label: I agree to follow this project's Contribution Guidelines.
required: true
- type: checkboxes
id: security-policy
attributes:
label: Security Policy
description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/.github/security/policy)
options:
- label: I agree to follow this project's Security Policy.
required: true
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: ❓ Question
description: Question about usage or documentation
title: "[Question]: <title>"
labels: ["question"]
assignees:
- danielinteractive
body:
- type: textarea
attributes:
label: What is your question?
validations:
required: true
- type: checkboxes
id: code-of-conduct
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct.](https://github.com/insightsengineering/.github/blob/main/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct.
required: true
- type: checkboxes
id: contributor-guidelines
attributes:
label: Contribution Guidelines
description: By submitting this issue, you agree to follow our [Contribution Guidelines.](https://github.com/insightsengineering/.github/blob/main/CONTRIBUTING.md)
options:
- label: I agree to follow this project's Contribution Guidelines.
required: true
- type: checkboxes
id: security-policy
attributes:
label: Security Policy
description: By submitting this issue, you agree to follow our [Security Policy.](https://github.com/insightsengineering/.github/security/policy)
options:
- label: I agree to follow this project's Security Policy.
required: true
2 changes: 2 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
R/RcppExports.R:generic-api-key:2
src/RcppExports.cpp:generic-api-key:2
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
Type: Package
Package: shrinkforest
Title: Shrinkage based Forest Plots
Title: Shrinkage Based Forest Plots
Version: 0.0.0.9033
Date: 2023-02-28
Date: 2024-03-07
Authors@R:
person("Mar", "Vazquez Rabunal", , "mar.vazquez_rabunal@roche.com", role = c("aut", "cre"))
c(
person("Mar", "Vazquez Rabunal", , "mar.vazquez_rabunal@roche.com", role = c("aut", "cre")),
person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@roche.com", role = "aut")
)
Description: Subgroup analyses are routinely performed in clinical trial
analyses. From a methodological perspective, two key issues of
subgroup analyses are multiplicity (even if only predefined subgroups
Expand Down Expand Up @@ -49,4 +52,4 @@ Language: en-US
LazyData: true
LazyDataCompression: xz
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
16 changes: 11 additions & 5 deletions R/generate_stacked_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,24 @@ generate_stacked_data <- function(base_model, subgroup_model, data,
}
tmp <- lapply(data[, subgroup_vars], function(x) levels(factor(x)))
subgroup_names <- paste(rep(names(tmp), lapply(tmp, length)),
unlist(tmp), sep = ".")
unlist(tmp),
sep = "."
)
data <- data[, c(arm_var, resp_var, status_var, subgroup_vars)]
data[, subgroup_vars] <- lapply(data[, subgroup_vars], as.character)
d <- tidyr::gather(data, "subgroup_var", "subgroup_value",
-arm_var, -resp_var, -status_var)
d <- tidyr::gather(
data, "subgroup_var", "subgroup_value",
-arm_var, -resp_var, -status_var
)
subgroup <- paste(d$subgroup_var, d$subgroup_value, sep = ".")
subgroup <- factor(subgroup, levels = subgroup_names)
d <- cbind(d, subgroup)
d <- dplyr::arrange(d, subgroup)
d <- if (resptype == "survival") {
dplyr::rename_at(d, dplyr::vars(c(arm_var, resp_var, status_var)),
~ c("arm", "time", "status"))
dplyr::rename_at(
d, dplyr::vars(c(arm_var, resp_var, status_var)),
~ c("arm", "time", "status")
)
} else if (resptype == "binary") {
dplyr::rename_at(d, dplyr::vars(c(arm_var, resp_var)), ~ c("arm", "y"))
}
Expand Down
19 changes: 10 additions & 9 deletions R/horseshoe.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#' @examples
#' horseshoe("ev_pfs", "arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"),
#' example_data, "binary",
#' chains = 1, seed = 0, control = list(adapt_delta = 0.95)
#' chains = 1, seed = 0, control = list(adapt_delta = 0.95),
#' iter = 50 # In practice, you need to omit this or set it much higher!
#' )
horseshoe <- function(resp, trt, subgr, covars, data,
resptype = c("survival", "binary"), status = NULL,
Expand Down Expand Up @@ -75,9 +76,12 @@ horseshoe <- function(resp, trt, subgr, covars, data,
design_main <- prep_data$design_main[, -1]
design_matrix <- cbind(design_main, prep_data$design_ia)
form <- stats::as.formula(paste(resp, " ~ a + b"))
form_a <- stats::as.formula(paste("a ~ 1 +", paste0(colnames(design_main),
collapse = " + "
)))
form_a <- stats::as.formula(
paste(
"a ~ 1 +",
paste0(colnames(design_main), collapse = " + ")
)
)
y <- as.data.frame(data[[resp]])
colnames(y) <- resp
data_model <- cbind(design_matrix, y)
Expand All @@ -90,11 +94,8 @@ horseshoe <- function(resp, trt, subgr, covars, data,
brms::lf(form_b),
data = data_model,
family = family,
brms::prior(normal(0, 5), class = "b", nlpar = "a") +
brms::prior(horseshoe(1),
class = "b",
nlpar = "b"
),
brms::prior_string("normal(0, 5)", class = "b", nlpar = "a") +
brms::prior_string("horseshoe(1)", class = "b", nlpar = "b"),
...
)
}
Expand Down
16 changes: 10 additions & 6 deletions R/lOR_estimation.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ lor_estimation <- function(x_subg, dummy_subg, est_coef) {
assert_matrix(dummy_subg)
assert_matrix(est_coef)
x_arm <- list()
for (i in 0:1){
x_arm[[i + 1]] <- cbind(rep(1, nrow(x_subg)), rep(i, nrow(x_subg)),
x_subg[, 2:(ncol(x_subg) - ncol(dummy_subg))], i * dummy_subg)
for (i in 0:1) {
x_arm[[i + 1]] <- cbind(
rep(1, nrow(x_subg)), rep(i, nrow(x_subg)),
x_subg[, 2:(ncol(x_subg) - ncol(dummy_subg))], i * dummy_subg
)
}
prob <- function(x, est_coef) {
k <- as.matrix(x) %*% as.matrix(est_coef)
k <- as.matrix(x) %*% as.matrix(est_coef)
p <- exp(k) / (1 + exp(k))
y <- apply(p, 2, mean)
y
}
y_arm <- lapply(x_arm, prob, est_coef = est_coef)
phi <- as.numeric(log(y_arm[[2]] / (1 - y_arm[[2]])) -
log(y_arm[[1]] / (1 - y_arm[[1]])))
phi <- as.numeric(
log(y_arm[[2]] / (1 - y_arm[[2]])) -
log(y_arm[[1]] / (1 - y_arm[[1]]))
)
phi
}
54 changes: 41 additions & 13 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@ plot.summary.naive <- function(x, ...) {
data$subgroup <- as.factor(data$subgroup)
forestplot <- ggplot(
data = data,
aes(x = trt.estimate, y = model, xmin = trt.low, xmax = trt.high)
aes(
x = .data$trt.estimate,
y = .data$model,
xmin = .data$trt.low,
xmax = .data$trt.high
)
) +
ggtitle("Forest plot Naive") +
geom_pointrange(aes(col = model)) +
geom_pointrange(aes(col = .data$model)) +
ylab("Subgroup") +
geom_errorbar(aes(xmin = trt.low, xmax = trt.high, col = model), width = 0.5, cex = 1) +
geom_errorbar(
aes(
xmin = .data$trt.low,
xmax = .data$trt.high,
col = .data$model
),
width = 0.5, cex = 1
) +
facet_wrap(~ forcats::fct_inorder(subgroup),
strip.position = "left",
nrow = nrow(data), scales = "free_y"
Expand Down Expand Up @@ -70,10 +82,10 @@ plot.summary.elastic_net <- function(x, ...) {
data$subgroup <- as.factor(data$subgroup)
forestplot <- ggplot(
data = data,
aes(x = trt.estimate, y = model)
aes(x = .data$trt.estimate, y = .data$model)
) +
ggtitle("Forest plot Elastic Net") +
geom_point(aes(col = model)) +
geom_point(aes(col = .data$model)) +
ylab("Subgroup") +
facet_wrap(~ forcats::fct_inorder(subgroup),
strip.position = "left",
Expand Down Expand Up @@ -117,12 +129,25 @@ plot.summary.horseshoe <- function(x, ...) {
data$subgroup <- as.factor(data$subgroup)
forestplot <- ggplot(
data = data,
aes(x = trt.estimate, y = model, xmin = trt.low, xmax = trt.high)
aes(
x = .data$trt.estimate,
y = .data$model,
xmin = .data$trt.low,
xmax = .data$trt.high
)
) +
ggtitle("Forest plot Horseshoe") +
geom_pointrange(aes(col = model)) +
geom_pointrange(aes(col = .data$model)) +
ylab("Subgroup") +
geom_errorbar(aes(xmin = trt.low, xmax = trt.high, col = model), width = 0.5, cex = 1) +
geom_errorbar(
aes(
xmin = .data$trt.low,
xmax = .data$trt.high,
col = .data$model
),
width = 0.5,
cex = 1
) +
facet_wrap(~ forcats::fct_inorder(subgroup),
strip.position = "left",
nrow = nrow(data), scales = "free_y"
Expand Down Expand Up @@ -170,16 +195,19 @@ plot.compare.data <- function(x, ...) {
forestplot <- ggplot(
data = data,
aes(
x = trt.estimate, y = forcats::fct_rev(forcats::fct_inorder(model)), xmin = trt.low,
xmax = trt.high
x = .data$trt.estimate,
y = forcats::fct_rev(forcats::fct_inorder(.data$model)),
xmin = .data$trt.low,
xmax = .data$trt.high
)
) +
ggtitle("Forest plot") +
geom_pointrange(aes(col = forcats::fct_inorder(model))) +
geom_pointrange(aes(col = forcats::fct_inorder(.data$model))) +
ylab("Subgroup") +
geom_errorbar(aes(
xmin = trt.low, xmax = trt.high,
col = forcats::fct_inorder(model)
xmin = .data$trt.low,
xmax = .data$trt.high,
col = forcats::fct_inorder(.data$model)
), width = 0.5, cex = 1) +
facet_wrap(~ forcats::fct_inorder(subgroup),
strip.position = "left",
Expand Down
2 changes: 1 addition & 1 deletion R/trt_horseshoe.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @export
#'
#' @examples
#' trt_horseshoe(horseshoe_fit_surv)
#' trt_horseshoe(horseshoe_fit_surv, m = 5)
trt_horseshoe <- function(object, gamma = 1, l = NULL, m = 50) {
assert_class(object, c("shrinkforest", "horseshoe"))
assert_int(m)
Expand Down
18 changes: 12 additions & 6 deletions data-raw/elastic_net_fit_surv.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
elastic_net_fit_surv <- elastic_net("tt_pfs", "arm", c("x_1", "x_2", "x_3",
"x_4", "x_5", "x_6", "x_7",
"x_8", "x_9", "x_10"),
c("x_1", "x_2", "x_3", "x_4", "x_5", "x_6",
"x_7", "x_8", "x_9", "x_10"),
example_data, "survival", 1, "ev_pfs")
elastic_net_fit_surv <- elastic_net(
"tt_pfs", "arm", c(
"x_1", "x_2", "x_3",
"x_4", "x_5", "x_6", "x_7",
"x_8", "x_9", "x_10"
),
c(
"x_1", "x_2", "x_3", "x_4", "x_5", "x_6",
"x_7", "x_8", "x_9", "x_10"
),
example_data, "survival", 1, "ev_pfs"
)
usethis::use_data(elastic_net_fit_surv, compress = "xz", overwrite = TRUE)
3 changes: 2 additions & 1 deletion data-raw/est_coef_bin1.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
est_coef_bin1 <- as.matrix(coef(elastic_net_fit_bin$fit,
s = elastic_net_fit_bin$fit$lambda.min))
s = elastic_net_fit_bin$fit$lambda.min
))
usethis::use_data(est_coef_bin1, overwrite = TRUE)
Loading

0 comments on commit 3fa9c60

Please sign in to comment.