Skip to content

Commit

Permalink
v1.0.0 - MRA manuscript release
Browse files Browse the repository at this point in the history
  • Loading branch information
arendsee committed Nov 18, 2021
1 parent 607ce3d commit 6614f67
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 53 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: octoflushow
Title: A Shiny app for the swine surveillence data
Version: 0.0.0.9000
Version: 1.0.0
Authors@R: c(
person(given = "Zebulun",
family = "Arendsee",
Expand Down
5 changes: 3 additions & 2 deletions R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ barchart_bytime <- function(df, value="n", variable="H1", palette=octoflushow::g
tunit="month",
fed=FALSE,
xfontsize=10,
yfontsize=10) {
yfontsize=10,
ytitle="Number of Swine Isolates") {

# local format of federal quarter
format_Q <- function(ddf){
Expand All @@ -439,7 +440,7 @@ barchart_bytime <- function(df, value="n", variable="H1", palette=octoflushow::g
p <- ggplot2::ggplot(data = df, ggplot2::aes_string(x = "Date", y = value, fill = variable)) +
ggplot2::geom_bar(stat = "identity", position = bartype) +
ggplot2::scale_fill_manual(values = palette) +
ggplot2::labs(y="Number of Swine Isolates", x="", title=title) +
ggplot2::labs(y=ytitle, x="", title=title) +
ggplot2::theme_bw() +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90, size = 10, vjust = 0.5),
axis.text.y = ggplot2::element_text(size = 10),
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,13 @@ Check the website address see if site is working.
```

Click through the [documentation](https://httpd.apache.org/docs/2.4/mod/directives.html) for what the tags mean in `000-default.conf` so you can configure it properly.

# Debugging

If downloading plots returns an HTML file containing the error messages
"polygon edge not found", then you may need to update the font database. In the
R shell, run the following command:

```R
extrafont::font_import()
```
79 changes: 30 additions & 49 deletions inst/app/server.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
library(shiny)

require(magrittr)

d <- octoflushow::load_current()


# update data in various ways prior to plotting
plot_munge <- function(d, collapse_n2_clade, collapse_gamma_clade, collapse_c4_clade, global_ha="us"){
if(collapse_n2_clade){
Expand Down Expand Up @@ -39,15 +39,15 @@ server <- function(input, output, session) {
})

output$time_plot <- renderPlot({
print(basic_plot_rct())
print(time_plot_rct())
})

output$hana_time_plot <- renderPlot({
print(hana_basic_plot_rct())
print(hana_time_plot_rct())
})

output$triple_time_plot <- renderPlot({
print(triple_basic_plot_rct())
print(triple_time_plot_rct())
})

output$state_plot <- renderPlot({
Expand All @@ -62,18 +62,18 @@ server <- function(input, output, session) {
print(constellation_plot_rct())
})

basic_plot_rct <- reactive({
time_plot_rct <- reactive({
plot_munge(d_rct(), input$collapse_n2_bar, input$collapse_gamma_bar, input$collapse_c4_bar, input$global_bar) %>%
octoflushow::plot_basic(floorDateBy=input$floorDateBy, segment=input$segmentChoiceBar)
})

hana_basic_plot_rct <- reactive({
plot_munge(d_rct(), input$collapse_n2_hana_bar, input$collapse_gamma_hana_bar, input$collapse_c4_hana_bar) %>%
hana_time_plot_rct <- reactive({
plot_munge(d_rct(), input$collapse_n2_hana_bar, input$collapse_gamma_hana_bar, input$collapse_c4_hana_bar, input$global_hana_bar) %>%
octoflushow::hana_barplots(floorDateBy=input$floorDateByHanaBar, global=input$global_hana_bar == "global")
})

triple_basic_plot_rct <- reactive({
plot_munge(d_rct(), input$collapse_n2_triple_bar, input$collapse_gamma_triple_bar, input$collapse_c4_triple_bar) %>%
triple_time_plot_rct <- reactive({
plot_munge(d_rct(), input$collapse_n2_triple_bar, input$collapse_gamma_triple_bar, input$collapse_c4_triple_bar, input$global_triple_bar) %>%
octoflushow::triple_barplots(floorDateBy=input$floorDateByTripleBar, global=input$global_triple_bar == "global")
})

Expand All @@ -92,47 +92,28 @@ server <- function(input, output, session) {
octoflushow::plot_constellation()
})

output$download_time_plot <- downloadHandler(
filename = function(){"swine-survey-time_plot.pdf"},
content = function(file){
ggplot2::ggsave(file, basic_plot_rct(), device="pdf", width = input$shiny_width_time_plot/72, height = input$shiny_height_time_plot/72)
}
)

output$download_hana_time_plot <- downloadHandler(
filename = function(){"swine-survey-hana_time_plot.pdf"},
content = function(file){
ggplot2::ggsave(file, hana_basic_plot_rct(), device="pdf", width = input$shiny_width_time_plot/72, height = input$shiny_height_time_plot/72)
}
)
make_downloader <- function(function_name){
reactive_function = get(glue::glue("{function_name}_rct"))
width_field = glue::glue("shiny_width_{function_name}")
height_field = glue::glue("shiny_height_{function_name}")
downloadHandler(
filename = function(){glue::glue("swine-survey-{function_name}.pdf")},
content = function(file){
ggplot2::ggsave(file,
reactive_function(),
device="pdf",
width = input[[width_field]]/72,
height = input[[height_field]]/72)
}
)
}

output$download_triple_time_plot <- downloadHandler(
filename = function(){"swine-survey-triple_time_plot.pdf"},
content = function(file){
ggplot2::ggsave(file, triple_basic_plot_rct(), device="pdf", width = input$shiny_width_time_plot/72, height = input$shiny_height_time_plot/72)
}
)

output$download_state_plot <- downloadHandler(
filename = function(){"swine-survey-state_plot.pdf"},
content = function(file){
ggplot2::ggsave(file, state_plot_rct(), device="pdf", width = input$shiny_width_state_plot/72, height = input$shiny_height_state_plot/72)
}
)

output$download_heatmap_plot <- downloadHandler(
filename = function(){"swine-survey-heatmap_plot.pdf"},
content = function(file){
ggplot2::ggsave(file, heatmap_plot_rct(), device="pdf", width = input$shiny_width_heatmap_plot/72, height = input$shiny_height_heatmap_plot/72)
}
)

output$download_constellation_plot <- downloadHandler(
filename = function(){"swine-survey-constellation_plot.pdf"},
content = function(file){
ggplot2::ggsave(file, constellation_plot_rct(), device="pdf", width = input$shiny_width_constellation_plot/72, height = input$shiny_height_constellation_plot/72)
}
)
output$download_time_plot <- make_downloader("time_plot")
output$download_hana_time_plot <- make_downloader("hana_time_plot")
output$download_triple_time_plot <- make_downloader("triple_time_plot")
output$download_state_plot <- make_downloader("state_plot")
output$download_heatmap_plot <- make_downloader("heatmap_plot")
output$download_constellation_plot <- make_downloader("constellation_plot")

output$downloadExcel <- downloadHandler(
filename = 'swine-surveillance-data.xlsx',
Expand Down
10 changes: 10 additions & 0 deletions inst/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ colors:
pandemic: "#01665e"
1A.3.3.2: "#01665e"
gamma2-beta-like: "#8c000a"
LAIV: "#8c000a"
1A.2-3-like: "#8c000a"
delta1: "#bf812d"
1B.2.2: "#bf812d"
Expand All @@ -33,6 +34,7 @@ colors:
3.2010.2: "#996633"
other-human: "#F90005"
I: "#542788"
LAIV: "#542788"
3.1990.1: "#542788"
II: "#d73027"
3.1990.2 : "#d73027"
Expand Down Expand Up @@ -73,6 +75,7 @@ colors:
Pandemic: "#F03B20"
Human_seasonal: "#BD2D2B"
MN99: "#91BFDB"
LAIV: "#91BFDB"
N6: "#FF0000"
# No_data: "#EDF881"
N2:
Expand Down Expand Up @@ -102,12 +105,14 @@ colors:
Human-like: "#969696"
Human_N2: "#969696"
TX98: "#FF9F02"
LAIV: "#FF9F02"
unknown: "#800000"
# No_data: "#EDF8B1"
PB2:
PDM: "#762A83"
TRIG: "#C2A5CF"
TX98: "#C7EAE5"
LAIV: "#C7EAE5"
Human-seasonal: "#969696"
Human-seasonal_H3: "#969696"
classicalSwine: "#FF0000"
Expand All @@ -116,6 +121,7 @@ colors:
PDM: "#762A83"
TRIG: "#C2A5CF"
TX98: "#C7EAE5"
LAIV: "#C7EAE5"
Human-seasonal: "#969696"
Human-seasonal_H3: "#969696"
classicalSwine: "#FF0000"
Expand All @@ -124,6 +130,7 @@ colors:
PDM: "#762A83"
TRIG: "#C2A5CF"
TX98: "#C7EAE5"
LAIV: "#C7EAE5"
Human-seasonal: "#969696"
Human-seasonal_H3: "#969696"
classicalSwine: "###FF0000"
Expand All @@ -132,6 +139,7 @@ colors:
PDM: "#762A83"
TRIG: "#C2A5CF"
TX98: "#C7EAE5"
LAIV: "#C7EAE5"
Human-seasonal: "#969696"
Human-seasonal_H3: "#969696"
classicalSwine: "#FF0000"
Expand All @@ -140,6 +148,7 @@ colors:
PDM: "#762A83"
TRIG: "#C2A5CF"
TX98: "#C7EAE5"
LAIV: "#C7EAE5"
Human-seasonal: "#969696"
Human-seasonal_H3: "#969696"
classicalSwine: "#FF0000"
Expand All @@ -148,6 +157,7 @@ colors:
PDM: "#762A83"
TRIG: "#C2A5CF"
TX98: "#C7EAE5"
LAIV: "#C7EAE5"
Human-seasonal: "#969696"
Human-seasonal_H3: "#969696"
classicalSwine: "#FF0000"
Expand Down
3 changes: 2 additions & 1 deletion man/barchart_bytime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6614f67

Please sign in to comment.