Skip to content
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

Package app #8

Merged
merged 57 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b95d0bc
Restructure organization and debug filter calls
vsriram24 Sep 20, 2024
0a1a2d4
Package oncarto
vsriram24 Sep 20, 2024
7e36c9f
Add pkg dependencies to DESCRIPTION
vsriram24 Sep 22, 2024
c3a0b88
Update package versions to handle new cancerprof API updates
vsriram24 Sep 30, 2024
96955bb
Resolve merge conflicts btwn dev and package-app
vsriram24 Nov 14, 2024
39bfcd5
Drop renv
vsriram24 Nov 18, 2024
ea52032
Beginning to functionalize UI 11/18
vsriram24 Nov 19, 2024
842a1ca
Resolve basic app running issues
vsriram24 Nov 20, 2024
bf6d703
Add remaining selectInputs for incidence UI
vsriram24 Nov 20, 2024
a642859
Add UI for incidence output
vsriram24 Nov 20, 2024
252aad9
Add UI for contact info in incidence
vsriram24 Nov 20, 2024
ad3a09e
moving files around to make your life easier
seankross Nov 20, 2024
c24bee2
Add UI for background tab
vsriram24 Nov 20, 2024
34ee49f
Merge pull request #15 from getwilds/package-app-sk
vsriram24 Nov 20, 2024
d81977d
Correct info for background UI
vsriram24 Nov 20, 2024
8a5b324
Include NS for UI
vsriram24 Nov 20, 2024
61b4aa6
Server logic for background tab + background data
vsriram24 Nov 20, 2024
3f87fea
Update server logic for contact info in incidence tab
vsriram24 Nov 20, 2024
ca37500
Ingest data for incidence on server
vsriram24 Nov 20, 2024
f14228e
Fix ref to get_data fn
vsriram24 Nov 20, 2024
6c6e812
Filter input data and functionalize contact info
vsriram24 Nov 21, 2024
49f7658
Update data filtering to dplyr
vsriram24 Nov 22, 2024
da03dc8
Debugging map message functionalization
vsriram24 Nov 22, 2024
7c83f85
all of the co working stuff we talked about
seankross Nov 22, 2024
a65ce91
Merge pull request #16 from getwilds/nov-22-coworking
vsriram24 Nov 25, 2024
5cc39fc
Move logic for contact info from server to UI
vsriram24 Nov 25, 2024
52b6b47
drop extraneous server logic for bground
vsriram24 Nov 25, 2024
f80e01f
Add param statements for data_table_name and state_abbr in run-app
vsriram24 Nov 25, 2024
739d490
Get choropleth map and message working without functionalization
vsriram24 Nov 26, 2024
cc113f5
Functionalize palette
vsriram24 Nov 26, 2024
5800d0f
Functionalize making leaflet map
vsriram24 Nov 26, 2024
90481b7
Clean up parameter calls between run-app and server
vsriram24 Nov 26, 2024
89edd5f
Fix filename for make-leaflet
vsriram24 Nov 26, 2024
2c43264
Remove extraneous scripts and clean up make-leaflet
vsriram24 Nov 26, 2024
1ea6318
Resolve NOTES from running check()
vsriram24 Nov 26, 2024
8f927d1
Include packages for function calls
vsriram24 Nov 26, 2024
3d4a330
Package addt for NAMESPACE
vsriram24 Nov 26, 2024
c7f8a5e
Include more package defs for fns
vsriram24 Nov 26, 2024
1bbf2e3
Resolve addPolygons issue in leaflet
vsriram24 Nov 26, 2024
9139294
Clean up server-county-incidence
vsriram24 Nov 26, 2024
2ef4a6a
fixed logo and added testing
seankross Nov 26, 2024
257f05e
Merge pull request #17 from getwilds/package-app-logo-fix-and-testing
vsriram24 Nov 27, 2024
cd8fcc8
Plan out tests and create sample data
vsriram24 Dec 2, 2024
059a2ef
Further test dev and addResourcePath pkg
vsriram24 Dec 3, 2024
dcedc49
Change map_message to NULL for easier testing
vsriram24 Dec 3, 2024
fdca1b3
Baseline test format with sample data
vsriram24 Dec 3, 2024
705e012
Failed test. Trying to debug
vsriram24 Dec 3, 2024
73b6aeb
Turn get_data into a callback
vsriram24 Dec 4, 2024
94241f4
Disentangle incidence outputs
vsriram24 Dec 4, 2024
8c3f9db
Working tests (half of them)
vsriram24 Dec 4, 2024
5a61a45
We're not gonna bother about shinytest2
vsriram24 Dec 4, 2024
4f4d5c0
Reorg inst/ folder
vsriram24 Dec 5, 2024
480c25b
Introduce contact_info md as an argument for ui-county-incidence
vsriram24 Dec 5, 2024
d2435a4
Cleanup and check
vsriram24 Dec 5, 2024
b8c481e
started cleanup - blocked by terra
seankross Dec 6, 2024
be37e15
looking better
seankross Dec 8, 2024
14a08e1
Merge pull request #18 from getwilds/package-app-cleanup
vsriram24 Jan 15, 2025
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
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
^data-raw$
^LICENSE\.md$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
51 changes: 51 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ renv/library/
renv/staging/
renv/cache/
inst/doc
.Rprofile
.Renviron
36 changes: 25 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,45 @@ Authors@R:
email = "[email protected]",
role = c("aut"),
comment = c(ORCID = "0000-0003-3759-2911")),
person(given = "Scott",
family = "Chamberlain",
email = "sachamber@fredhutch.org",
person(given = "Sean",
family = "Kross",
email = "skross@fredhutch.org",
role = c("ctb", "cre"),
comment = c(ORCID = "0000-0003-1444-9135")),
comment = c(ORCID = "0000-0001-5215-0316")),
person(given = "Monica",
family = "Gerber",
email = "[email protected]",
role = "ctb",
role = c("ctb"),
comment = c(ORCID = "0000-0001-9878-9166")),
person(given = "Sean",
family = "Kross",
email = "skross@fredhutch.org",
person(given = "Scott",
family = "Chamberlain",
email = "sachamber@fredhutch.org",
role = c("ctb"),
comment = c(ORCID = "0000-0001-5215-0316")))
comment = c(ORCID = "0000-0003-1444-9135"))
)
Description: Oncarto (Oncology Cartographer) is an R package / Shiny dashboard
developed by the Fred Hutch Data Science Lab (DaSL) for the
automated integration and visualization of publicly available cancer
incidence data for the Fred Hutch Cancer Center catchment area.
License: MIT
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Suggests:
knitr,
rmarkdown
rmarkdown,
testthat (>= 3.0.0)
VignetteBuilder: knitr
Imports:
dplyr,
htmltools,
leaflet,
sf,
shiny,
shinycssloaders,
shinydashboard,
tigris
Depends:
R (>= 2.10)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: oncarto authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2024 oncarto authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 41 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand

export(example_callback)
export(oncarto_file)
export(run_app)
importFrom(dplyr,filter)
importFrom(dplyr,left_join)
importFrom(htmltools,HTML)
importFrom(htmltools,a)
importFrom(htmltools,tags)
importFrom(leaflet,addLegend)
importFrom(leaflet,addPolygons)
importFrom(leaflet,addTiles)
importFrom(leaflet,colorNumeric)
importFrom(leaflet,highlightOptions)
importFrom(leaflet,labelOptions)
importFrom(leaflet,leaflet)
importFrom(leaflet,leafletOutput)
importFrom(sf,st_transform)
importFrom(shiny,NS)
importFrom(shiny,addResourcePath)
importFrom(shiny,column)
importFrom(shiny,fluidRow)
importFrom(shiny,includeMarkdown)
importFrom(shiny,moduleServer)
importFrom(shiny,renderUI)
importFrom(shiny,selectInput)
importFrom(shiny,shinyApp)
importFrom(shiny,uiOutput)
importFrom(shinycssloaders,withSpinner)
importFrom(shinydashboard,box)
importFrom(shinydashboard,dashboardBody)
importFrom(shinydashboard,dashboardHeader)
importFrom(shinydashboard,dashboardPage)
importFrom(shinydashboard,dashboardSidebar)
importFrom(shinydashboard,menuItem)
importFrom(shinydashboard,sidebarMenu)
importFrom(shinydashboard,tabItem)
importFrom(shinydashboard,tabItems)
importFrom(tigris,counties)
importFrom(utils,read.table)
22 changes: 22 additions & 0 deletions R/example-callback.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#' A function that provides an example dataframe for testing.
#' @param key A string used internally (in a specific shiny server module
#' implementation) to indicate which data to return.
#' @export
#' @importFrom utils read.table
#' @examples
#' example_callback("county-incidence")
#'
example_callback <- function(key) {
stopifnot(key %in% c("county-incidence", "contact-info"))

if (key == "county-incidence") {
utils::read.table(
header = TRUE,
system.file(file.path("test", "example-incidence.tsv"), package = "oncarto"),
sep = "\t"
)
} else if (key == "contact-info") {
oncarto_file("fh-contact-info.md")
}
}

