Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #462 - capture KRI and other associated metadata #527

Merged
merged 37 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5936af9
change Rate to KRI
mattroumaya Jun 6, 2022
ea8595b
ffwd dev
mattroumaya Jun 7, 2022
4f66741
add KRI and Score cols
mattroumaya Jun 7, 2022
eddaa44
test KRILabel with ae.yaml
mattroumaya Jun 7, 2022
2a564d8
dont re-bind KRILabel
mattroumaya Jun 8, 2022
4716b30
Update R/Analyze_Poisson.R
mattroumaya Jun 8, 2022
105aa14
Update R/Analyze_Poisson.R
mattroumaya Jun 8, 2022
7c7b85d
Update R/Consent_Assess.R
mattroumaya Jun 8, 2022
7dfba04
Update R/Consent_Assess.R
mattroumaya Jun 8, 2022
e5886fb
Update R/Consent_Assess.R
mattroumaya Jun 8, 2022
d7f4e37
Update R/Flag.R
mattroumaya Jun 8, 2022
909dddc
Update R/Summarize.R
mattroumaya Jun 8, 2022
d663dd6
updates based on PR review
mattroumaya Jun 8, 2022
a7220a8
add Analyze_Identity + placeholder unit test
mattroumaya Jun 8, 2022
3fcf712
remove "KRI" because it is now default
mattroumaya Jun 8, 2022
3574402
remove labels from inst/assessments YAML files
mattroumaya Jun 8, 2022
c192b6d
update unit tests + documentation
mattroumaya Jun 8, 2022
b471d08
Update R/Analyze_Chisq.R
mattroumaya Jun 9, 2022
bd9b51b
Update R/Analyze_Fisher.R
mattroumaya Jun 9, 2022
bc96160
Update R/Analyze_Identity.R
mattroumaya Jun 9, 2022
9a3a306
Update R/Analyze_Wilcoxon.R
mattroumaya Jun 9, 2022
c23fabb
Update R/Flag.R
mattroumaya Jun 9, 2022
d1a719c
Update R/Flag.R
mattroumaya Jun 9, 2022
b7113e8
Update R/IE_Assess.R
mattroumaya Jun 9, 2022
8591393
Update R/IE_Assess.R
mattroumaya Jun 9, 2022
b32100d
[[]] in Analyze_Identity()
mattroumaya Jun 9, 2022
73337b1
unit tests
mattroumaya Jun 9, 2022
c8f338d
update tests
mattroumaya Jun 9, 2022
672fe17
ffwd dev
mattroumaya Jun 9, 2022
e25741c
update unit tests and documentation
mattroumaya Jun 9, 2022
5b520eb
update examples
mattroumaya Jun 9, 2022
e31e7b8
update qualification tests for KRI update
Jun 10, 2022
f54bae9
report sort
mattroumaya Jun 10, 2022
cdfd4a6
ffwd dev
mattroumaya Jun 10, 2022
112aaba
Merge pull request #535 from Gilead-BioStats/fix-462_quali
mattroumaya Jun 10, 2022
4334b2f
add Analyze_Identity() to pkgdown index
mattroumaya Jun 10, 2022
00d2aad
Update R/Analyze_Fisher.R
mattroumaya Jun 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export(AE_Map_Adam)
export(AE_Map_Raw)
export(Analyze_Chisq)
export(Analyze_Fisher)
export(Analyze_Identity)
export(Analyze_Poisson)
export(Analyze_Poisson_PredictBounds)
export(Analyze_Wilcoxon)
Expand Down
17 changes: 10 additions & 7 deletions R/AE_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' `c(-5, 5)` for `strMethod` = "poisson" and `c(.0001, NA)` for `strMethod` = "wilcoxon".
#' @param strMethod `character` Statistical model. Valid values include "poisson" (default) and
#' "wilcoxon".
#' @param strKRILabel `character` Describe the `KRI` column, a vector of length 1 that defaults to `AEs/Week`
#' @param lTags `list` Assessment tags, a named list of tags describing the assessment that defaults
#' to `list(Assessment="AE")`. `lTags` is returned as part of the assessment (`lAssess$lTags`) and
#' each tag is added as a column in `lAssess$dfSummary`.
Expand Down Expand Up @@ -52,6 +53,7 @@ AE_Assess <- function(
dfInput,
vThreshold = NULL,
strMethod = "poisson",
strKRILabel = "AEs/Week",
lTags = list(Assessment = "AE"),
bChart = TRUE,
bReturnChecks = FALSE,
Expand All @@ -61,7 +63,8 @@ AE_Assess <- function(
"dfInput is not a data.frame" = is.data.frame(dfInput),
"strMethod is not 'poisson' or 'wilcoxon'" = strMethod %in% c("poisson", "wilcoxon"),
"One or more of these columns: SubjectID, SiteID, Count, Exposure, and Rate not found in dfInput" = all(c("SubjectID", "SiteID", "Count", "Exposure", "Rate") %in% names(dfInput)),
"strMethod must be length 1" = length(strMethod) == 1
"strMethod must be length 1" = length(strMethod) == 1,
"strKRILabel must be length 1" = length(strKRILabel) == 1
)

if (!is.null(lTags)) {
Expand Down Expand Up @@ -93,7 +96,7 @@ AE_Assess <- function(
if (!bQuiet) cli::cli_h2("Initializing {.fn AE_Assess}")
if (!bQuiet) cli::cli_text("Input data has {nrow(lAssess$dfInput)} rows.")

lAssess$dfTransformed <- gsm::Transform_EventCount(lAssess$dfInput, strCountCol = "Count", strExposureCol = "Exposure")
lAssess$dfTransformed <- gsm::Transform_EventCount(lAssess$dfInput, strCountCol = "Count", strExposureCol = "Exposure", strKRILabel = strKRILabel)
if (!bQuiet) cli::cli_alert_success("{.fn Transform_EventCount} returned output with {nrow(lAssess$dfTransformed)} rows.")

if (strMethod == "poisson") {
Expand All @@ -110,10 +113,10 @@ AE_Assess <- function(
lAssess$dfAnalyzed <- gsm::Analyze_Poisson(lAssess$dfTransformed, bQuiet = bQuiet)
if (!bQuiet) cli::cli_alert_success("{.fn Analyze_Poisson} returned output with {nrow(lAssess$dfAnalyzed)} rows.")

lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, strColumn = "Residuals", vThreshold = vThreshold)
lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, vThreshold = vThreshold)
if (!bQuiet) cli::cli_alert_success("{.fn Flag} returned output with {nrow(lAssess$dfFlagged)} rows.")

lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, strScoreCol = "Residuals", lTags)
lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, lTags = lTags)
if (!bQuiet) cli::cli_alert_success("{.fn Summarize} returned output with {nrow(lAssess$dfSummary)} rows.")
} else if (strMethod == "wilcoxon") {
if (is.null(vThreshold)) {
Expand All @@ -127,13 +130,13 @@ AE_Assess <- function(
)
jwildfire marked this conversation as resolved.
Show resolved Hide resolved
}

lAssess$dfAnalyzed <- gsm::Analyze_Wilcoxon(lAssess$dfTransformed, "Rate", bQuiet = bQuiet)
lAssess$dfAnalyzed <- gsm::Analyze_Wilcoxon(lAssess$dfTransformed, bQuiet = bQuiet)
if (!bQuiet) cli::cli_alert_success("{.fn Analyze_Wilcoxon} returned output with {nrow(lAssess$dfAnalyzed)} rows.")

lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, strColumn = "PValue", vThreshold = vThreshold, strValueColumn = "Estimate")
lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, vThreshold = vThreshold, strValueColumn = "Estimate")
if (!bQuiet) cli::cli_alert_success("{.fn Flag} returned output with {nrow(lAssess$dfFlagged)} rows.")

lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, strScoreCol = "PValue", lTags = lTags)
lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, lTags = lTags)
if (!bQuiet) cli::cli_alert_success("{.fn Summarize} returned output with {nrow(lAssess$dfSummary)} rows.")
}

Expand Down
2 changes: 1 addition & 1 deletion R/Analyze_Chisq.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#'
#' @examples
#' dfInput <- Disp_Map(dfDisp = safetyData::adam_adsl, strCol = "DCREASCD", strReason = "Adverse Event")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strKRILabel = "Discontinuations due to AE/Month")
#' dfAnalyzed <- Analyze_Chisq(dfTransformed)
#'
#' @import dplyr
Expand Down
2 changes: 1 addition & 1 deletion R/Analyze_Fisher.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#'
#' @examples
#' dfInput <- Disp_Map(dfDisp = safetyData::adam_adsl, strCol = "DCREASCD", strReason = "Adverse Event")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strKRILabel = "Discontinuations due to AE")
#' dfAnalyzed <- Analyze_Fisher(dfTransformed)
#'
#' @import dplyr
Expand Down
31 changes: 31 additions & 0 deletions R/Analyze_Identity.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#' Analyze Identity
#'
#' Used in the data pipeline between `Transform` and `Flag` to rename KRI and Score columns.
#'
#' @param dfTransformed `data.frame` created by `Transform_EventCount()`
#' @param strValueCol `character` Name of column that will be copied as `Score`
#' @param strLabelCol `character` Name of column that will be copied as `ScoreLabel`
#' @param bQuiet `logical` Suppress warning messages? Default: `TRUE`
#'
#' @return `data.frame` that adds two columns to `dfTransformed`: `Score` and `ScoreLabel`
#'
#' @export

Analyze_Identity <- function(dfTransformed, strValueCol = 'KRI', strLabelCol = "KRILabel", bQuiet = TRUE){

stopifnot(
"dfTransformed is not a data.frame" = is.data.frame(dfTransformed),
"strValueCol and/or strLabelCol not found in dfTransformed" = all(c(strValueCol, strLabelCol) %in% names(dfTransformed)),
"strValueCol must be length 1" = length(strValueCol) == 1,
"strLabelCol must be length 1" = length(strLabelCol) == 1
)

dfAnalyzed <- dfTransformed %>%
mutate(Score = .data[[strValueCol]],
ScoreLabel = .data[[strLabelCol]])

if(!bQuiet) cli::cli_text(paste0("{.var Score} column created from `", strValueCol, "`."))
if(!bQuiet) cli::cli_text(paste0("{.var ScoreLabel} column created from `", strLabelCol, "`."))

return(dfAnalyzed)
}
24 changes: 17 additions & 7 deletions R/Analyze_Poisson.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#'
#' @examples
#' dfInput <- AE_Map_Raw()
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure", strKRILabel = "AEs/Week")
#' dfAnalyzed <- Analyze_Poisson(dfTransformed)
#'
#' @import dplyr
Expand All @@ -38,7 +38,8 @@
Analyze_Poisson <- function(dfTransformed, bQuiet = TRUE) {
stopifnot(
"dfTransformed is not a data.frame" = is.data.frame(dfTransformed),
"One or more of these columns: SiteID, N, TotalExposure, TotalCount, Rate" = all(c("SiteID", "N", "TotalExposure", "TotalCount", "Rate") %in% names(dfTransformed)),
"One or more of these columns not found: SiteID, N, TotalExposure, TotalCount, KRI, KRILabel" =
all(c("SiteID", "N", "TotalExposure", "TotalCount", "KRI", "KRILabel") %in% names(dfTransformed)),
"NA value(s) found in SiteID" = all(!is.na(dfTransformed[["SiteID"]]))
)

Expand All @@ -60,12 +61,21 @@ Analyze_Poisson <- function(dfTransformed, bQuiet = TRUE) {
)

dfAnalyzed <- broom::augment(cModel, dfModel, type.predict = "response") %>%
rename(
Residuals = .data$.resid,
PredictedCount = .data$.fitted,
mutate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gwu05 Do we want to add a strScoreCol parameter here? We can set default to ".resid", but could also allow users to set up assessments that use pvalue (or another parameter) as the Score column for use in flagging.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this hardcoded for now. Can revisit as needed if a new use case comes up.

ScoreLabel = "Residuals"
) %>%
select(.data$SiteID, .data$N, .data$TotalExposure, .data$TotalCount, .data$Rate, .data$Residuals, .data$PredictedCount) %>%
arrange(.data$Residuals)
select(
.data$SiteID,
.data$N,
.data$TotalCount,
.data$TotalExposure,
.data$KRI,
.data$KRILabel,
Score = .data$.resid,
.data$ScoreLabel,
PredictedCount = .data$.fitted
) %>%
arrange(.data$Score)

return(dfAnalyzed)
}
2 changes: 1 addition & 1 deletion R/Analyze_Poisson_PredictBounds.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#'
#' @examples
#' dfInput <- AE_Map_Adam()
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure", strKRILabel = "AEs/Week")
#' dfBounds <- Analyze_Poisson_PredictBounds(dfTransformed, c(-5, 5))
#'
#' @importFrom stats glm offset poisson qchisq
Expand Down
15 changes: 10 additions & 5 deletions R/Analyze_Wilcoxon.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#'
#' @examples
#' dfInput <- AE_Map_Raw()
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure")
#' dfAnalyzed <- Analyze_Wilcoxon(dfTransformed, strOutcomeCol = "Rate")
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure", strKRILabel = "AEs/Week")
#' dfAnalyzed <- Analyze_Wilcoxon(dfTransformed)
#'
#' @import dplyr
#' @importFrom broom glance
Expand All @@ -44,7 +44,7 @@

