diff --git a/DESCRIPTION b/DESCRIPTION
index 004141a9..09e6b5ca 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
Type: Package
Package: ClinicoPath
Title: Analysis for Clinicopathological Research
-Version: 0.0.2.08
-Date: 2023-12-03
+Version: 0.0.2.12
+Date: 2023-12-07
Authors@R:
person(given = "Serdar",
family = "Balci",
diff --git a/R/jjhistostats.b.R b/R/jjhistostats.b.R
index aa6a046b..a48d86d6 100644
--- a/R/jjhistostats.b.R
+++ b/R/jjhistostats.b.R
@@ -169,7 +169,7 @@ jjhistostatsClass <- if (requireNamespace('jmvcore'))
x = !!dep,
binwidth = binwidth,
- # bar.measure = barmeasure, ----
+ # bar.measure = barmeasure,
# xlab = NULL,
# title = NULL,
# subtitle = NULL,
diff --git a/R/jjhistostats.h.R b/R/jjhistostats.h.R
index 1d5452b7..5a7a6907 100644
--- a/R/jjhistostats.h.R
+++ b/R/jjhistostats.h.R
@@ -8,7 +8,7 @@ jjhistostatsOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Clas
initialize = function(
dep = NULL,
grvar = NULL,
- excl = TRUE,
+ excl = FALSE,
typestatistics = "parametric",
centralityparameter = "mean",
centralityline = TRUE,
@@ -55,7 +55,7 @@ jjhistostatsOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Clas
private$..excl <- jmvcore::OptionBool$new(
"excl",
excl,
- default=TRUE)
+ default=FALSE)
private$..typestatistics <- jmvcore::OptionList$new(
"typestatistics",
typestatistics,
@@ -339,7 +339,7 @@ jjhistostats <- function(
data,
dep,
grvar,
- excl = TRUE,
+ excl = FALSE,
typestatistics = "parametric",
centralityparameter = "mean",
centralityline = TRUE,
diff --git a/R/multisurvival.b.R b/R/multisurvival.b.R
index 101cfd03..d602f418 100644
--- a/R/multisurvival.b.R
+++ b/R/multisurvival.b.R
@@ -9,62 +9,62 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
inherit = multisurvivalBase,
private = list(
- .todo = function() {
- # If no variable selected Initial Message ----
-
- if (
-
- (is.null(self$options$outcome) && !(self$options$multievent)) ||
-
- (self$options$multievent && (is.null(self$options$dod) && is.null(self$options$dooc) && is.null(self$options$awd) && is.null(self$options$awod))) ||
-
- (is.null(self$options$elapsedtime) && !(self$options$tint)) ||
-
- (self$options$tint && (is.null(self$options$dxdate) || is.null(self$options$fudate))) ||
-
- is.null(self$options$explanatory)
-
- # ||
-
- # (!is.null(self$options$explanatory) && is.null(self$options$contexpl))
-
-
- )
- {
- # TODO ----
-
- todo <- glue::glue(
- "
-
Welcome to ClinicoPath
-
- This tool will help you perform a multivariable survival analysis.
-
- Explanatory variables can be categorical (ordinal or nominal) or continuous.
-
- Select outcome level from Outcome variable.
-
- Outcome Level: if patient is dead or event (recurrence) occured. You may also use advanced outcome options depending on your analysis type.
-
- Survival time should be numeric, continuous, and in months. You may also use dates to calculate survival time in advanced elapsed time options.
-
- This function uses finalfit, survival, survminer and ggstatsplot packages. Please cite jamovi and the packages as given below.
-
- "
- )
- # https://finalfit.org/articles/all_tables_examples.html#cox-proportional-hazards-model-survival-time-to-event
-
-
- html <- self$results$todo
- html$setContent(todo)
- return()
-
- } else {
- if (nrow(self$data) == 0)
- stop('Data contains no (complete) rows')
- }
-
- }
- ,
+ # .todo = function() {
+ # # If no variable selected Initial Message ----
+ #
+ # if (
+ #
+ # (is.null(self$options$outcome) && !(self$options$multievent)) ||
+ #
+ # (self$options$multievent && (is.null(self$options$dod) && is.null(self$options$dooc) && is.null(self$options$awd) && is.null(self$options$awod))) ||
+ #
+ # (is.null(self$options$elapsedtime) && !(self$options$tint)) ||
+ #
+ # (self$options$tint && (is.null(self$options$dxdate) || is.null(self$options$fudate))) ||
+ #
+ # is.null(self$options$explanatory)
+ #
+ # # ||
+ #
+ # # (!is.null(self$options$explanatory) && is.null(self$options$contexpl))
+ #
+ #
+ # )
+ # {
+ # # TODO ----
+ #
+ # todo <- glue::glue(
+ # "
+ #
Welcome to ClinicoPath
+ #
+ # This tool will help you perform a multivariable survival analysis.
+ #
+ # Explanatory variables can be categorical (ordinal or nominal) or continuous.
+ #
+ # Select outcome level from Outcome variable.
+ #
+ # Outcome Level: if patient is dead or event (recurrence) occured. You may also use advanced outcome options depending on your analysis type.
+ #
+ # Survival time should be numeric, continuous, and in months. You may also use dates to calculate survival time in advanced elapsed time options.
+ #
+ # This function uses finalfit, survival, survminer and ggstatsplot packages. Please cite jamovi and the packages as given below.
+ #
+ # "
+ # )
+ # # https://finalfit.org/articles/all_tables_examples.html#cox-proportional-hazards-model-survival-time-to-event
+ #
+ #
+ # html <- self$results$todo
+ # html$setContent(todo)
+ # # return()
+ #
+ # } else {
+ # if (nrow(self$data) == 0)
+ # stop('Data contains no (complete) rows')
+ # }
+ #
+ # }
+ # ,
.cleandata = function() {
@@ -81,6 +81,7 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
elapsedtime <- self$options$elapsedtime
outcome <- self$options$outcome
explanatory <- self$options$explanatory
+ contexpl <- self$options$contexpl
outcomeLevel <- self$options$outcomeLevel
tint <- self$options$tint
@@ -285,26 +286,35 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
myfactors <- c(myexplanatory, mycontexpl)
+ self$results$mydataview$setContent(
+ list(
+ head(mydata, n = 10),
+ myexplanatory = myexplanatory,
+ mycontexpl = mycontexpl,
+ myfactors = myfactors
+ )
+ )
- # Add Redefined Outcome to Data ----
- if (self$options$multievent) {
+ # Add Redefined Outcome to Data ----
- if (self$options$outcomeredifened &&
- self$results$outcomeredifened$isNotFilled()) {
- self$results$outcomeredifened$setValues(mydata[["myoutcome"]])
- }
- }
+ # if (self$options$multievent) {
+ #
+ # if (self$options$outcomeredifened &&
+ # self$results$outcomeredifened$isNotFilled()) {
+ # self$results$outcomeredifened$setValues(mydata[["myoutcome"]])
+ # }
+ # }
# Add Calculated Time to Data ----
- if (self$options$tint) {
-
- if (self$options$calculatedtime &&
- self$results$calculatedtime$isNotFilled()) {
- self$results$calculatedtime$setValues(mydata[["mytime"]])
- }
- }
+ # if (self$options$tint) {
+ #
+ # if (self$options$calculatedtime &&
+ # self$results$calculatedtime$isNotFilled()) {
+ # self$results$calculatedtime$setValues(mydata[["mytime"]])
+ # }
+ # }
@@ -332,7 +342,11 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
mydata <- jmvcore::select(df = mydata, columnNames = c("mytime", "myoutcome", myfactors))
-
+ # self$results$mydataview$setContent(
+ # list(
+ # head(mydata, n = 30)
+ # )
+ # )
# naOmit ----
@@ -355,24 +369,24 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
# Errors ----
- if (
-
- (is.null(self$options$outcome) && !(self$options$multievent)) ||
-
- (self$options$multievent && (is.null(self$options$dod) && is.null(self$options$dooc) && is.null(self$options$awd) && is.null(self$options$awod))) ||
-
- (self$options$tint && (is.null(self$options$dxdate) || is.null(self$options$fudate))) ||
-
- is.null(self$options$explanatory)
-
- # ||
- #
- # (!is.null(self$options$explanatory) && is.null(self$options$contexpl))
-
- ) {
- private$.todo()
- return()
- }
+ # if (
+ #
+ # (is.null(self$options$outcome) && !(self$options$multievent)) ||
+ #
+ # (self$options$multievent && (is.null(self$options$dod) && is.null(self$options$dooc) && is.null(self$options$awd) && is.null(self$options$awod))) ||
+ #
+ # (self$options$tint && (is.null(self$options$dxdate) || is.null(self$options$fudate))) ||
+ #
+ # is.null(self$options$explanatory)
+ #
+ # #
+ # #
+ # # (!is.null(self$options$explanatory) && is.null(self$options$contexpl))
+ #
+ # ) {
+ # private$.todo()
+ # # return()
+ # }
if (nrow(self$data) == 0)
stop('Data contains no (complete) rows')
@@ -384,6 +398,9 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
mydata <- cleaneddata$mydata
+
+
+
# Cox ----
private$.cox(mydata)
@@ -396,7 +413,7 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
# )
- # # Prepare Data For Plots ----
+ # Prepare Data For Plots ----
image <- self$results$plot
@@ -406,8 +423,8 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
image3$setState(mydata)
- image4 <- self$results$plot4
- image4$setState(mydata)
+ # image4 <- self$results$plot4
+ # image4$setState(mydata)
# imageKM <- self$results$plotKM
@@ -827,39 +844,39 @@ multisurvivalClass <- if (requireNamespace('jmvcore'))
- # coxzph plot ----
- ,
- .plot4 = function(image4, ggtheme, theme, ...) {
-
- plotData <- image4$state
-
- formula2 <-
- jmvcore::constructFormula(terms = c(self$options$explanatory, self$options$contexpl))
-
- formula3 <-
- paste("survival::Surv(mytime, myoutcome) ~ ", formula2)
-
- formula3 <- as.formula(formula3)
-
- cox_model <-
- survival::coxph(formula = formula3,
- data = plotData)
-
-
-
- cox_zph_fit <- survival::cox.zph(cox_model)
-
-
- # plot all variables
- plot4 <- survminer::ggcoxzph(cox_zph_fit)
-
-
- # print plot ----
-
- print(plot4)
- TRUE
-
- }
+ # # coxzph plot ----
+ # ,
+ # .plot4 = function(image4, ggtheme, theme, ...) {
+ #
+ # plotData <- image4$state
+ #
+ # formula2 <-
+ # jmvcore::constructFormula(terms = c(self$options$explanatory, self$options$contexpl))
+ #
+ # formula3 <-
+ # paste("survival::Surv(mytime, myoutcome) ~ ", formula2)
+ #
+ # formula3 <- as.formula(formula3)
+ #
+ # cox_model <-
+ # survival::coxph(formula = formula3,
+ # data = plotData)
+ #
+ #
+ #
+ # cox_zph_fit <- survival::cox.zph(cox_model)
+ #
+ #
+ # # plot all variables
+ # plot4 <- survminer::ggcoxzph(cox_zph_fit)
+ #
+ #
+ # # print plot ----
+ #
+ # print(plot4)
+ # TRUE
+ #
+ # }
diff --git a/R/multisurvival.h.R b/R/multisurvival.h.R
index 6a144ece..ed621c54 100644
--- a/R/multisurvival.h.R
+++ b/R/multisurvival.h.R
@@ -221,11 +221,11 @@ multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
inherit = jmvcore::Group,
active = list(
todo = function() private$.items[["todo"]],
+ mydataview = function() private$.items[["mydataview"]],
text = function() private$.items[["text"]],
text2 = function() private$.items[["text2"]],
plot = function() private$.items[["plot"]],
- plot3 = function() private$.items[["plot3"]],
- plot4 = function() private$.items[["plot4"]]),
+ plot3 = function() private$.items[["plot3"]]),
private = list(),
public=list(
initialize=function(options) {
@@ -261,8 +261,11 @@ multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
"fudate",
"dxdate",
"tint",
- "multievent",
- "adjexplanatory")))
+ "multievent")))
+ self$add(jmvcore::Preformatted$new(
+ options=options,
+ name="mydataview",
+ title="mydataview"))
self$add(jmvcore::Html$new(
options=options,
name="text",
@@ -277,8 +280,7 @@ multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
"fudate",
"dxdate",
"tint",
- "multievent",
- "adjexplanatory")))
+ "multievent")))
self$add(jmvcore::Html$new(
options=options,
name="text2",
@@ -293,8 +295,7 @@ multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
"fudate",
"dxdate",
"tint",
- "multievent",
- "adjexplanatory")))
+ "multievent")))
self$add(jmvcore::Image$new(
options=options,
name="plot",
@@ -316,8 +317,7 @@ multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
"fudate",
"dxdate",
"tint",
- "multievent",
- "adjexplanatory")))
+ "multievent")))
self$add(jmvcore::Image$new(
options=options,
name="plot3",
@@ -339,15 +339,7 @@ multisurvivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Cla
"fudate",
"dxdate",
"tint",
- "multievent",
- "adjexplanatory")))
- self$add(jmvcore::Image$new(
- options=options,
- name="plot4",
- title="coxzph Plot",
- width=800,
- height=600,
- renderFun=".plot4"))}))
+ "multievent")))}))
multisurvivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"multisurvivalBase",
@@ -402,11 +394,11 @@ multisurvivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
+#' \code{results$mydataview} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$text} \tab \tab \tab \tab \tab a html \cr
#' \code{results$text2} \tab \tab \tab \tab \tab a html \cr
#' \code{results$plot} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
-#' \code{results$plot4} \tab \tab \tab \tab \tab an image \cr
#' }
#'
#' @export
diff --git a/R/survival.b.R b/R/survival.b.R
index 3af2d0ed..437569ad 100644
--- a/R/survival.b.R
+++ b/R/survival.b.R
@@ -9,72 +9,169 @@ survivalClass <- if (requireNamespace('jmvcore'))
"survivalClass",
inherit = survivalBase,
private = list(
+
+
+
+
.init = function() {
- if (self$options$sas) {
+
+
+
+ if(self$options$ph_cox) {
# Disable tables
- self$results$medianSummary$setVisible(FALSE)
- self$results$medianTable$setVisible(FALSE)
- self$results$coxSummary$setVisible(FALSE)
- self$results$coxTable$setVisible(FALSE)
- self$results$tCoxtext2$setVisible(FALSE)
- self$results$survTableSummary$setVisible(FALSE)
- self$results$survTable$setVisible(FALSE)
- self$results$pairwiseSummary$setVisible(FALSE)
- self$results$pairwiseTable$setVisible(FALSE)
+ self$results$cox_ph$setVisible(TRUE)
}
+ # if (self$options$sas) {
+ # # Disable tables
+ # self$results$medianSummary$setVisible(FALSE)
+ # self$results$medianTable$setVisible(FALSE)
+ # self$results$coxSummary$setVisible(FALSE)
+ # self$results$coxTable$setVisible(FALSE)
+ # self$results$tCoxtext2$setVisible(FALSE)
+ # self$results$survTableSummary$setVisible(FALSE)
+ # self$results$survTable$setVisible(FALSE)
+ # self$results$pairwiseSummary$setVisible(FALSE)
+ # self$results$pairwiseTable$setVisible(FALSE)
+ # }
+
}
+
,
- .todo = function() {
- if ((is.null(self$options$outcome) && !(self$options$multievent)) ||
- (self$options$multievent &&
- (
- is.null(self$options$dod) &&
- is.null(self$options$dooc) &&
- is.null(self$options$awd) && is.null(self$options$awod)
- )) ||
- (self$options$tint &&
- (
- is.null(self$options$dxdate) || is.null(self$options$fudate)
- )) ||
- ((is.null(self$options$explanatory)) || (is.null(self$explanatory$sas)))) {
-
- todo <- glue::glue(
- "
-
Welcome to ClinicoPath
-
- This tool will help you calculate median survivals and 1,3,5-yr survivals for a given fisk factor.
-
- Explanatory variable should be categorical (ordinal or nominal).
-
- Select outcome level from Outcome variable.
-
- Outcome Level: if patient is dead or event (recurrence) occured. You may also use advanced outcome options depending on your analysis type.
-
- Survival time should be numeric and continuous. You may also use dates to calculate survival time in advanced elapsed time options.
-
- This function uses survival, survminer, and finalfit packages. Please cite jamovi and the packages as given below.
-
-
- See details for survival here."
- )
- html <- self$results$todo
- html$setContent(todo)
- }
+
+
+
+ .getData = function() {
+
+ mydata <- self$data
+
+ mydata$row_names <- rownames(mydata)
+
+ original_names <- names(mydata)
+
+ labels <- setNames(original_names, original_names)
+
+ mydata <- mydata %>% janitor::clean_names()
+
+ corrected_labels <-
+ setNames(original_names, names(mydata))
+
+ mydata <- labelled::set_variable_labels(.data = mydata,
+ .labels = corrected_labels)
+
+ all_labels <- labelled::var_label(mydata)
+
+
+ mytime <-
+ names(all_labels)[all_labels == self$options$elapsedtime]
+
+ myoutcome <-
+ names(all_labels)[all_labels == self$options$outcome]
+
+ mydxdate <-
+ names(all_labels)[all_labels == self$options$dxdate]
+
+ myfudate <-
+ names(all_labels)[all_labels == self$options$fudate]
+
+ myexplanatory <-
+ names(all_labels)[all_labels == self$options$explanatory]
+
+ return(list(
+ "mydata_labelled" = mydata
+ , "mytime_labelled" = mytime
+ , "myoutcome_labelled" = myoutcome
+ , "mydxdate_labelled" = mydxdate
+ , "myfudate_labelled" = myfudate
+ , "myexplanatory_labelled" = myexplanatory
+ ))
+
}
+
+
+ # ,
+ # .todo = function() {
+ # if (
+ # (is.null(self$options$outcome) && !(self$options$multievent)) ||
+
+ # (self$options$multievent &&
+ # (
+ # is.null(self$options$dod) &&
+ # is.null(self$options$dooc) &&
+ # is.null(self$options$awd) && is.null(self$options$awod)
+
+ # )
+ # ) ||
+
+ # (self$options$tint &&
+ # (
+ # is.null(self$options$dxdate) || is.null(self$options$fudate)
+ # )) ||
+
+ # (is.null(self$options$explanatory)
+
+ # #
+ # # || (is.null(self$explanatory$sas))
+ # #
+
+ # )
+ # ) {
+
+ # todo <- glue::glue(
+ # "
+ #
Welcome to ClinicoPath
+ #
+ # This tool will help you calculate median survivals and 1,3,5-yr survivals for a given fisk factor.
+ #
+ # Explanatory variable should be categorical (ordinal or nominal).
+ #
+ # Select outcome level from Outcome variable.
+ #
+ # Outcome Level: if patient is dead or event (recurrence) occured. You may also use advanced outcome options depending on your analysis type.
+ #
+ # Survival time should be numeric and continuous. You may also use dates to calculate survival time in advanced elapsed time options.
+ #
+ # This function uses survival, survminer, and finalfit packages. Please cite jamovi and the packages as given below.
+ #
+ #
+ # See details for survival here."
+ # )
+
+ # html <- self$results$todo
+ # html$setContent(todo)
+
+ # }
+
+ # }
+
+
+
+
+
# Define Survival Time ----
,
.definemytime = function() {
- mydata <- self$data
+ # mydata <- self$data
+
+ # Read Labelled Data ----
+
+ labelled_data <- private$.getData()
+
+ mydata <- labelled_data$mydata_labelled
+ mytime_labelled <- labelled_data$mytime_labelled
+ # myoutcome_labelled <- labelled_data$myoutcome_labelled
+ mydxdate_labelled <- labelled_data$mydxdate_labelled
+ myfudate_labelled <- labelled_data$myfudate_labelled
+ # myexplanatory_labelled <- labelled_data$myexplanatory_labelled
tint <- self$options$tint
@@ -84,15 +181,16 @@ survivalClass <- if (requireNamespace('jmvcore'))
# mydata[[self$options$elapsedtime]] <- jmvcore::toNumeric(mydata[[self$options$elapsedtime]])
- mydata[["mytime"]] <-
- jmvcore::toNumeric(mydata[[self$options$elapsedtime]])
+ mydata[["mytime"]] <-
+ jmvcore::toNumeric(mydata[[mytime_labelled]])
+
} else if (tint) {
# Time Interval ----
- dxdate <- self$options$dxdate
- fudate <- self$options$fudate
+ dxdate <- mydxdate_labelled # self$options$dxdate
+ fudate <- myfudate_labelled #self$options$fudate
timetypedata <- self$options$timetypedata
@@ -150,34 +248,68 @@ survivalClass <- if (requireNamespace('jmvcore'))
}
- return(mydata[["mytime"]])
+ df_time <- mydata %>% jmvcore::select(c("row_names", "mytime"))
- }
- # Add Calculated Time to Data ----
- ,
- .mytimetodata = function() {
- mycalculatedtime <- private$.definemytime()
+ return(df_time)
- if (self$options$calculatedtime &&
- self$results$calculatedtime$isNotFilled()) {
- self$results$calculatedtime$setValues(mycalculatedtime)
- }
}
+ # # Add Calculated Time to Data ----
+ # ,
+ # .mytimetodata = function() {
+ # mycalculatedtime <- private$.definemytime()
+
+ # if (self$options$calculatedtime &&
+ # self$results$calculatedtime$isNotFilled()) {
+ # self$results$calculatedtime$setValues(mycalculatedtime)
+ # }
+
+ # }
+
# Define Outcome ----
,
.definemyoutcome = function() {
- mydata <- self$data
+
+
+ labelled_data <- private$.getData()
+
+ mydata <- labelled_data$mydata_labelled
+ # mytime_labelled <- labelled_data$mytime_labelled
+ myoutcome_labelled <- labelled_data$myoutcome_labelled
+ # mydxdate_labelled <- labelled_data$mydxdate_labelled
+ # myfudate_labelled <- labelled_data$myfudate_labelled
+ # myexplanatory_labelled <- labelled_data$myexplanatory_labelled
+
+ # self$results$mydataview$setContent(
+ # list(
+ # mydata_labelled = mydata_labelled,
+ # mytime_labelled = mytime_labelled,
+ # myoutcome_labelled = myoutcome_labelled,
+ # mydxdate_labelled = mydxdate_labelled,
+ # myfudate_labelled = myfudate_labelled,
+ # myexplanatory_labelled = myexplanatory_labelled
+ # )
+ # )
+
+
+
+ # mydata <- mydata_labelled #self$data
contin <- c("integer", "numeric", "double")
outcomeLevel <- self$options$outcomeLevel
multievent <- self$options$multievent
- outcome1 <- self$options$outcome
- outcome1 <- self$data[[outcome1]]
+
+
+ # outcome1 <- self$options$outcome
+ # outcome1 <- self$data[[outcome1]]
+ outcome1 <- mydata[[myoutcome_labelled]]
+
+
+
if (!multievent) {
if (inherits(outcome1, contin)) {
@@ -192,8 +324,8 @@ survivalClass <- if (requireNamespace('jmvcore'))
}
- mydata[["myoutcome"]] <-
- mydata[[self$options$outcome]]
+ mydata[["myoutcome"]] <- mydata[[myoutcome_labelled]]
+ # mydata[[self$options$outcome]]
} else if (inherits(outcome1, "factor")) {
mydata[["myoutcome"]] <-
@@ -262,23 +394,25 @@ survivalClass <- if (requireNamespace('jmvcore'))
}
+ df_outcome <- mydata %>% jmvcore::select(c("row_names", "myoutcome"))
+
- return(mydata[["myoutcome"]])
+ return(df_outcome)
}
# Add Redefined Outcome to Data ----
- ,
- .myoutcometodata = function() {
- mydefinedoutcome <- private$.definemyoutcome()
+ # ,
+ # .myoutcometodata = function() {
+ # mydefinedoutcome <- private$.definemyoutcome()
- if (self$options$outcomeredifened &&
- self$results$outcomeredifened$isNotFilled()) {
- self$results$outcomeredifened$setValues(mydefinedoutcome)
- }
+ # if (self$options$outcomeredifened &&
+ # self$results$outcomeredifened$isNotFilled()) {
+ # self$results$outcomeredifened$setValues(mydefinedoutcome)
+ # }
- }
+ # }
@@ -286,22 +420,45 @@ survivalClass <- if (requireNamespace('jmvcore'))
# Define Factor ----
,
+
.definemyfactor = function() {
- mydata <- self$data
+ # mydata <- self$data
- expl <- self$options$explanatory
+ # expl <- self$options$explanatory
+
+
+ labelled_data <- private$.getData()
- mydata[["myfactor"]] <- mydata[[expl]]
+ mydata_labelled <- labelled_data$mydata_labelled
+ mytime_labelled <- labelled_data$mytime_labelled
+ myoutcome_labelled <- labelled_data$myoutcome_labelled
+ mydxdate_labelled <- labelled_data$mydxdate_labelled
+ myfudate_labelled <- labelled_data$myfudate_labelled
+ myexplanatory_labelled <- labelled_data$myexplanatory_labelled
- # single arm ----
- sas <- self$options$sas
+ mydata <- mydata_labelled
- if (sas) {
- mydata[["myfactor"]] <- "1"
- }
+ # mydata[["myfactor"]] <- mydata[[expl]]
+
+
+ mydata[["myfactor"]] <- mydata[[myexplanatory_labelled]]
+
+ # # single arm ----
+ #
+ # sas <- self$options$sas
+ #
+ # if (sas) {
+ # mydata[["myfactor"]] <- "1"
+ # }
+ #
+ # return(mydata[["myfactor"]])
+
+
+ df_factor <- mydata %>% jmvcore::select(c("row_names","myfactor"))
+
+ return(df_factor)
- return(mydata[["myfactor"]])
}
@@ -309,13 +466,45 @@ survivalClass <- if (requireNamespace('jmvcore'))
# Clean Data For Analysis ----
,
.cleandata = function() {
+
+ labelled_data <- private$.getData()
+
+ mydata_labelled <- labelled_data$mydata_labelled
+ mytime_labelled <- labelled_data$mytime_labelled
+ myoutcome_labelled <- labelled_data$myoutcome_labelled
+ mydxdate_labelled <- labelled_data$mydxdate_labelled
+ myfudate_labelled <- labelled_data$myfudate_labelled
+ myexplanatory_labelled <- labelled_data$myexplanatory_labelled
+
+
+
+
+
+
+
+
time <- private$.definemytime()
outcome <- private$.definemyoutcome()
factor <- private$.definemyfactor()
- cleanData <- data.frame("mytime" = time,
- "myoutcome" = outcome,
- "factor" = factor)
+
+
+
+
+ cleanData <- dplyr::left_join(time, outcome, by = "row_names") %>%
+ dplyr::left_join(factor, by = "row_names")
+ # %>%
+ # dplyr::select(-row_names)
+
+
+
+
+
+
+
+ # data.frame("mytime" = time,
+ # "myoutcome" = outcome,
+ # "factor" = factor)
# Landmark ----
# https://www.emilyzabor.com/tutorials/survival_analysis_in_r_tutorial.html#landmark_method
@@ -342,23 +531,36 @@ survivalClass <- if (requireNamespace('jmvcore'))
if (!self$options$tint &&
!is.null(self$options$elapsedtime)) {
- name1time <- jmvcore::composeTerm(self$options$elapsedtime)
+ name1time <- mytime_labelled
+ # jmvcore::composeTerm(self$options$elapsedtime)
}
- name2outcome <-
- jmvcore::composeTerm(self$options$outcome)
+ name2outcome <- myoutcome_labelled
+ # jmvcore::composeTerm(self$options$outcome)
- if (self$options$sas) {
- name3explanatory <- "SingleArm"
- }
+ # if (self$options$sas) {
+ # name3explanatory <- "SingleArm"
+ # }
- if (!self$options$sas &&
- !is.null(self$options$explanatory)) {
- name3explanatory <- jmvcore::composeTerm(self$options$explanatory)
- }
+ if (
+ # !self$options$sas &&
+ !is.null(self$options$explanatory)
+ ) {
+ name3explanatory <- myexplanatory_labelled
+ # jmvcore::composeTerm(self$options$explanatory)
+ }
+
+ cleanData <- cleanData %>%
+ dplyr::rename(
+ !!name1time := mytime,
+ !!name2outcome := myoutcome,
+ !!name3explanatory := myfactor
+ )
+
+
- names(cleanData) <-
- c(name1time, name2outcome, name3explanatory)
+ # names(cleanData) <-
+ # c(name1time, name2outcome, name3explanatory)
# naOmit ----
@@ -447,11 +649,25 @@ survivalClass <- if (requireNamespace('jmvcore'))
if (nrow(self$data) == 0)
stop('Data contains no (complete) rows')
+
+ labelled_data <- private$.getData()
+
+ mydata_labelled <- labelled_data$mydata_labelled
+ mytime_labelled <- labelled_data$mytime_labelled
+ myoutcome_labelled <- labelled_data$myoutcome_labelled
+ mydxdate_labelled <- labelled_data$mydxdate_labelled
+ myfudate_labelled <- labelled_data$myfudate_labelled
+ myexplanatory_labelled <- labelled_data$myexplanatory_labelled
+
+
+
+
+
# Add Calculated Time to Data ----
- if (self$options$tint) {
- private$.mytimetodata()
- }
+ # if (self$options$tint) {
+ # private$.mytimetodata()
+ # }
# mycalculatedtime <- private$.definemytime()
#
@@ -461,31 +677,76 @@ survivalClass <- if (requireNamespace('jmvcore'))
# Add Redefined Outcome to Data ----
- if (self$options$multievent) {
- private$.myoutcometodata()
- }
+ # if (self$options$multievent) {
+ # private$.myoutcometodata()
+ # }
# Get Clean Data ----
results <- private$.cleandata()
+
+ self$results$mydataview$setContent(
+ list(
+ mydata_labelled = head(mydata_labelled),
+ mytime_labelled = mytime_labelled,
+ myoutcome_labelled = myoutcome_labelled,
+ mydxdate_labelled = mydxdate_labelled,
+ myfudate_labelled = myfudate_labelled,
+ myexplanatory_labelled = myexplanatory_labelled,
+ # time = head(time),
+ # outcome = head(outcome),
+ # factor = head(factor),
+ results = head(results)
+ )
+ )
+
+
+
+
+
+
+
+
# Run Analysis ----
- if (!self$options$sas) {
+ # if (!self$options$sas) {
# Median Survival ----
private$.medianSurv(results)
# Cox ----
private$.cox(results)
# Survival Table ----
private$.survTable(results)
- }
+ # }
# Pairwise ----
- if (self$options$pw && !self$options$sas) {
+ if (self$options$pw
+ # && !self$options$sas
+ ) {
private$.pairwise(results)
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
@@ -707,6 +968,56 @@ survivalClass <- if (requireNamespace('jmvcore'))
self$results$coxSummary$setContent(coxSummary)
+ # Proportional Hazards Assumption ----
+
+ if (self$options$ph_cox) {
+
+ # self$results$mydataview$setContent(
+ # list(
+ # mydata = head(mydata),
+ # # mydata_labelled = head(mydata_labelled),
+ # # mytime_labelled = mytime_labelled,
+ # # myoutcome_labelled = myoutcome_labelled,
+ # # mydxdate_labelled = mydxdate_labelled,
+ # # myfudate_labelled = myfudate_labelled,
+ # # myexplanatory_labelled = myexplanatory_labelled,
+ # # time = head(time),
+ # # outcome = head(outcome),
+ # # factor = head(factor),
+ # results = head(results)
+ # )
+ # )
+
+
+
+
+
+
+ mydata[[mytime]] <- jmvcore::toNumeric(mydata[[mytime]])
+
+
+ formula <-
+ paste('survival::Surv(',
+ mytime,
+ ',',
+ myoutcome,
+ ') ~ ',
+ myfactor)
+
+ formula <- as.formula(formula)
+
+
+
+ cox_model <- survival::coxph(formula, data = mydata)
+
+ zph <- survival::cox.zph(cox_model)
+
+ self$results$cox_ph$setContent(print(zph))
+
+ image7 <- self$results$plot7
+ image7$setState(zph)
+
+ }
}
@@ -935,11 +1246,11 @@ survivalClass <- if (requireNamespace('jmvcore'))
title2 <- as.character(myfactor)
- sas <- self$options$sas
-
- if (sas) {
- title2 <- "Overall"
- }
+ # sas <- self$options$sas
+ #
+ # if (sas) {
+ # title2 <- "Overall"
+ # }
plot <- plotData %>%
@@ -1004,11 +1315,11 @@ survivalClass <- if (requireNamespace('jmvcore'))
title2 <- as.character(myfactor)
- sas <- self$options$sas
-
- if (sas) {
- title2 <- "Overall"
- }
+ # sas <- self$options$sas
+ #
+ # if (sas) {
+ # title2 <- "Overall"
+ # }
plot2 <- plotData %>%
finalfit::surv_plot(
@@ -1070,11 +1381,11 @@ survivalClass <- if (requireNamespace('jmvcore'))
title2 <- as.character(myfactor)
- sas <- self$options$sas
-
- if (sas) {
- title2 <- "Overall"
- }
+ # sas <- self$options$sas
+ #
+ # if (sas) {
+ # title2 <- "Overall"
+ # }
plot3 <- plotData %>%
@@ -1131,11 +1442,11 @@ survivalClass <- if (requireNamespace('jmvcore'))
title2 <- as.character(myfactor)
- sas <- self$options$sas
-
- if (sas) {
- title2 <- "Overall"
- }
+ # sas <- self$options$sas
+ #
+ # if (sas) {
+ # title2 <- "Overall"
+ # }
myformula <-
@@ -1169,5 +1480,26 @@ survivalClass <- if (requireNamespace('jmvcore'))
}
+ # cox.zph ----
+ ,
+ .plot7 = function(image7, ggtheme, theme, ...) {
+
+ ph_cox <- self$options$ph_cox
+
+ if (!ph_cox)
+ return()
+
+ zph <- image7$state
+
+ plot7 <- plot(zph)
+
+ print(plot7)
+ TRUE
+
+ }
+
+
+
+
)
)
diff --git a/R/survival.h.R b/R/survival.h.R
index f8b9ca79..2594a0fc 100644
--- a/R/survival.h.R
+++ b/R/survival.h.R
@@ -25,6 +25,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
landmark = 3,
pw = FALSE,
padjustmethod = "holm",
+ ph_cox = FALSE,
sc = FALSE,
kmunicate = FALSE,
ce = FALSE,
@@ -35,8 +36,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
ci95 = FALSE,
risktable = FALSE,
censored = FALSE,
- pplot = TRUE,
- sas = FALSE, ...) {
+ pplot = TRUE, ...) {
super$initialize(
package="ClinicoPath",
@@ -160,6 +160,10 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"fdr",
"none"),
default="holm")
+ private$..ph_cox <- jmvcore::OptionBool$new(
+ "ph_cox",
+ ph_cox,
+ default=FALSE)
private$..sc <- jmvcore::OptionBool$new(
"sc",
sc,
@@ -204,10 +208,6 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"pplot",
pplot,
default=TRUE)
- private$..sas <- jmvcore::OptionBool$new(
- "sas",
- sas,
- default=FALSE)
self$.addOption(private$..elapsedtime)
self$.addOption(private$..tint)
@@ -228,6 +228,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
self$.addOption(private$..landmark)
self$.addOption(private$..pw)
self$.addOption(private$..padjustmethod)
+ self$.addOption(private$..ph_cox)
self$.addOption(private$..sc)
self$.addOption(private$..kmunicate)
self$.addOption(private$..ce)
@@ -239,7 +240,6 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
self$.addOption(private$..risktable)
self$.addOption(private$..censored)
self$.addOption(private$..pplot)
- self$.addOption(private$..sas)
}),
active = list(
elapsedtime = function() private$..elapsedtime$value,
@@ -261,6 +261,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
landmark = function() private$..landmark$value,
pw = function() private$..pw$value,
padjustmethod = function() private$..padjustmethod$value,
+ ph_cox = function() private$..ph_cox$value,
sc = function() private$..sc$value,
kmunicate = function() private$..kmunicate$value,
ce = function() private$..ce$value,
@@ -271,8 +272,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
ci95 = function() private$..ci95$value,
risktable = function() private$..risktable$value,
censored = function() private$..censored$value,
- pplot = function() private$..pplot$value,
- sas = function() private$..sas$value),
+ pplot = function() private$..pplot$value),
private = list(
..elapsedtime = NA,
..tint = NA,
@@ -293,6 +293,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
..landmark = NA,
..pw = NA,
..padjustmethod = NA,
+ ..ph_cox = NA,
..sc = NA,
..kmunicate = NA,
..ce = NA,
@@ -303,8 +304,7 @@ survivalOptions <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
..ci95 = NA,
..risktable = NA,
..censored = NA,
- ..pplot = NA,
- ..sas = NA)
+ ..pplot = NA)
)
survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
@@ -313,11 +313,14 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
active = list(
subtitle = function() private$.items[["subtitle"]],
todo = function() private$.items[["todo"]],
+ mydataview = function() private$.items[["mydataview"]],
medianSummary = function() private$.items[["medianSummary"]],
medianTable = function() private$.items[["medianTable"]],
coxSummary = function() private$.items[["coxSummary"]],
coxTable = function() private$.items[["coxTable"]],
tCoxtext2 = function() private$.items[["tCoxtext2"]],
+ cox_ph = function() private$.items[["cox_ph"]],
+ plot7 = function() private$.items[["plot7"]],
survTableSummary = function() private$.items[["survTableSummary"]],
survTable = function() private$.items[["survTable"]],
pairwiseSummary = function() private$.items[["pairwiseSummary"]],
@@ -325,9 +328,7 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
plot = function() private$.items[["plot"]],
plot2 = function() private$.items[["plot2"]],
plot3 = function() private$.items[["plot3"]],
- plot6 = function() private$.items[["plot6"]],
- calculatedtime = function() private$.items[["calculatedtime"]],
- outcomeredifened = function() private$.items[["outcomeredifened"]]),
+ plot6 = function() private$.items[["plot6"]]),
private = list(),
public=list(
initialize=function(options) {
@@ -360,11 +361,14 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"dxdate",
"tint",
"multievent")))
+ self$add(jmvcore::Preformatted$new(
+ options=options,
+ name="mydataview",
+ title="mydataview"))
self$add(jmvcore::Preformatted$new(
options=options,
name="medianSummary",
title="`Median Survival Summary and Table - ${explanatory}`",
- visible="(!sas)",
clearWith=list(
"explanatory",
"outcome",
@@ -413,8 +417,7 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
`name`="x0_95ucl",
`title`="Upper",
`superTitle`="95% Confidence Interval",
- `type`="number",
- `visible`="(!sas)")),
+ `type`="number")),
clearWith=list(
"explanatory",
"outcome",
@@ -428,7 +431,6 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
options=options,
name="coxSummary",
title="`Cox Regression Summary and Table - ${explanatory}`",
- visible="(!sas)",
clearWith=list(
"explanatory",
"outcome",
@@ -459,8 +461,7 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
list(
`name`="HR_univariable",
`title`="HR (Univariable)",
- `type`="text",
- `visible`="(!sas)")),
+ `type`="text")),
clearWith=list(
"explanatory",
"outcome",
@@ -484,13 +485,46 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"dxdate",
"tint",
"multievent",
- "contexpl"),
- visible="(!sas)"))
+ "contexpl")))
+ self$add(jmvcore::Preformatted$new(
+ options=options,
+ name="cox_ph",
+ title="Proportional Hazards Assumption",
+ clearWith=list(
+ "explanatory",
+ "outcome",
+ "outcomeLevel",
+ "overalltime",
+ "fudate",
+ "dxdate",
+ "tint",
+ "multievent",
+ "contexpl")))
+ self$add(jmvcore::Image$new(
+ options=options,
+ name="plot7",
+ title="`Proportional Hazards Assumption - ${explanatory}`",
+ width=600,
+ height=450,
+ renderFun=".plot7",
+ visible="(ph_cox)",
+ requiresData=TRUE,
+ clearWith=list(
+ "ph_cox",
+ "endplot",
+ "byplot",
+ "explanatory",
+ "outcome",
+ "outcomeLevel",
+ "overalltime",
+ "fudate",
+ "dxdate",
+ "tint",
+ "multievent")))
self$add(jmvcore::Preformatted$new(
options=options,
name="survTableSummary",
title="`1, 3, 5-yr Survival Summary and Table - ${explanatory}`",
- visible="(!sas)",
clearWith=list(
"explanatory",
"outcome",
@@ -539,7 +573,6 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
`superTitle`="95% Confidence Interval",
`type`="number",
`format`="pc")),
- visible="(!sas)",
clearWith=list(
"explanatory",
"outcome",
@@ -563,7 +596,7 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"dxdate",
"tint",
"multievent"),
- visible="(pw && !sas)"))
+ visible="(pw)"))
self$add(jmvcore::Table$new(
options=options,
name="pairwiseTable",
@@ -583,7 +616,7 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
`title`="p-value",
`type`="number",
`format`="zto,pvalue")),
- visible="(pw && !sas)",
+ visible="(pw)",
clearWith=list(
"pw",
"explanatory",
@@ -609,7 +642,6 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"sc",
"endplot",
"byplot",
- "sas",
"ci95",
"risktable",
"censored",
@@ -635,7 +667,6 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ce",
"endplot",
"byplot",
- "sas",
"ci95",
"risktable",
"censored",
@@ -660,7 +691,6 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"ch",
"endplot",
"byplot",
- "sas",
"ci95",
"risktable",
"censored",
@@ -685,7 +715,6 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"kmunicate",
"endplot",
"byplot",
- "sas",
"explanatory",
"outcome",
"outcomeLevel",
@@ -696,42 +725,7 @@ survivalResults <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"multievent"),
refs=list(
"KMunicate",
- "KMunicate2")))
- self$add(jmvcore::Output$new(
- options=options,
- name="calculatedtime",
- title="Add Calculated Time to Data",
- varTitle="`Calculated Time - from ${ dxdate } to { fudate }`",
- varDescription="Calculated Time from given Dates",
- clearWith=list(
- "tint",
- "dxdate",
- "fudate",
- "explanatory",
- "outcome",
- "outcomeLevel",
- "overalltime",
- "fudate",
- "dxdate",
- "tint",
- "multievent")))
- self$add(jmvcore::Output$new(
- options=options,
- name="outcomeredifened",
- title="Add Redefined Outcome to Data",
- varTitle="`Redefined Outcome - from ${ outcome } for analysis { analysistype }`",
- varDescription="Redefined Outcome from Outcome based on Analysis Type",
- clearWith=list(
- "outcome",
- "analysistype",
- "multievent",
- "explanatory",
- "outcomeLevel",
- "overalltime",
- "fudate",
- "dxdate",
- "tint",
- "multievent")))}))
+ "KMunicate2")))}))
survivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
"survivalBase",
@@ -781,6 +775,7 @@ survivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
#' @param landmark .
#' @param pw .
#' @param padjustmethod .
+#' @param ph_cox .
#' @param sc .
#' @param kmunicate .
#' @param ce .
@@ -792,16 +787,18 @@ survivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
#' @param risktable .
#' @param censored .
#' @param pplot .
-#' @param sas .
#' @return A results object containing:
#' \tabular{llllll}{
#' \code{results$subtitle} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$todo} \tab \tab \tab \tab \tab a html \cr
+#' \code{results$mydataview} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$medianSummary} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$medianTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$coxSummary} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$coxTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$tCoxtext2} \tab \tab \tab \tab \tab a html \cr
+#' \code{results$cox_ph} \tab \tab \tab \tab \tab a preformatted \cr
+#' \code{results$plot7} \tab \tab \tab \tab \tab an image \cr
#' \code{results$survTableSummary} \tab \tab \tab \tab \tab a preformatted \cr
#' \code{results$survTable} \tab \tab \tab \tab \tab a table \cr
#' \code{results$pairwiseSummary} \tab \tab \tab \tab \tab a preformatted \cr
@@ -810,8 +807,6 @@ survivalBase <- if (requireNamespace("jmvcore", quietly=TRUE)) R6::R6Class(
#' \code{results$plot2} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot3} \tab \tab \tab \tab \tab an image \cr
#' \code{results$plot6} \tab \tab \tab \tab \tab an image \cr
-#' \code{results$calculatedtime} \tab \tab \tab \tab \tab an output \cr
-#' \code{results$outcomeredifened} \tab \tab \tab \tab \tab an output \cr
#' }
#'
#' Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example:
@@ -842,6 +837,7 @@ survival <- function(
landmark = 3,
pw = FALSE,
padjustmethod = "holm",
+ ph_cox = FALSE,
sc = FALSE,
kmunicate = FALSE,
ce = FALSE,
@@ -852,8 +848,7 @@ survival <- function(
ci95 = FALSE,
risktable = FALSE,
censored = FALSE,
- pplot = TRUE,
- sas = FALSE) {
+ pplot = TRUE) {
if ( ! requireNamespace("jmvcore", quietly=TRUE))
stop("survival requires jmvcore to be installed (restart may be required)")
@@ -894,6 +889,7 @@ survival <- function(
landmark = landmark,
pw = pw,
padjustmethod = padjustmethod,
+ ph_cox = ph_cox,
sc = sc,
kmunicate = kmunicate,
ce = ce,
@@ -904,8 +900,7 @@ survival <- function(
ci95 = ci95,
risktable = risktable,
censored = censored,
- pplot = pplot,
- sas = sas)
+ pplot = pplot)
analysis <- survivalClass$new(
options = options,
diff --git a/jamovi/0000.yaml b/jamovi/0000.yaml
index 50e1fea9..49516632 100644
--- a/jamovi/0000.yaml
+++ b/jamovi/0000.yaml
@@ -1,12 +1,12 @@
---
title: Common Analysis for Clinicopathological Research
name: ClinicoPath
-version: 0.0.2.08
+version: 0.0.2.12
jms: '1.0'
authors:
- Serdar Balci
maintainer: Serdar Balci
-date: '2023-12-03'
+date: '2023-12-07'
type: R
description: >-
ClinicoPath help researchers to generate natural language summaries of their
diff --git a/jamovi/jjhistostats.a.yaml b/jamovi/jjhistostats.a.yaml
index e6a50131..7cc4cc42 100644
--- a/jamovi/jjhistostats.a.yaml
+++ b/jamovi/jjhistostats.a.yaml
@@ -41,7 +41,7 @@ options:
- name: excl
title: Exclude Missing (NA)
type: Bool
- default: true
+ default: false
diff --git a/jamovi/multisurvival.r.yaml b/jamovi/multisurvival.r.yaml
index df09d67b..cb4a3553 100644
--- a/jamovi/multisurvival.r.yaml
+++ b/jamovi/multisurvival.r.yaml
@@ -33,13 +33,13 @@ items:
- dxdate
- tint
- multievent
- - adjexplanatory
+ # - adjexplanatory
- # - name: mydataview
- # title: mydataview
- # type: Preformatted
+ - name: mydataview
+ title: mydataview
+ type: Preformatted
# - name: text3
@@ -63,7 +63,7 @@ items:
- dxdate
- tint
- multievent
- - adjexplanatory
+ # - adjexplanatory
- name: text2
title: ''
@@ -79,7 +79,7 @@ items:
- dxdate
- tint
- multievent
- - adjexplanatory
+ # - adjexplanatory
- name: plot
@@ -103,7 +103,7 @@ items:
- dxdate
- tint
- multievent
- - adjexplanatory
+ # - adjexplanatory
# - name: plot2
# title: Hazards Regression Plot
@@ -144,16 +144,16 @@ items:
- dxdate
- tint
- multievent
- - adjexplanatory
+ # - adjexplanatory
- - name: plot4
- title: coxzph Plot
- type: Image
- width: 800
- height: 600
- renderFun: .plot4
+ # - name: plot4
+ # title: coxzph Plot
+ # type: Image
+ # width: 800
+ # height: 600
+ # renderFun: .plot4
diff --git a/jamovi/survival.a.yaml b/jamovi/survival.a.yaml
index 008097b1..0d99fbd4 100644
--- a/jamovi/survival.a.yaml
+++ b/jamovi/survival.a.yaml
@@ -209,6 +209,11 @@ options:
+ - name: ph_cox
+ title: Proportional Hazards Assumption
+ type: Bool
+ default: false
+
- name: sc
title: Survival Plot
type: Bool
@@ -270,10 +275,10 @@ options:
default: true
- - name: sas
- title: Single Arm Survival
- type: Bool
- default: false
+ # - name: sas
+ # title: Single Arm Survival
+ # type: Bool
+ # default: false
...
diff --git a/jamovi/survival.r.yaml b/jamovi/survival.r.yaml
index e865b614..ec37977c 100644
--- a/jamovi/survival.r.yaml
+++ b/jamovi/survival.r.yaml
@@ -26,9 +26,9 @@ items:
- multievent
- # - name: mydataview
- # title: mydataview
- # type: Preformatted
+ - name: mydataview
+ title: mydataview
+ type: Preformatted
# - name: medianSummary2
@@ -41,7 +41,7 @@ items:
# title: Median Survival Summary and Table
title: '`Median Survival Summary and Table - ${explanatory}`'
type: Preformatted
- visible: (!sas)
+ # visible: (!sas)
clearWith:
- explanatory
- outcome
@@ -93,7 +93,7 @@ items:
title: "Upper"
superTitle: '95% Confidence Interval'
type: number
- visible: (!sas)
+ # visible: (!sas)
clearWith:
- explanatory
- outcome
@@ -109,7 +109,7 @@ items:
# title: Cox Regression Summary and Table
title: '`Cox Regression Summary and Table - ${explanatory}`'
type: Preformatted
- visible: (!sas)
+ # visible: (!sas)
clearWith:
- explanatory
- outcome
@@ -140,7 +140,7 @@ items:
- name: 'HR_univariable'
title: "HR (Univariable)"
type: text
- visible: (!sas)
+ # visible: (!sas)
# - name: 'HR_multivariable'
# title: "HR (Multivariable)"
# type: text
@@ -170,14 +170,53 @@ items:
- tint
- multievent
- contexpl
- visible: (!sas)
+ # visible: (!sas)
+
+
+
+ - name: cox_ph
+ title: 'Proportional Hazards Assumption'
+ type: Preformatted
+ clearWith:
+ - explanatory
+ - outcome
+ - outcomeLevel
+ - overalltime
+ - fudate
+ - dxdate
+ - tint
+ - multievent
+ - contexpl
+
+
+
+ - name: plot7
+ title: '`Proportional Hazards Assumption - ${explanatory}`'
+ type: Image
+ width: 600
+ height: 450
+ renderFun: .plot7
+ visible: (ph_cox)
+ requiresData: true
+ clearWith:
+ - ph_cox
+ - endplot
+ - byplot
+ - explanatory
+ - outcome
+ - outcomeLevel
+ - overalltime
+ - fudate
+ - dxdate
+ - tint
+ - multievent
- name: survTableSummary
# title: '1, 3, 5-yr Survival Summary and Table'
title: '`1, 3, 5-yr Survival Summary and Table - ${explanatory}`'
type: Preformatted
- visible: (!sas)
+ # visible: (!sas)
clearWith:
- explanatory
- outcome
@@ -223,7 +262,7 @@ items:
superTitle: '95% Confidence Interval'
type: number
format: pc
- visible: (!sas)
+ # visible: (!sas)
clearWith:
- explanatory
- outcome
@@ -251,7 +290,7 @@ items:
- dxdate
- tint
- multievent
- visible: (pw && !sas)
+ visible: (pw) # && !sas)
@@ -270,7 +309,7 @@ items:
title: p-value
type: number
format: zto,pvalue
- visible: (pw && !sas)
+ visible: (pw) # && !sas)
clearWith:
- pw
- explanatory
@@ -299,7 +338,6 @@ items:
- sc
- endplot
- byplot
- - sas
- ci95
- risktable
- censored
@@ -312,6 +350,7 @@ items:
- tint
- multievent
- pplot
+ # - sas
@@ -328,7 +367,6 @@ items:
- ce
- endplot
- byplot
- - sas
- ci95
- risktable
- censored
@@ -340,6 +378,7 @@ items:
- dxdate
- tint
- multievent
+ # - sas
@@ -356,7 +395,6 @@ items:
- ch
- endplot
- byplot
- - sas
- ci95
- risktable
- censored
@@ -368,6 +406,7 @@ items:
- dxdate
- tint
- multievent
+ # - sas
@@ -383,7 +422,6 @@ items:
- kmunicate
- endplot
- byplot
- - sas
- explanatory
- outcome
- outcomeLevel
@@ -392,47 +430,55 @@ items:
- dxdate
- tint
- multievent
+ # - sas
refs:
- KMunicate
- KMunicate2
- - name: calculatedtime
- title: Add Calculated Time to Data
- type: Output
- varTitle: '`Calculated Time - from ${ dxdate } to { fudate }`'
- varDescription: Calculated Time from given Dates
- clearWith:
- - tint
- - dxdate
- - fudate
- - explanatory
- - outcome
- - outcomeLevel
- - overalltime
- - fudate
- - dxdate
- - tint
- - multievent
- - name: outcomeredifened
- title: Add Redefined Outcome to Data
- type: Output
- varTitle: '`Redefined Outcome - from ${ outcome } for analysis { analysistype }`'
- varDescription: Redefined Outcome from Outcome based on Analysis Type
- clearWith:
- - outcome
- - analysistype
- - multievent
- - explanatory
- - outcomeLevel
- - overalltime
- - fudate
- - dxdate
- - tint
- - multievent
+
+
+
+
+ # - name: calculatedtime
+ # title: Add Calculated Time to Data
+ # type: Output
+ # varTitle: '`Calculated Time - from ${ dxdate } to { fudate }`'
+ # varDescription: Calculated Time from given Dates
+ # clearWith:
+ # - tint
+ # - dxdate
+ # - fudate
+ # - explanatory
+ # - outcome
+ # - outcomeLevel
+ # - overalltime
+ # - fudate
+ # - dxdate
+ # - tint
+ # - multievent
+
+
+
+ # - name: outcomeredifened
+ # title: Add Redefined Outcome to Data
+ # type: Output
+ # varTitle: '`Redefined Outcome - from ${ outcome } for analysis { analysistype }`'
+ # varDescription: Redefined Outcome from Outcome based on Analysis Type
+ # clearWith:
+ # - outcome
+ # - analysistype
+ # - multievent
+ # - explanatory
+ # - outcomeLevel
+ # - overalltime
+ # - fudate
+ # - dxdate
+ # - tint
+ # - multievent
refs:
- finalfit
diff --git a/jamovi/survival.u.yaml b/jamovi/survival.u.yaml
index 5b013a64..a1a4da7d 100644
--- a/jamovi/survival.u.yaml
+++ b/jamovi/survival.u.yaml
@@ -133,16 +133,6 @@ children:
- type: ComboBox
name: analysistype
enable: (outcome && multievent)
- - type: CollapseBox
- label: Single Arm Survival
- collapsed: true
- children:
- - type: Label
- label: Single Arm Survival
- fitToGrid: true
- children:
- - type: CheckBox
- name: sas
- type: CollapseBox
label: Pairwise Comparisons
collapsed: true
@@ -169,6 +159,8 @@ children:
- type: LayoutBox
fitToGrid: true
children:
+ - type: CheckBox
+ name: ph_cox
- type: CheckBox
name: sc
- type: CheckBox
@@ -197,6 +189,7 @@ children:
name: censored
- type: CheckBox
name: pplot
+
- type: CollapseBox
label: Survival Tables
collapsed: true
@@ -208,23 +201,3 @@ children:
name: cutp
format: string
width: large
- # - type: CollapseBox
- # label: Save Converted Variables to Data
- # collapsed: true
- # children:
- # - type: Label
- # label: Add Calculated Time to Your Data
- # fitToGrid: true
- # children:
- # - type: Output
- # name: calculatedtime
- # enable: (tint)
- # fitToGrid: true
- # - type: Label
- # label: Add Redefined Outcome to Data
- # fitToGrid: true
- # children:
- # - type: Output
- # name: outcomeredifened
- # enable: (multievent)
- # fitToGrid: true
diff --git a/man/jjhistostats.Rd b/man/jjhistostats.Rd
index b4aa7330..17a8d48e 100644
--- a/man/jjhistostats.Rd
+++ b/man/jjhistostats.Rd
@@ -8,7 +8,7 @@ jjhistostats(
data,
dep,
grvar,
- excl = TRUE,
+ excl = FALSE,
typestatistics = "parametric",
centralityparameter = "mean",
centralityline = TRUE,
diff --git a/man/survival.Rd b/man/survival.Rd
index 65483c2e..e0e7e41b 100644
--- a/man/survival.Rd
+++ b/man/survival.Rd
@@ -25,6 +25,7 @@ survival(
landmark = 3,
pw = FALSE,
padjustmethod = "holm",
+ ph_cox = FALSE,
sc = FALSE,
kmunicate = FALSE,
ce = FALSE,
@@ -35,8 +36,7 @@ survival(
ci95 = FALSE,
risktable = FALSE,
censored = FALSE,
- pplot = TRUE,
- sas = FALSE
+ pplot = TRUE
)
}
\arguments{
@@ -80,6 +80,8 @@ survival(
\item{padjustmethod}{.}
+\item{ph_cox}{.}
+
\item{sc}{.}
\item{kmunicate}{.}
@@ -101,19 +103,20 @@ survival(
\item{censored}{.}
\item{pplot}{.}
-
-\item{sas}{.}
}
\value{
A results object containing:
\tabular{llllll}{
\code{results$subtitle} \tab \tab \tab \tab \tab a preformatted \cr
\code{results$todo} \tab \tab \tab \tab \tab a html \cr
+\code{results$mydataview} \tab \tab \tab \tab \tab a preformatted \cr
\code{results$medianSummary} \tab \tab \tab \tab \tab a preformatted \cr
\code{results$medianTable} \tab \tab \tab \tab \tab a table \cr
\code{results$coxSummary} \tab \tab \tab \tab \tab a preformatted \cr
\code{results$coxTable} \tab \tab \tab \tab \tab a table \cr
\code{results$tCoxtext2} \tab \tab \tab \tab \tab a html \cr
+\code{results$cox_ph} \tab \tab \tab \tab \tab a preformatted \cr
+\code{results$plot7} \tab \tab \tab \tab \tab an image \cr
\code{results$survTableSummary} \tab \tab \tab \tab \tab a preformatted \cr
\code{results$survTable} \tab \tab \tab \tab \tab a table \cr
\code{results$pairwiseSummary} \tab \tab \tab \tab \tab a preformatted \cr
@@ -122,8 +125,6 @@ A results object containing:
\code{results$plot2} \tab \tab \tab \tab \tab an image \cr
\code{results$plot3} \tab \tab \tab \tab \tab an image \cr
\code{results$plot6} \tab \tab \tab \tab \tab an image \cr
-\code{results$calculatedtime} \tab \tab \tab \tab \tab an output \cr
-\code{results$outcomeredifened} \tab \tab \tab \tab \tab an output \cr
}
Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.frame}}. For example: