Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gravesti committed Jun 21, 2024
1 parent ff94b85 commit bfecd49
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 116 deletions.
5 changes: 3 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#' \describe{
#' \item{USUBJID}{Unique subject identifiers for patients.}
#' \item{ARM}{Assigned treatment arm, `"A"`.}
#' \item{EVNT}{Event indicator `0`/`1`.}
#' \item{AVAL}{Analysis value which in this dataset overall survival time in days.}
#' \item{AVALU}{Unit of `AVAL`.}
#' \item{PARAMCD}{Paramater code of `AVAL`, `"OS"`.}
Expand Down Expand Up @@ -67,6 +66,7 @@
#' \item{SEX_MALE_CENTERED}{`SEX_MALE` centered by the proportion of male patients in [agd]}
#' \item{ECOG0_CENTERED}{`ECOG0` centered by the proportion of `ECOG0` in [agd]}
#' \item{SMOKE_CENTERED}{`SMOKE` centered by the proportion of `SMOKE` in [agd]}
#' \item{N_PR_THER_MEDIAN_CENTERED}{`N_PR_THER` centered by the median in [agd].}
#' }
#' @family unanchored datasets
#' @keywords dataset
Expand Down Expand Up @@ -116,6 +116,7 @@
#' \item{SEX_MALE_COUNT}{Number of male patients}
#' \item{ECOG0_COUNT}{Number of patients with ECOG score = 0}
#' \item{SMOKE_COUNT}{Number of smokers}
#' \item{N_PR_THER_MEDIAN}{Median number of prior therapies}
#' }
#' @family unanchored datasets
#' @family anchored datasets
Expand Down Expand Up @@ -147,7 +148,6 @@
#' \describe{
#' \item{USUBJID}{Unique subject identifiers for patients.}
#' \item{ARM}{Assigned treatment arm, `"A"`, `"C"`.}
#' \item{EVNT}{Event indicator `0`/`1`.}
#' \item{AVAL}{Analysis value which in this dataset overall survival time in days.}
#' \item{AVALU}{Unit of `AVAL`.}
#' \item{PARAMCD}{Parameter code of `AVAL`, `"OS"`.}
Expand Down Expand Up @@ -202,6 +202,7 @@
#' \item{SEX_MALE_CENTERED}{`SEX_MALE` centered by the proportion of male patients in [agd]}
#' \item{ECOG0_CENTERED}{`ECOG0` centered by the proportion of `ECOG0` in [agd]}
#' \item{SMOKE_CENTERED}{`SMOKE` centered by the proportion of `SMOKE` in [agd]}
#' \item{N_PR_THER_MEDIAN_CENTERED}{`N_PR_THER` centered by the median in [agd].}
#' }
#' @keywords dataset
#' @family anchored datasets
Expand Down
2 changes: 1 addition & 1 deletion data-raw/dummy_anchored.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ adtte <- read.csv(system.file("extdata", "adtte.csv",
mustWork = TRUE
))
adtte$TIME <- adtte$AVAL
adtte$EVENT <- adtte$EVNT
adtte$EVENT <- 1 - adtte$CNSR
adtte$USUBJID <- paste0("xx", adtte$USUBJID)

adtte2 <- adtte
Expand Down
2 changes: 1 addition & 1 deletion data-raw/dummy_unanchored.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ adtte_sat <- read.csv(system.file("extdata", "adtte.csv",
mustWork = TRUE
))
adtte_sat$TIME <- adtte_sat$AVAL
adtte_sat$EVENT <- adtte_sat$EVNT
adtte_sat$EVENT <- 1 - adtte_sat$CNSR
adtte_sat <- adtte_sat[adtte_sat$ARM == "A", , drop = FALSE]
adsl_sat <- adsl_sat[adsl_sat$USUBJID %in% adtte_sat$USUBJID, , drop = FALSE]

