@@ -223,6 +223,7 @@ waterfallClass <- if (requireNamespace('jmvcore')) R6::R6Class(
223
223
.calculateMetrics = function (df ) {
224
224
# # Calculate response rates ----
225
225
cats <- c(" CR" , " PR" , " SD" , " PD" )
226
+
226
227
summary_table <- data.frame (
227
228
category = cats ,
228
229
n = sapply(cats , function (x ) sum(df $ category == x , na.rm = TRUE )),
@@ -427,19 +428,46 @@ waterfallClass <- if (requireNamespace('jmvcore')) R6::R6Class(
427
428
428
429
# # Update results tables ----
429
430
for (i in seq_len(nrow(metrics $ summary ))) {
430
- self $ results $ summary $ addRow(rowKey = i , values = list (
431
+ self $ results $ summaryTable $ addRow(rowKey = i , values = list (
431
432
category = metrics $ summary $ category [i ],
432
433
n = metrics $ summary $ n [i ],
433
- percent = metrics $ summary $ percent [i ]/ 100
434
+ percent = paste0( metrics $ summary $ percent [i ], " % " )
434
435
))
435
436
}
436
437
437
- self $ results $ clinicalMetrics $ addRow(rowKey = 1 , values = list (
438
+
439
+
440
+ self $ results $ summaryTable $ addFootnote(
441
+ rowNo = 1 ,
442
+ col = " category" ,
443
+ " Complete Response (CR): Complete disappearance of all target lesions."
444
+ )
445
+
446
+ self $ results $ summaryTable $ addFootnote(
447
+ rowNo = 2 ,
448
+ col = " category" ,
449
+ " Partial Response (PR): At least 30% decrease in sum of target lesions."
450
+ )
451
+
452
+ self $ results $ summaryTable $ addFootnote(
453
+ rowNo = 3 ,
454
+ col = " category" ,
455
+ " Stable Disease (SD): Neither PR nor PD criteria met."
456
+ )
457
+
458
+ self $ results $ summaryTable $ addFootnote(
459
+ rowNo = 4 ,
460
+ col = " category" ,
461
+ " Progressive Disease (PD): At least 20% increase in sum of target lesions."
462
+ )
463
+
464
+
465
+ self $ results $ clinicalMetrics $ addRow(rowKey = 1 , values = list (
438
466
metric = " Objective Response Rate (CR+PR)" ,
439
467
value = paste0(metrics $ ORR , " %" )
440
468
))
441
469
442
- self $ results $ clinicalMetrics $ addRow(rowKey = 2 , values = list (
470
+ self $ results $ clinicalMetrics $ addRow(rowKey = 2 , values = list (
443
471
metric = " Disease Control Rate (CR+PR+SD)" ,
444
472
value = paste0(metrics $ DCR , " %" )
445
473
))
@@ -450,26 +478,53 @@ waterfallClass <- if (requireNamespace('jmvcore')) R6::R6Class(
450
478
451
479
# mydataview ----
452
480
453
- # self$results$mydataview$setContent(
454
- # list(
455
- # "data" = processed_data,
456
- # options = list(
457
- # "patientID" = self$options$patientID,
458
- # "response" = self$options$responseVar,
459
- # "timeVar" = self$options$timeVar,
460
- # "sortBy" = self$options$sortBy,
461
- # "showThresholds" = self$options$showThresholds,
462
- # "labelOutliers" = self$options$labelOutliers,
463
- # "colorScheme" = self$options$colorScheme,
464
- # "barWidth" = self$options$barWidth,
465
- # "barAlpha" = self$options$barAlpha,
466
- # "showMedian" = self$options$showMedian,
467
- # "showCI" = self$options$showCI,
468
- # "minResponseForLabel" = self$options$minResponseForLabel
469
- # ),
470
- # "metrics" = metrics
471
- # )
472
- # )
481
+ self $ results $ mydataview $ setContent(
482
+ list (
483
+ " data" = processed_data ,
484
+ " data_waterfall" = processed_data $ waterfall ,
485
+ " data_spider" = processed_data $ spider ,
486
+ options = list (
487
+ " patientID" = self $ options $ patientID ,
488
+ " response" = self $ options $ responseVar ,
489
+ " timeVar" = self $ options $ timeVar ,
490
+ " sortBy" = self $ options $ sortBy ,
491
+ " showThresholds" = self $ options $ showThresholds ,
492
+ " labelOutliers" = self $ options $ labelOutliers ,
493
+ " colorScheme" = self $ options $ colorScheme ,
494
+ " barWidth" = self $ options $ barWidth ,
495
+ " barAlpha" = self $ options $ barAlpha ,
496
+ " showMedian" = self $ options $ showMedian ,
497
+ " showCI" = self $ options $ showCI ,
498
+ " minResponseForLabel" = self $ options $ minResponseForLabel
499
+ ),
500
+ " metrics" = metrics
501
+ )
502
+ )
503
+
504
+
505
+ # # Add response category to data ----
506
+
507
+ if (is.null(self $ options $ timeVar ) && self $ options $ addResponseCategory && self $ results $ addResponseCategory $ isNotFilled()) {
508
+ df <- processed_data $ waterfall
509
+ self $ results $ addResponseCategory $ setRowNums(rownames(df ))
510
+ self $ results $ addResponseCategory $ setValues(df $ category )
511
+ }
512
+
513
+ if (! is.null(self $ options $ timeVar ) && self $ options $ addResponseCategory && self $ results $ addResponseCategory $ isNotFilled()) {
514
+ # Get waterfall data and extract unique patient categories
515
+ df <- processed_data $ waterfall %> %
516
+ dplyr :: select(!! rlang :: sym(self $ options $ patientID ), category ) %> %
517
+ dplyr :: distinct()
518
+
519
+ # Join with original data
520
+ df2 <- self $ data %> %
521
+ dplyr :: left_join(df , by = self $ options $ patientID )
522
+
523
+ # Update response category output
524
+ self $ results $ addResponseCategory $ setRowNums(rownames(df2 ))
525
+ self $ results $ addResponseCategory $ setValues(df2 $ category )
526
+ }
527
+
473
528
474
529
475
530
# # Prepare plot data ----
@@ -695,46 +750,46 @@ waterfallClass <- if (requireNamespace('jmvcore')) R6::R6Class(
695
750
# Create an informative message with improved formatting for readability
696
751
text_warning <- paste0(
697
752
" Spider Plot Requirements and Guidelines" ,
698
- " <br><br> " ,
753
+ " \n\n " ,
699
754
" This visualization requires two key elements:" ,
700
- " <br> " ,
755
+ " \n " ,
701
756
" 1. A time variable to show response trajectories" ,
702
- " <br> " ,
757
+ " \n " ,
703
758
" 2. The 'Show Spider Plot' option to be enabled" ,
704
- " <br><br> " ,
759
+ " \n\n " ,
705
760
" Understanding Spider Plots:" ,
706
- " <br> " ,
707
- " A spider plot helps visualize how each patient's response changes over time. " ,
708
- " Each line represents one patient's treatment journey, making it easy to see " ,
761
+ " \n " ,
762
+ " A spider plot helps visualize how each patient's response changes over time. \n " ,
763
+ " Each line represents one patient's treatment journey, making it easy to see \n " ,
709
764
" patterns in response and identify different types of outcomes." ,
710
- " <br><br> " ,
765
+ " \n\n " ,
711
766
" To Generate the Plot:" ,
712
- " <br> " ,
767
+ " \n " ,
713
768
" • Add a time variable (such as months from baseline)" ,
714
- " <br> " ,
769
+ " \n " ,
715
770
" • Enable 'Show Spider Plot' in the options panel" ,
716
- " <br><br> " ,
717
- " The resulting visualization will help you track response patterns " ,
718
- " and compare outcomes across different patients over time." ,
771
+ " \n\n " ,
772
+ " The resulting visualization will help you track response patterns \n " ,
773
+ " and compare outcomes across different patients over time.\n\n " ,
719
774
sep = " "
720
775
)
721
776
722
777
text_warning <- paste0(text_warning ,
723
778
" Time Variable Requirement:" ,
724
- " <br><br>A time variable is required to create visualizations when using raw measurements." ,
725
- " <br><br>Why is this important?" ,
726
- " <br> • Baseline identification: Marks the starting point (time = 0)" ,
727
- " <br> • Response calculation: Computes changes from baseline" ,
728
- " <br> • Progression tracking: Shows how response changes over time" ,
729
- " <br><br>How to proceed:" ,
730
- " <br>1 . Add a time variable to your data" ,
731
- " <br>2 . Time should start at 0 (baseline)" ,
732
- " <br>3 . Use consistent time units (e.g., months or weeks)" ,
733
- " <br><br>Example time variable format:" ,
734
- " <br>PatientID . Time Measurement" ,
735
- " <br>PT1 0 50 (baseline)" ,
736
- " <br>PT1 2 25 (2 months)" ,
737
- " <br>PT1 4 10 (4 months)" ,
779
+ " \n\n A time variable is required to create visualizations when using raw measurements." ,
780
+ " \n\n Why is this important?" ,
781
+ " \n • Baseline identification: Marks the starting point (time = 0)" ,
782
+ " \n • Response calculation: Computes changes from baseline" ,
783
+ " \n • Progression tracking: Shows how response changes over time" ,
784
+ " \n\n How to proceed:" ,
785
+ " \n 1 . Add a time variable to your data" ,
786
+ " \n 2 . Time should start at 0 (baseline)" ,
787
+ " \n 3 . Use consistent time units (e.g., months or weeks)" ,
788
+ " \n\n Example time variable format:" ,
789
+ " \n PatientID . Time Measurement" ,
790
+ " \n PT1 0 50 (baseline)" ,
791
+ " \n PT1 2 25 (2 months)" ,
792
+ " \n PT1 4 10 (4 months)" ,
738
793
sep = " "
739
794
)
740
795
0 commit comments