@@ -321,3 +321,169 @@ get_second_data_fig <- function(seq_counts_as_of1,
321321 )
322322 return (fig_eval )
323323}
324+
325+ # ' Make data comparing data as of nowcast date vs when evaluating -
326+ # ' All US version
327+ # '
328+ # ' @param seq_counts_as_of A plot showing sequence counts as of nowcast date
329+ # ' @param seq_counts_eval B plot showing sequence counts for evaluation
330+ # ' @param eval_freq C plot showing clade frequencies
331+ # ' @inheritParams get_plot_obs_clade_freq
332+ # '
333+ # ' @returns patchwork figure
334+ get_data_fig_all_us <- function (seq_counts_as_of ,
335+ seq_counts_eval ,
336+ eval_freq ,
337+ plot_name ,
338+ output_fp = file.path(
339+ " output" , " figs" ,
340+ " as_of_data_figs" , " final"
341+ )) {
342+ fig_layout <- "
343+ AAA
344+ BBB
345+ CCC"
346+
347+ fig_eval <- (seq_counts_as_of +
348+ ylab(" Sequence counts as of\n the nowcast date" )) +
349+ (seq_counts_eval + ylab(" Sequence counts\n for evaluation" )) +
350+ eval_freq +
351+ plot_layout(
352+ design = fig_layout ,
353+ axes = " collect" ,
354+ guides = " collect"
355+ ) +
356+ plot_annotation(
357+ tag_levels = " A" ,
358+ tag_suffix = " " ,
359+ tag_sep = " " ,
360+ theme = theme(
361+ legend.position = " top" ,
362+ legend.title = element_text(hjust = 0.5 ),
363+ legend.justification = " center" ,
364+ plot.tag = element_text(size = 20 )
365+ )
366+ )
367+
368+ dir_create(output_fp , recurse = TRUE )
369+ ggsave(file.path(output_fp , glue :: glue(" {plot_name}.png" )),
370+ plot = fig_eval ,
371+ width = 10 ,
372+ height = 10
373+ )
374+ return (fig_eval )
375+ }
376+
377+ # ' Make data comparing data as of nowcast date vs when evaluating -
378+ # ' Horizontal layout
379+ # '
380+ # ' @param seq_counts_as_of A plot showing sequence counts as of nowcast date
381+ # ' @param seq_counts_eval B plot showing sequence counts for evaluation
382+ # ' @param eval_freq C plot showing clade frequencies
383+ # ' @inheritParams get_plot_obs_clade_freq
384+ # '
385+ # ' @returns patchwork figure
386+ get_data_fig_all_us_horizontal <- function (seq_counts_as_of ,
387+ seq_counts_eval ,
388+ eval_freq ,
389+ plot_name ,
390+ output_fp = file.path(
391+ " output" , " figs" ,
392+ " as_of_data_figs" , " final"
393+ )) {
394+ fig_layout <- " ABC"
395+
396+ # Add x-axis text to all plots
397+ seq_counts_as_of <- seq_counts_as_of +
398+ theme(axis.text.x = element_text(angle = 45 , hjust = 1 , size = 10 ))
399+
400+ seq_counts_eval <- seq_counts_eval +
401+ theme(axis.text.x = element_text(angle = 45 , hjust = 1 , size = 10 ))
402+
403+ fig_eval <- (seq_counts_as_of +
404+ ylab(" Sequence counts as of\n the nowcast date" )) +
405+ (seq_counts_eval +
406+ ylab(" Sequence counts\n for evaluation" )) +
407+ eval_freq +
408+ plot_layout(
409+ design = fig_layout ,
410+ guides = " collect"
411+ ) +
412+ plot_annotation(
413+ tag_levels = " A" ,
414+ tag_suffix = " " ,
415+ tag_sep = " " ,
416+ theme = theme(
417+ legend.position = " top" ,
418+ legend.title = element_text(hjust = 0.5 ),
419+ legend.justification = " center" ,
420+ plot.tag = element_text(size = 20 )
421+ )
422+ )
423+
424+ dir_create(output_fp , recurse = TRUE )
425+ ggsave(file.path(output_fp , glue :: glue(" {plot_name}.png" )),
426+ plot = fig_eval ,
427+ width = 15 ,
428+ height = 5
429+ )
430+ return (fig_eval )
431+ }
432+
433+ # ' Make data comparing data as of nowcast date vs when evaluating -
434+ # ' Triangular layout
435+ # '
436+ # ' @param seq_counts_as_of A plot showing sequence counts as of nowcast date
437+ # ' @param seq_counts_eval B plot showing sequence counts for evaluation
438+ # ' @param eval_freq C plot showing clade frequencies
439+ # ' @inheritParams get_plot_obs_clade_freq
440+ # '
441+ # ' @returns patchwork figure
442+ get_data_fig_all_us_triangular <- function (seq_counts_as_of ,
443+ seq_counts_eval ,
444+ eval_freq ,
445+ plot_name ,
446+ output_fp = file.path(
447+ " output" , " figs" ,
448+ " as_of_data_figs" , " final"
449+ )) {
450+ # Inverted triangle: two plots on top, one wide plot on bottom
451+ fig_layout <- "
452+ AAABBB
453+ CCCCCC"
454+
455+ # Add x-axis text to top plots (they were set to remove it)
456+ seq_counts_as_of <- seq_counts_as_of +
457+ theme(axis.text.x = element_text(angle = 45 , hjust = 1 , size = 10 ))
458+
459+ seq_counts_eval <- seq_counts_eval +
460+ theme(axis.text.x = element_text(angle = 45 , hjust = 1 , size = 10 ))
461+
462+ fig_eval <- (seq_counts_as_of +
463+ ylab(" Sequence counts as of\n the nowcast date" )) +
464+ (seq_counts_eval + ylab(" Sequence counts\n for evaluation" )) +
465+ eval_freq +
466+ plot_layout(
467+ design = fig_layout ,
468+ guides = " collect"
469+ ) +
470+ plot_annotation(
471+ tag_levels = " A" ,
472+ tag_suffix = " " ,
473+ tag_sep = " " ,
474+ theme = theme(
475+ legend.position = " top" ,
476+ legend.title = element_text(hjust = 0.5 ),
477+ legend.justification = " center" ,
478+ plot.tag = element_text(size = 20 )
479+ )
480+ )
481+
482+ dir_create(output_fp , recurse = TRUE )
483+ ggsave(file.path(output_fp , glue :: glue(" {plot_name}.png" )),
484+ plot = fig_eval ,
485+ width = 12 ,
486+ height = 8
487+ )
488+ return (fig_eval )
489+ }
0 commit comments