8000 Fix 817 - Add HTMLWidgets barcharts by mattroumaya · Pull Request #883 · Gilead-BioStats/gsm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix 817 - Add HTMLWidgets barcharts #883

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

Merged
merged 67 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f3d7d41
adding barchart files
MayaGans Nov 14, 2022
45b3696
reference gsm package
mattroumaya Nov 14, 2022
7cdf721
updates to AE_Assess
mattroumaya Nov 15, 2022
fbcd3fb
debug and update
mattroumaya Nov 16, 2022
264d991
pass thresholds to rbm-viz as a simple vector/array
samussiah Nov 16, 2022
67ab491
update tests - snapshot expected plots for now
mattroumaya Nov 16, 2022
06268d5
Merge pull request #885 from Gilead-BioStats/add-barchart-simple-thre…
mattroumaya Nov 16, 2022
ba64b2e
add scatter plot
mattroumaya Nov 16, 2022
e80563f
add files
mattroumaya Nov 16, 2022
45decf8
update docs and namespace
mattroumaya Nov 16, 2022
9c25e87
update pkgdown
mattroumaya Nov 16, 2022
127fc00
updates to AE implementation
mattroumaya Nov 18, 2022
866ff78
Merge remote-tracking branch 'origin/dev' into add-barchart
mattroumaya Nov 18, 2022
917bdf4
add pkgdown ref
mattroumaya Nov 18, 2022
9e69105
fix tests
mattroumaya Nov 18, 2022
cdce0d2
add disp viz
mattroumaya Nov 28, 2022
07b8ae6
add MakeDfConfig
mattroumaya Nov 28, 2022
bd390b0
add pkgdown
mattroumaya Nov 28, 2022
16b38e8
add rbm-viz
mattroumaya Nov 28, 2022
8368f7e
Merge branch 'dev' into add-barchart
mattroumaya Nov 29, 2022
cb28f9e
update tests
mattroumaya Nov 30, 2022
6a11117
Update R/AE_Assess.R
mattroumaya Dec 5, 2022
fe4bdc9
Update R/Consent_Assess.R
mattroumaya Dec 5, 2022
a18468b
Update R/Disp_Assess.R
mattroumaya Dec 5, 2022
d9d2858
Update R/PD_Assess.R
mattroumaya Dec 5, 2022
debd709
Create pperational KRI mapping
Zhongkai-Wang Oct 31, 2022
df85ce5
Create mapping
Zhongkai-Wang Nov 16, 2022
82eb08e
Create specs
Zhongkai-Wang Nov 16, 2022
31ed9a7
Update mapping and util
Zhongkai-Wang Nov 17, 2022
62ae0a0
Update mapping
Zhongkai-Wang Nov 17, 2022
638f091
Update specs
Zhongkai-Wang Nov 17, 2022
ec82668
Assessment functions, specs, mapping
Zhongkai-Wang Nov 17, 2022
d6b752f
Documentation
Zhongkai-Wang Nov 17, 2022
2ee843f
Build Markdown
Zhongkai-Wang Nov 17, 2022
f6852c8
add yaml
mattroumaya Nov 21, 2022
ba143ad
update joins
mattroumaya Nov 22, 2022
05392d7
add map_raw tests
mattroumaya Nov 22, 2022
11a5df7
Update typo and document in fix-781
Zhongkai-Wang Nov 28, 2022
00e326a
Update variable name for domains
Zhongkai-Wang Nov 29, 2022
65261a2
Update to remove strType as an option
Zhongkai-Wang Nov 29, 2022
44e809e
Update mapping and specs
Zhongkai-Wang Nov 29, 2022
d127028
Build Markdown
Zhongkai-Wang Nov 29, 2022
565d71f
Update tests
Zhongkai-Wang Nov 29, 2022
56cb9d3
update tests + workflows
mattroumaya Nov 29, 2022
f90bbcd
add unit tests, update test data, update specs
mattroumaya Nov 30, 2022
01316fb
remove duplicate
mattroumaya Nov 30, 2022
a547596
test merge
Zhongkai-Wang Dec 1, 2022
b6e9cf4
Update merge logic
Zhongkai-Wang Dec 1, 2022
f5e601a
Update PascalCase
Zhongkai-Wang Dec 1, 2022
7428116
Remove numerator with NA during mapping
Zhongkai-Wang Dec 1, 2022
9c76c52
update tests
mattroumaya Dec 1, 2022
04c76e1
fix #909
samussiah Dec 1, 2022
4b9394e
update snapshots
mattroumaya Dec 1, 2022
c640f1a
add UpdateParams function
mattroumaya Oct 24, 2022
8987390
pkgdown
mattroumaya Oct 24, 2022
5ff36d1
review updates
mattroumaya Nov 2, 2022
9596ffd
ffwd stats PR + updates
mattroumaya Nov 2, 2022
a50bbcd
update docs
mattroumaya Nov 2, 2022
1fab3f5
update docs
mattroumaya Nov 23, 2022
054d824
add metadata QC checks
mattroumaya Nov 23, 2022
e24f41d
Update _pkgdown.yml
mattroumaya Nov 23, 2022
dc54437
tweak UpdateParams
samussiah Nov 30, 2022
30002c3
update from devtools::check()
mattroumaya Dec 5, 2022
07bff94
Merge branch 'dev' into add-barchart
mattroumaya Dec 5, 2022
88e2d5c
updates
mattroumaya Dec 5, 2022
bed7fcf
updates
mattroumaya Dec 5, 2022
189e307
rbm-viz 0.4.1 -> 0.13.0
mattroumaya Dec 5, 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 DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Imports:
glue,
gt,
ggplot2,
htmlwidgets,
here,
janitor,
knitr,
Expand Down
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export(IE_Assess)
export(IE_Map_Raw)
export(LB_Assess)
export(LB_Map_Raw)
export(MakeDfConfig)
export(MakeStratifiedAssessment)
export(MakeWorkflowList)
export(Make_Snapshot)
Expand Down Expand Up @@ -63,13 +64,20 @@ export(UpdateParams)
export(Visualize_Scatter)
export(Visualize_Score)
export(Visualize_Workflow)
export(barChart)
export(barChartOutput)
export(generate_md_table)
export(is_mapping_valid)
export(parse_data_mapping)
export(parse_data_spec)
export(rank_chg)
export(renderBarChart)
export(renderScatterPlot)
export(scatterPlot)
export(scatterPlotOutput)
import(dplyr)
import(ggplot2)
import(htmlwidgets)
import(purrr)
importFrom(DiagrammeR,create_graph)
importFrom(DiagrammeR,create_node_df)
Expand Down
54 changes: 50 additions & 4 deletions R/AE_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,61 @@ AE_Assess <- function(

if (!hasName(lData, "dfBounds")) lData$dfBounds <- NULL



# rbm-viz setup -----------------------------------------------------------

dfConfig <- MakeDfConfig(
strMethod = strMethod,
strGroup = strGroup,
strAbbreviation = "AE",
strMetric = "AE Reporting Rate",
strNumerator = "AEs",
strDenominator = "Days on Treatment",
vThreshold = vThreshold
)



# scatter plots -----------------------------------------------------------

# ggplot bar charts -------------------------------------------------------

if (strMethod != "Identity") {


lCharts$scatter <- gsm::Visualize_Scatter(dfFlagged = lData$dfFlagged, dfBounds = lData$dfBounds, strGroupLabel = strGroup)
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Scatter} created {length(lCharts)} chart.")

# rbm-viz charts ----------------------------------------------------------
lCharts$scatterJS <- scatterPlot(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer Widget or Interactive here if I may be so pedantic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samussiah will update the naming in a separate PR, think that'll make things a tad easier

results = lData$dfFlagged,
workflow = dfConfig,
bounds = lData$dfBounds,
elementId = "aeAssessScatter"
)
if (!bQuiet) cli::cli_alert_success("Created {length(lCharts)} scatter plot{?s}.")
}

lCharts$barMetric <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "metric")
lCharts$barScore <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "score", vThreshold = vThreshold)
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Score} created {length(names(lCharts)[names(lCharts) != 'scatter'])} chart{?s}.")

# bar charts --------------------------------------------------------------
lCharts$barMetric <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "metric")
lCharts$barScore <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "score", vThreshold = vThreshold)

lCharts$barMetricJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "metric",
elementId = "aeAssessMetric"
)

lCharts$barScoreJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "score",
elementId = "aeAssessScore"
)

if (!bQuiet) cli::cli_alert_success("Created {length(names(lCharts)[!names(lCharts) %in% c('scatter', 'scatterJS')])} bar chart{?s}.")


# return data -------------------------------------------------------------
Expand Down
28 changes: 27 additions & 1 deletion R/Consent_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,35 @@ Consent_Assess <- function(

# visualizations ----------------------------------------------------------
lCharts <- list()

dfConfig <- MakeDfConfig(
strMethod = "identity",
strGroup = strGroup,
strAbbreviation = "CONSENT",
strMetric = "Consent Issues",
strNumerator = "Consent Issues",
strDenominator = "Total Subjects",
Copy link
Contributor

Choose a reason for hiding this comment

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

Denominator doesn't apply here.

vThreshold = nThreshold
)

lCharts$barMetric <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "metric")
lCharts$barScore <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "score")
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Score} created {length(lCharts)} chart{?s}.")

lCharts$barMetricJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "metric",
elementId = "consentAssessMetric"
)

lCharts$barScoreJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "score",
elementId = "consentAssessScore"
)

if (!bQuiet) cli::cli_alert_success("Created {length(lCharts)} bar chart{?s}.")

# return data -------------------------------------------------------------
return(list(
Expand Down
14 changes: 7 additions & 7 deletions R/DataChg_Map_Raw.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
#' @export

DataChg_Map_Raw <- function(
dfs = list(
dfSUBJ = clindata::rawplus_dm,
dfDATACHG = clindata::edc_data_change_rate
),
lMapping = yaml::read_yaml(system.file("mappings", "mapping_edc.yaml", package = "gsm")),
bReturnChecks = FALSE,
bQuiet = TRUE
dfs = list(
dfSUBJ = clindata::rawplus_dm,
dfDATACHG = clindata::edc_data_change_rate
),
lMapping = yaml::read_yaml(system.file("mappings", "mapping_edc.yaml", package = "gsm")),
bReturnChecks = FALSE,
bQuiet = TRUE
) {
stopifnot(
"bReturnChecks must be logical" = is.logical(bReturnChecks),
Expand Down
15 changes: 8 additions & 7 deletions R/DataEntry_Map_Raw.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@
#' @export

DataEntry_Map_Raw <- function(
dfs = list(
dfSUBJ = clindata::rawplus_dm,
dfDATAENT = clindata::edc_data_entry_lag
),
lMapping = yaml::read_yaml(system.file("mappings", "mapping_edc.yaml", package = "gsm")),
bReturnChecks = FALSE,
bQuiet = TRUE
dfs = list(
dfSUBJ = clindata::rawplus_dm,
dfDATAENT = clindata::edc_data_entry_lag
),
lMapping = yaml::read_yaml(system.file("mappings", "mapping_edc.yaml", package = "gsm")),
bReturnChecks = FALSE,
bQuiet = TRUE

) {
stopifnot(
"bReturnChecks must be logical" = is.logical(bReturnChecks),
Expand Down
52 changes: 50 additions & 2 deletions R/Disp_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,62 @@ Disp_Assess <- function(
if (strMethod != "QTL") {
if (!hasName(lData, "dfBounds")) lData$dfBounds <- NULL



# rbm-viz setup -----------------------------------------------------------
dfConfig <- MakeDfConfig(
strMethod = strMethod,
strGroup = strGroup,
strAbbreviation = "DISP",
strMetric = "Subject Discontinuation Rate",
strNumerator = "Subjects Discontinued",
strDenominator = "Total Subjects",
vThreshold = vThreshold
)



if (strMethod != "Identity") {


lCharts$scatter <- gsm::Visualize_Scatter(dfFlagged = lData$dfFlagged, dfBounds = lData$dfBounds, strGroupLabel = strGroup)
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Scatter} created {length(lCharts)} chart.")

if (exists('dfBounds', lData)) {
bounds <- lData$dfBounds
} else {
bounds <- NULL
}

lCharts$scatterJS <- scatterPlot(
results = lData$dfFlagged,
workflow = dfConfig,
bounds = bounds,
elementId = "dispAssessScatter"
)
if (!bQuiet) cli::cli_alert_success("Created {length(lCharts)} scatter plot{?s}.")
}


# bar charts --------------------------------------------------------------

lCharts$barMetric <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "metric")
lCharts$barScore <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "score", vThreshold = vThreshold)
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Score} created {length(names(lCharts)[names(lCharts) != 'scatter'])} chart{?s}.")

lCharts$barMetricJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "metric",
elementId = "dispAssessMetric"
)

lCharts$barScoreJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "score",
elementId = "dispAssessScore"
)

if (!bQuiet) cli::cli_alert_success("Created {length(names(lCharts)[!names(lCharts) %in% c('scatter', 'scatterJS')])} bar chart{?s}.")
}

# return data -------------------------------------------------------------
Expand Down
28 changes: 27 additions & 1 deletion R/IE_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,35 @@ IE_Assess <- function(

# visualizations ----------------------------------------------------------
lCharts <- list()

dfConfig <- MakeDfConfig(
strMethod = "identity",
strGroup = strGroup,
strAbbreviation = "IE",
strMetric = "Inclusion/Exclusion Issues (Count)",
Copy link
Contributor

Choose a reason for hiding this comment

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

< F438 task-lists disabled sortable>
Suggested change
strMetric = "Inclusion/Exclusion Issues (Count)",
strMetric = "Inclusion/Exclusion Issues",

strNumerator = "Inclusion/Exclusion Issues",
strDenominator = "Total Subjects",
Copy link
Contributor

Choose a reason for hiding this comment

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

Denominator doesn't apply here.

vThreshold = nThreshold
)

lCharts$barMetric <- Visualize_Score(dfFlagged = lData$dfFlagged, strType = "metric")
lCharts$barScore <- Visualize_Score(dfFlagged = lData$dfFlagged, strType = "score")
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Score} created {length(lCharts)} chart{?s}.")

lCharts$barMetricJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "metric",
elementId = "ieAssessMetric"
)

