Skip to content

Commit

Permalink
Merge pull request #19 from getwilds/dev
Browse files Browse the repository at this point in the history
Packaging the App (Closes #6)
  • Loading branch information
seankross authored Jan 17, 2025
2 parents 037cb85 + dff7e34 commit e97569f
Show file tree
Hide file tree
Showing 48 changed files with 2,922 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
^renv$
^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")'
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
.RData
.Ruserdata
.DS_Store
renv/library/
renv/staging/
renv/cache/
inst/doc
.Rprofile
.Renviron
53 changes: 47 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
Package: oncarto
Type: Package
Title: What the Package Does (Title Case)
Title: Oncology Cartographer
Version: 0.1.0
Author: Who wrote it
Maintainer: The package maintainer <[email protected]>
Description: More about what it does (maybe more than one line)
Use four spaces when indenting paragraphs within the Description.
License: What license is it under?
Authors@R:
c(person(given = "Vivek",
family = "Sriram",
email = "[email protected]",
role = c("aut"),
comment = c(ORCID = "0000-0003-3759-2911")),
person(given = "Sean",
family = "Kross",
email = "[email protected]",
role = c("ctb", "cre"),
comment = c(ORCID = "0000-0001-5215-0316")),
person(given = "Monica",
family = "Gerber",
email = "[email protected]",
role = c("ctb"),
comment = c(ORCID = "0000-0001-9878-9166")),
person(given = "Scott",
family = "Chamberlain",
email = "[email protected]",
role = c("ctb"),
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 + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Suggests:
knitr,
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"))
18 changes: 0 additions & 18 deletions R/hello.R

This file was deleted.

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

0 comments on commit e97569f

Please sign in to comment.