Analyze_Wilcoxon <- function(
dfTransformed,
strOutcomeCol = NULL,
strOutcomeCol = "KRI",
strPredictorCol = "SiteID",
bQuiet = TRUE
) {
Expand All @@ -62,7 +62,9 @@ Analyze_Wilcoxon <- function(
"@param:strOutcomeCol or @param:strPredictorCol not found in @param:dfTransformed" =
all(c(strPredictorCol, strOutcomeCol) %in% names(dfTransformed)),
"NA value(s) found in @param:strPredictorCol" =
all(!is.na(dfTransformed[[strPredictorCol]]))
all(!is.na(dfTransformed[[strPredictorCol]])),
"One or more of these columns not found: SiteID, N, TotalExposure, TotalCount, KRI, KRILabel" =
all(c("SiteID", "N", "TotalExposure", "TotalCount", "KRI", "KRILabel") %in% names(dfTransformed))
)

wilcoxon_model <- function(predictorValue) {
Expand Down Expand Up @@ -126,6 +128,9 @@ Analyze_Wilcoxon <- function(

return(
dfAnalyzed %>%
select(names(dfTransformed), .data$Estimate, .data$PValue)
select(names(dfTransformed), .data$Estimate, Score = .data$PValue) %>%
mutate(
ScoreLabel = "P value"
)
)
}
17 changes: 11 additions & 6 deletions R/Consent_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#' @param dfInput `data.frame` Input data, a data frame with one record per subject.
#' @param nThreshold `numeric` Threshold specification. Default: `0.5`
#' @param lTags `list` Assessment tags, a named list of tags describing the assessment that defaults to `list(Assessment="IE")`. `lTags` is returned as part of the assessment (`lAssess$lTags`) and each tag is added as a column in `lAssess$dfSummary`.
#' @param strKRILabel `character` Describe the `KRI` column, a vector of length 1 that defaults to `Total Number of Consent Issues`
#' @param bChart `logical` Generate data visualization? Default: `TRUE`
#' @param bReturnChecks `logical` Return input checks from `is_mapping_valid`? Default: `FALSE`
#' @param bQuiet `logical` Suppress warning messages? Default: `TRUE`
Expand Down Expand Up @@ -57,6 +58,7 @@ Consent_Assess <- function(
dfInput,
nThreshold = 0.5,
lTags = list(Assessment = "Consent"),
strKRILabel = "Total Number of Consent Issues",
bChart = TRUE,
bReturnChecks = FALSE,
bQuiet = TRUE
Expand All @@ -65,7 +67,8 @@ Consent_Assess <- function(
"dfInput is not a data.frame" = is.data.frame(dfInput),
"One or more of these columns: SubjectID, SiteID,and Count not found in dfInput" = all(c("SubjectID", "SiteID", "Count") %in% names(dfInput)),
"nThreshold must be numeric" = is.numeric(nThreshold),
"nThreshold must be length 1" = length(nThreshold) == 1
"nThreshold must be length 1" = length(nThreshold) == 1,
"strKRILabel must be length 1" = length(strKRILabel) == 1
)

if (!is.null(lTags)) {
Expand Down Expand Up @@ -96,16 +99,18 @@ Consent_Assess <- function(
if (checks$status) {
if (!bQuiet) cli::cli_h2("Initializing {.fn Consent_Assess}")
if (!bQuiet) cli::cli_text("Input data has {nrow(lAssess$dfInput)} rows.")
lAssess$dfTransformed <- gsm::Transform_EventCount(lAssess$dfInput, strCountCol = "Count")
lAssess$dfTransformed <- gsm::Transform_EventCount(lAssess$dfInput, strCountCol = "Count", strKRILabel = strKRILabel)
if (!bQuiet) cli::cli_alert_success("{.fn Transform_EventCount} returned output with {nrow(lAssess$dfTransformed)} rows.")

lAssess$dfAnalyzed <- lAssess$dfTransformed %>% dplyr::mutate(Estimate = .data$TotalCount)
if (!bQuiet) cli::cli_alert_info("No analysis function used. {.var dfTransformed} copied directly to {.var dfAnalyzed}")
lAssess$dfAnalyzed <- lAssess$dfTransformed %>%
Analyze_Identity(bQuiet = bQuiet)

lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, vThreshold = c(NA, nThreshold), strColumn = "Estimate")
if (!bQuiet) cli::cli_alert_info("No analysis function used. {.var dfTransformed} copied directly to {.var dfAnalyzed} with added {.var ScoreLabel} column.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!bQuiet) cli::cli_alert_info("No analysis function used. {.var dfTransformed} copied directly to {.var dfAnalyzed} with added {.var ScoreLabel} column.")
if (!bQuiet) cli::cli_alert_success("{.fn Analyze_Identity} returned output with {nrow(lAssess$dfAnalyzed)} rows.")


lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, vThreshold = c(NA, nThreshold))
if (!bQuiet) cli::cli_alert_success("{.fn Flag} returned output with {nrow(lAssess$dfFlagged)} rows.")

lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, strScoreCol = "TotalCount", lTags)
lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, lTags = lTags)
if (!bQuiet) cli::cli_alert_success("{.fn Summarize} returned output with {nrow(lAssess$dfSummary)} rows.")

if (bChart) {
Expand Down
10 changes: 5 additions & 5 deletions R/Flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
#'
#' @examples
#' dfInput <- AE_Map_Adam()
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure")
#' dfAnalyzed <- Analyze_Wilcoxon(dfTransformed, "Rate")
#' dfFlagged <- Flag(dfAnalyzed) # PValue < 0.05 flagged
#' dfTransformed <- Transform_EventCount(dfInput, strCountCol = "Count", strExposureCol = "Exposure", strKRILabel = "AEs/Week")
#' dfAnalyzed <- Analyze_Wilcoxon(dfTransformed)
#' dfFlagged <- Flag(dfAnalyzed) # P value (dfAnalyzed$Score) < 0.05 flagged
#' dfFlagged10 <- Flag(dfAnalyzed, vThreshold = c(0.10, NA)) # PValue <0.10 flagged
#' # Flag direction set based on 'Statistic' column
#' dfFlagged <- Flag(dfAnalyzed, strColumn = "PValue", strValueColumn = "Estimate")
#' dfFlagged <- Flag(dfAnalyzed, strColumn = "Score", strValueColumn = "Estimate")
#'
#' @import dplyr
#' @importFrom stats median
Expand All @@ -46,7 +46,7 @@

Flag <- function(
dfAnalyzed,
strColumn = "PValue",
strColumn = "Score",
vThreshold = c(0.05, NA),
mattroumaya marked this conversation as resolved.
Show resolved Hide resolved
strValueColumn = NULL
) {
Expand Down
17 changes: 11 additions & 6 deletions R/IE_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @param dfInput `data.frame` Input data, a data frame with one record per subject.
#' @param nThreshold `numeric` Threshold specification. Default: `0.5`
#' @param lTags `list` Assessment tags, a named list of tags describing the assessment that defaults to `list(Assessment="IE")`. `lTags` is returned as part of the assessment (`lAssess$lTags`) and each tag is added as a column in `lAssess$dfSummary`.
#' @param strKRILabel `character` Describe the `KRI` column, a vector of length 1 that defaults to `# of Inclusion/Exclusion Issues`
#' @param bChart `logical` Generate data visualization? Default: `TRUE`
#' @param bReturnChecks `logical` Return input checks from `is_mapping_valid`? Default: `FALSE`
#' @param bQuiet `logical` Suppress warning messages? Default: `TRUE`
Expand Down Expand Up @@ -48,6 +49,7 @@ IE_Assess <- function(
dfInput,
nThreshold = 0.5,
lTags = list(Assessment = "IE"),
strKRILabel = "# of Inclusion/Exclusion Issues",
bChart = TRUE,
bReturnChecks = FALSE,
bQuiet = TRUE
Expand All @@ -56,7 +58,8 @@ IE_Assess <- function(
"dfInput is not a data.frame" = is.data.frame(dfInput),
"One or more of these columns: SubjectID, SiteID, Count, Exposure, and Rate not found in dfInput" = all(c("SubjectID", "SiteID", "Count") %in% names(dfInput)),
"nThreshold must be numeric" = is.numeric(nThreshold),
"nThreshold must be length 1" = length(nThreshold) == 1
"nThreshold must be length 1" = length(nThreshold) == 1,
"strKRILabel must be length 1" = length(strKRILabel) == 1
)

if (!is.null(lTags)) {
Expand Down Expand Up @@ -87,16 +90,18 @@ IE_Assess <- function(
if (checks$status) {
if (!bQuiet) cli::cli_h2("Initializing {.fn IE_Assess}")
if (!bQuiet) cli::cli_text("Input data has {nrow(lAssess$dfInput)} rows.")
lAssess$dfTransformed <- gsm::Transform_EventCount(lAssess$dfInput, strCountCol = "Count")
lAssess$dfTransformed <- gsm::Transform_EventCount(lAssess$dfInput, strCountCol = "Count", strKRILabel = strKRILabel)
if (!bQuiet) cli::cli_alert_success("{.fn Transform_EventCount} returned output with {nrow(lAssess$dfTransformed)} rows.")

lAssess$dfAnalyzed <- lAssess$dfTransformed %>% dplyr::mutate(Estimate = .data$TotalCount)
if (!bQuiet) cli::cli_alert_info("No analysis function used. {.var dfTransformed} copied directly to {.var dfAnalyzed}")
lAssess$dfAnalyzed <- lAssess$dfTransformed %>%
Analyze_Identity(bQuiet = bQuiet)

lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, vThreshold = c(NA, nThreshold), strColumn = "Estimate")
if (!bQuiet) cli::cli_alert_info("No analysis function used. {.var dfTransformed} copied directly to {.var dfAnalyzed} with added {.var ScoreLabel} column.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!bQuiet) cli::cli_alert_info("No analysis function used. {.var dfTransformed} copied directly to {.var dfAnalyzed} with added {.var ScoreLabel} column.")
if (!bQuiet) cli::cli_alert_success("{.fn Analyze_Identity} returned output with {nrow(lAssess$dfAnalyzed)} rows.")


lAssess$dfFlagged <- gsm::Flag(lAssess$dfAnalyzed, vThreshold = c(NA, nThreshold))
if (!bQuiet) cli::cli_alert_success("{.fn Flag} returned output with {nrow(lAssess$dfFlagged)} rows.")

lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, strScoreCol = "TotalCount", lTags)
lAssess$dfSummary <- gsm::Summarize(lAssess$dfFlagged, lTags = lTags)
if (!bQuiet) cli::cli_alert_success("{.fn Summarize} returned output with {nrow(lAssess$dfSummary)} rows.")

if (bChart) {
Expand Down
Loading