14 changes: 14 additions & 0 deletions R/get-county-boundaries.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Get the right county boundaries for the desired choropleth visualization
#' @importFrom tigris counties
#' @importFrom sf st_transform
#'
get_county_boundaries <- function(state_abbr, county_col_name) {
# Get county boundaries for the choropleth visualization using the tigris package
out <- sf::st_transform(
tigris::counties(state = state_abbr, class = "sf"),
crs = 4326
)

out[[county_col_name]] <- out[['NAMELSAD']]
out
}
1 change: 1 addition & 0 deletions R/global.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
utils::globalVariables(c("NAMELSAD", "cancer_type", "race", "sex", "age", "stage", "year"))
41 changes: 41 additions & 0 deletions R/make-leaflet.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Make the choropleth map
#' @importFrom leaflet leaflet addTiles addPolygons addLegend labelOptions
#' highlightOptions
#'
make_leaflet <- function(in_data, in_palette, incidence_col_name,
county_col_name, legend_title) {

leaflet::leaflet(data = in_data) |>
leaflet::addTiles() |>
leaflet::addPolygons(
fillColor = ~in_palette(
in_data[[incidence_col_name]]
),
weight = 1,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlightOptions = leaflet::highlightOptions(
weight = 3,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE
),
label = ~paste(in_data[[county_col_name]], ": ",
in_data[[incidence_col_name]]),
labelOptions = leaflet::labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto"
)
) |>
leaflet::addLegend(
pal = in_palette,
values = ~in_data[[incidence_col_name]],
opacity = 0.7,
title = legend_title,
position = "topright"
)
}
12 changes: 12 additions & 0 deletions R/make-palette.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generate palette for choropleth map
#' @importFrom leaflet colorNumeric
#'
make_palette <- function(in_data, col_name, lower_color, upper_color,
na_color) {

leaflet::colorNumeric(
c(lower_color, upper_color),
domain = in_data[[col_name]],
na.color = na_color
)
}
6 changes: 6 additions & 0 deletions R/oncarto-body.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This function fills in the body of the shiny dashboard
#' @importFrom shinydashboard dashboardBody
#'
oncarto_body <- function() {

}
23 changes: 23 additions & 0 deletions R/oncarto-file.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#' Get the paths to files installed with oncarto
#'
#' This function allows you to quickly access files that are installed with
#' oncarto.
#'
#' @param path The name of the file. If no argument is provided then
#' all of the example files will be listed.
#'
#' @return A vector of file paths
#' @export
#' @examples
#' oncarto_file()
#'
oncarto_file <- function(path = NULL){
if(is.null(path)) {
list.files(
system.file(c("app"), package = "oncarto"),
full.names = TRUE)
} else {
system.file(c("app"), path, package = "oncarto",
mustWork = TRUE)
}
}
14 changes: 14 additions & 0 deletions R/oncarto-header.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This function fills in the header of the shiny dashboard
#' @importFrom shinydashboard dashboardHeader
#' @importFrom htmltools tags
#'
oncarto_header <- function(title, logo_src, logo_href, logo_width, logo_height) {
shinydashboard::dashboardHeader(
title = htmltools::tags$a(
href = logo_href,
tags$img(
src = logo_src, height = logo_height, width = logo_width
)
)
)
}
19 changes: 19 additions & 0 deletions R/oncarto-sidebar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This function fills in the sidebar of the shiny dashboard
#' @importFrom shinydashboard dashboardSidebar sidebarMenu menuItem
#'
oncarto_sidebar <- function() {
shinydashboard::dashboardSidebar(
shinydashboard::sidebarMenu(
# Multiple tabs, each correspond to a different type of map / info
shinydashboard::menuItem(
"Cancer Incidence by County",
tabName = "county-incidence"
),

shinydashboard::menuItem(
"Background",
tabName = "background"
)
)
)
}
Loading
Loading