lCharts$barScoreJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "score",
elementId = "ieAssessScore"
)

if (!bQuiet) cli::cli_alert_success("Created {length(lCharts)} bar chart{?s}.")

# return data -------------------------------------------------------------
return(list(
Expand Down
42 changes: 40 additions & 2 deletions R/LB_Assess.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,52 @@ LB_Assess <- function(

if (!hasName(lData, "dfBounds")) lData$dfBounds <- NULL

dfConfig <- MakeDfConfig(
strMethod = strMethod,
strGroup = strGroup,
strAbbreviation = "LB",
strMetric = "LB Abnormalities (Rate)",
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
strMetric = "LB Abnormalities (Rate)",
strMetric = "Abnormal Lab Rate",

strNumerator = "Abnormal Lab Samples",
strDenominator = "Total Lab Samples",
vThreshold = vThreshold
)



if (strMethod != "Identity") {


lCharts$scatter <- gsm::Visualize_Scatter(dfFlagged = lData$dfFlagged, dfBounds = lData$dfBounds, strGroupLabel = strGroup)
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Scatter} created {length(lCharts)} chart.")

# rbm-viz charts ----------------------------------------------------------
lCharts$scatterJS <- scatterPlot(
results = lData$dfFlagged,
workflow = dfConfig,
bounds = lData$dfBounds,
elementId = "lbAssessScatter"
)

if (!bQuiet) cli::cli_alert_success("Created {length(lCharts)} scatter plot{?s}.")
}

lCharts$barMetric <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "metric")
lCharts$barScore <- gsm::Visualize_Score(dfFlagged = lData$dfFlagged, strType = "score", vThreshold = vThreshold)
if (!bQuiet) cli::cli_alert_success("{.fn Visualize_Score} created {length(names(lCharts)[names(lCharts) != 'scatter'])} chart{?s}.")

lCharts$barMetricJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "metric",
elementId = "lbAssessMetric"
)

lCharts$barScoreJS <- barChart(
results = lData$dfFlagged,
workflow = dfConfig,
yaxis = "score",
elementId = "lbAssessScore"
)

if (!bQuiet) cli::cli_alert_success("Created {length(names(lCharts)[!names(lCharts) %in% c('scatter', 'scatterJS')])} bar chart{?s}.")



Expand Down
3 changes: 2 additions & 1 deletion R/Make_Snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' See the Data Model Vignette - Appendix 2 - Data Model Specifications for detailed specifications.
#' @param lData `list` a named list of domain-level data frames. Names should match the values specified in `lMapping` and `lAssessments`, which are generally based on the expected inputs from `X_Map_Raw`.
#' @param lMapping `list` Column metadata with structure `domain$key`, where `key` contains the name of the column. Default: package-defined mapping for raw+.

#' @param lAssessments `list` a named list of metadata defining how each assessment should be run. By default, `MakeWorkflowList()` imports YAML specifications from `inst/workflow`.
#' @param bUpdateParams `logical` if `TRUE`, configurable parameters found in `lMeta$config_param` will overwrite the default values in `lMeta$meta_params`. Default: `FALSE`.
#' @param cPath `character` a character string indicating a working directory to save .csv files; the output of the snapshot.
Expand Down Expand Up @@ -141,6 +140,8 @@ bQuiet = TRUE
}




# status_site -------------------------------------------------------------
if (!("enrolled_participants" %in% colnames(status_site))) {
status_site_count <- gsm::Get_Enrolled(
Expand Down
Loading
0