Expand Down
Binary file modified data/agd.rda
Binary file not shown.
Binary file modified data/centered_ipd_sat.rda
Binary file not shown.
Binary file modified data/centered_ipd_twt.rda
Binary file not shown.
Binary file modified data/weighted_sat.rda
Binary file not shown.
49 changes: 25 additions & 24 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
ADTTE
ADaM
AgD
Azocar
Bucher
Comparator
DSU
ECOG
ESS
IPD
Kaplan
MAIC
Paramater
Phillippo
Pre
Remiro
Schoenfeld
Signorovitch
TSD
TTE
Texp
USUBJID
Unanchored
Univariable
XXXX
adrs
adsl
ADTTE
adtte
AgD
agd
agg
al
Azocar
binarize
Bucher
Comparator
comparator
confounders
csv
DSU
dummize
dummized
ECOG
ESS
et
frac
ggplot
glm
hta
initializer
IPD
ipd
Kaplan
MAIC
multivariable
optim
Paramater
pharma
Phillippo
phillippo
Pre
pre
preprocessed
Remiro
reproducibility
Schoenfeld
sd
Signorovitch
signorovitch
Texp
THER
TSD
TTE
tte
Unanchored
unanchored
Univariable
unscaled
unstacked
USUBJID
vcovHC
XXXX
47 changes: 13 additions & 34 deletions inst/examples/kmplot_anchored_ex.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,19 @@

### IPD
# Read in relevant ADaM data and rename variables of interest
adsl <- read.csv(system.file("extdata", "adsl.csv",
package = "maicplus",
mustWork = TRUE
))
adtte <- read.csv(system.file("extdata", "adtte.csv",
package = "maicplus",
mustWork = TRUE
))
adtte$TIME <- adtte$AVAL
adtte$EVENT <- adtte$EVNT
adtte2 <- adtte
adtte2$ARM <- "C"
adtte2$TIME <- adtte2$TIME + 7
adtte <- rbind(adtte, adtte2)
adsl_twt
adtte_twt

### AgD
# Baseline aggregate data for the comparator population
target_pop <- read.csv(system.file("extdata", "aggregate_data_example_1.csv",
package = "maicplus", mustWork = TRUE
))
agd

# for time-to-event endpoints, pseudo IPD from digitalized KM
pseudo_ipd <- read.csv(system.file("extdata", "psuedo_IPD.csv",
package = "maicplus",
mustWork = TRUE
))
pseudo_ipd$ARM <- "B"
pseudo_ipd2 <- pseudo_ipd
pseudo_ipd2$ARM <- "C"
pseudo_ipd2$Time <- pseudo_ipd2$Time + 5
pseudo_ipd <- rbind(pseudo_ipd, pseudo_ipd2)
pseudo_ipd_twt

#### prepare data
target_pop <- process_agd(target_pop)
adsl <- dummize_ipd(adsl, dummize_cols = c("SEX"), dummize_ref_level = c("Female"))
target_pop <- process_agd(agd)
adsl <- dummize_ipd(adsl_twt, dummize_cols = c("SEX"), dummize_ref_level = c("Female"))
use_adsl <- center_ipd(ipd = adsl, agd = target_pop)

