@@ -113,7 +113,7 @@ curation <- function(articles, outbreaks, models, parameters, plotting) {
113113# function to produce forest plot for given dataframe
114114forest_plot <- function (df , label , color_column , lims , text_size = 11 ,
115115 show_label = FALSE , custom_colours = NA ,
116- segment_show.legend = NA , sort = FALSE ) {
116+ segment_show.legend = NA , sort = FALSE , qa_alpha = 1 ) {
117117 stopifnot(length(unique(df $ parameter_unit [! is.na(df $ parameter_unit )])) == 1 )# values must have same units
118118
119119 if (sort ){
@@ -128,29 +128,36 @@ forest_plot <- function(df, label, color_column, lims, text_size = 11,
128128 ! (is.na(parameter_uncertainty_lower_value ) &
129129 is.na(parameter_uncertainty_upper_value )))
130130 )
131+ df $ plot_alpha <- 1
132+ df $ segment_alpha <- 1
131133
132- cats <- length(unique(df [[color_column ]]))
134+ if (qa_alpha != 1 ){
135+ df [df $ qa_score < 0.5 , ]$ plot_alpha <- qa_alpha
136+ df [df $ qa_score < 0.5 , ]$ segment_alpha <- 0.65 * qa_alpha
137+ }
133138
139+ cats <- length(unique(df [[color_column ]]))
134140 gg <- ggplot(df ) +
135141 geom_segment(aes(x = parameter_lower_bound , xend = parameter_upper_bound ,
136- y = urefs , yend = urefs , color = .data [[color_column ]]),
137- linewidth = 3 , alpha = 0.65 , show.legend = segment_show.legend ) +
142+ y = urefs , yend = urefs , color = .data [[color_column ]], ),
143+ linewidth = 3 , alpha = df $ segment_alpha , show.legend = segment_show.legend ) +
138144 geom_errorbar(aes(xmin = parameter_uncertainty_lower_value , xmax = parameter_uncertainty_upper_value ,
139145 y = urefs ),
140- width = 0.25 , lwd = 0.5 , color = " black" , alpha = 1 ) +
141- geom_errorbar(data = df | > filter( ! uncertainty_present ) ,
146+ width = 0.25 , lwd = 0.5 , color = " black" , alpha = df $ plot_alpha ) +
147+ geom_errorbar(data = df [ ! df $ uncertainty_present ,] ,
142148 aes(xmin = parameter_2_lower_bound , xmax = parameter_2_upper_bound ,
143149 y = urefs ),
144- width = 0.25 , lwd = 0.5 , color = " black" , alpha = 1 , linetype = " dashed" ,
145- lineend = " square" ) +
146- geom_errorbar(data = df | > filter( uncertainty_present ) ,
150+ width = 0.25 , lwd = 0.5 , color = " black" , linetype = " dashed" ,
151+ lineend = " square" , alpha = df [ ! ( df $ uncertainty_present ),] $ plot_alpha ) +
152+ geom_errorbar(data = df [ df $ uncertainty_present ,] ,
147153 aes(xmin = parameter_2_lower_bound , xmax = parameter_2_upper_bound ,
148154 y = urefs ),
149- width = 0.25 , lwd = 0.5 , color = " black" , alpha = 1 , linetype = " dashed" ,
150- lineend = " square" , position = position_nudge(y = - 0.25 )) +
155+ width = 0.25 , lwd = 0.5 , color = " black" , linetype = " dashed" ,
156+ lineend = " square" , position = position_nudge(y = - 0.25 ),
157+ alpha = df [df $ uncertainty_present ,]$ plot_alpha ) +
151158 geom_point(aes(x = parameter_value , y = urefs ,
152159 shape = parameter_value_type , fill = .data [[color_column ]]),
153- size = 3 , stroke = 1 , color = " black" , alpha = 1 )
160+ alpha = df $ plot_alpha , size = 3 , stroke = 1 , color = " black" )
154161
155162 if (all(df $ parameter_class == " Reproduction number" )) {
156163 gg <- gg +
0 commit comments