#### derive weights
Expand All @@ -49,9 +28,9 @@ match_res <- estimate_weights(
# plot by trial
kmplot(
weights_object = match_res,
tte_ipd = adtte,
tte_ipd = adtte_twt,
trt_var_ipd = "ARM",
tte_pseudo_ipd = pseudo_ipd,
tte_pseudo_ipd = pseudo_ipd_twt,
trt_var_agd = "ARM",
endpoint_name = "Overall Survival",
trt_ipd = "A",
Expand All @@ -71,9 +50,9 @@ kmplot(
# plot by arm
kmplot(
weights_object = match_res,
tte_ipd = adtte,
tte_ipd = adtte_twt,
trt_var_ipd = "ARM",
tte_pseudo_ipd = pseudo_ipd,
tte_pseudo_ipd = pseudo_ipd_twt,
trt_var_agd = "ARM",
endpoint_name = "Overall Survival",
trt_ipd = "A",
Expand All @@ -92,9 +71,9 @@ kmplot(
# plot all
kmplot(
weights_object = match_res,
tte_ipd = adtte,
tte_ipd = adtte_twt,
trt_var_ipd = "ARM",
tte_pseudo_ipd = pseudo_ipd,
tte_pseudo_ipd = pseudo_ipd_twt,
trt_var_agd = "ARM",
endpoint_name = "Overall Survival",
trt_ipd = "A",
Expand Down
23 changes: 9 additions & 14 deletions inst/examples/maic_unanchored_binary_ex.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# load in prognostic IPD data and AgD
load(system.file("extdata", "ipd.rda", package = "maicplus", mustWork = TRUE))
load(system.file("extdata", "agd.rda", package = "maicplus", mustWork = TRUE))
ipd_centered <- center_ipd(ipd = ipd, agd = agd)
# load in centered prognostic IPD data

# estimate weights
centered_colnames <- c("AGE", "AGE_SQUARED", "SEX_MALE", "ECOG0", "SMOKE", "N_PR_THER_MEDIAN")
centered_colnames <- paste0(centered_colnames, "_CENTERED")
centered_ipd_sat
centered_colnames <- grep("_CENTERED$", colnames(centered_ipd_sat), value = TRUE)
weighted_data <- estimate_weights(data = centered_ipd_sat, centered_colnames = centered_colnames)
weighted_data2 <- estimate_weights(data = centered_ipd_sat, centered_colnames = centered_colnames, n_boot_iteration = 500)

weighted_data <- estimate_weights(data = ipd_centered, centered_colnames = centered_colnames)
weighted_data2 <- estimate_weights(data = ipd_centered, centered_colnames = centered_colnames, n_boot_iteration = 500)
# binary IPD
adrs_sat

# get dummy binary IPD
adrs <- read.csv(system.file("extdata", "adrs.csv", package = "maicplus", mustWork = TRUE))
adrs$RESPONSE <- adrs$AVAL

pseudo_adrs <- get_pseudo_ipd_binary(
binary_agd = data.frame(
ARM = rep("B", 2),
Expand All @@ -26,7 +21,7 @@ pseudo_adrs <- get_pseudo_ipd_binary(
# unanchored binary MAIC, with CI based on sandwich estimator
maic_unanchored(
weights_object = weighted_data,
ipd = adrs,
ipd = adrs_sat,
pseudo_ipd = pseudo_adrs,
trt_ipd = "A",
trt_agd = "B",
Expand All @@ -42,7 +37,7 @@ maic_unanchored(
# unanchored binary MAIC, with bootstrapped CI
maic_unanchored(
weights_object = weighted_data2,
ipd = adrs,
ipd = adrs_sat,
pseudo_ipd = pseudo_adrs,
trt_ipd = "A",
trt_agd = "B",
Expand Down
8 changes: 4 additions & 4 deletions inst/extdata/aggregate_data_example_1.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
STUDY,ARM,N,AGE_MEAN,AGE_MEDIAN,AGE_SD,SEX_MALE_COUNT,ECOG0_COUNT,SMOKE_COUNT
Study_XXXX,Total,300,51,49,3.25,147,105,58
Study_XXXX,Intervention,,,,,,,
Study_XXXX,Comparator,,,,,,,
STUDY,ARM,N,AGE_MEAN,AGE_MEDIAN,AGE_SD,SEX_MALE_COUNT,ECOG0_COUNT,SMOKE_COUNT,N_PR_THER_MEDIAN
Study_XXXX,Total,300,51,49,3.25,147,105,58,2
Study_XXXX,Intervention,,,,,,,,
Study_XXXX,Comparator,,,,,,,,
1 change: 0 additions & 1 deletion man/adtte_sat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/adtte_twt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/agd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/centered_ipd_sat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/centered_ipd_twt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bfecd49

Please sign in to comment.