Skip to content

Commit

Permalink
Merge pull request #97 from FredHutch/release-1.0.0
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
monicagerber authored Jan 10, 2022
2 parents 1807e44 + 7d60655 commit adcf124
Show file tree
Hide file tree
Showing 32 changed files with 1,031 additions and 383 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
^Meta$
CONDUCT.md
CONTRIBUTING.md
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
46 changes: 46 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]

name: R-CMD-check

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@v2

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

- uses: r-lib/actions/setup-r@v1
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@v1
with:
extra-packages: rcmdcheck

- uses: r-lib/actions/check-r-package@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.Rproj.user
doc
Meta
inst/doc
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: VISCtemplates
Title: Tools for writing reproducible reports at VISC
Version: 0.3.4
Version: 1.0.0
Authors@R:
person(given = "Jimmy",
family = "Fulp",
Expand All @@ -18,11 +18,13 @@ Description: The goal of VISCtemplates is to automate project setup provide a co
License: GPL-3 + file LICENSE
Depends: R (>= 3.0)
Imports:
fs,
bookdown,
here,
rmarkdown,
stringr,
usethis
usethis,
glue
Encoding: UTF-8
LazyData: true
URL: https://github.com/FredHutch/VISCtemplates
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export(set_kable_warnings)
export(set_pandoc_markup)
export(use_visc_docs)
export(use_visc_gitignore)
export(use_visc_methods)
export(use_visc_pr_template)
export(use_visc_readme)
export(use_visc_report)
export(visc_pdf_document)
export(visc_word_document)
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@

# VISCtemplates 1.0.0

The new release number is bumped to 1.0.0 because this version implements the structure needed for assay-specific templates.

* New feature: `use_visc_report()` creates a VISC report template with assay-specific R Markdown files.
* New vignette: a new vignette outlines how to set up a VISC analysis project (`vignette("create_a_visc_analysis_project")`).
* Changes to the PT report README to make it easier to use.
* Minor changes:
+ "*.zip" added to the .gitignore template
+ *.R template files created with `create_visc_project()` are saved to R/ in the analysis project template.
+ The study schema template is an R function.
+ New prompt with `create_visc_project()` asks about the project name.
+ Added \sloppy to .tex template to help with antigen name formatting.
* Minor edits to template language and documentation throughout.

# VISCtemplates 0.3.4

* Bug fix: updated `bibliography.bib` file to fix citation format for R Core Team citation.
Expand Down
40 changes: 39 additions & 1 deletion R/create_visc_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
#' @export
create_visc_project <- function(path){

challenge_directory(path)

# top level folder should follow VDCNNNAnalysis format
repo_name <- basename(path)
challenge_visc_name(repo_name)

# get "VDCNNN" if it exists
# this is a variable that is inserted into templates
Expand All @@ -20,7 +23,7 @@ create_visc_project <- function(path){
# create package
usethis::create_package(
path = path
) # add check for existing package
)

# must set active project otherwise it is <no active project>
usethis::proj_set(path = path)
Expand Down Expand Up @@ -48,6 +51,41 @@ create_visc_project <- function(path){
}


challenge_directory <- function(path) {

path <- fs::path_expand(path)

dir_exists <- dir.exists(path)

if (dir_exists) {

continue <- usethis::ui_yeah("
The directory {path} already exists.
Would you like to continue?")

if (!continue) {
usethis::ui_stop("Stopping `create_visc_project()`")
} else if (continue) {
usethis::ui_warn("
Creating new VISC project in {path}, which already exists.
Be sure to check the directory for unexpected files.")
}
}
}


challenge_visc_name <- function(repo_name) {

continue <- usethis::ui_yeah("
Creating a new VISC project called {repo_name}.
At VISC, we use a naming convention for analysis projects, VDCnnnAnalysis,
where 'VDC' is the CAVD PI name, and 'nnn' is the CAVD project number.
Would you like to continue?")

if (!continue) {
usethis::ui_stop("Stopping `create_visc_project()`")
}
}

# Set up project with RStudio GUI ----------------------------------------------

Expand Down
107 changes: 103 additions & 4 deletions R/template.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ use_project_objectives <- function(study_name) {

use_group_colors <- function(study_name) {
usethis::use_template(
template = "group-colors.R",
save_as = "docs/group-colors.R",
template = "group_colors.R",
save_as = "R/group_colors.R",
data = list(study_name = study_name),
package = "VISCtemplates"
)
}

use_study_schema <- function(study_name) {
usethis::use_template(
template = "study-schema.R",
save_as = "docs/study-schema.R",
template = "study_schema.R",
save_as = "R/study_schema.R",
data = list(study_name = study_name),
package = "VISCtemplates"
)
Expand All @@ -99,6 +99,105 @@ use_bib <- function(study_name) {
)
}

#' Use a VISC Report Template
#'
#' @param report_name name of the file (character)
#' @param path path of the file within the active project
#' @param report_type "empty", "generic", or "bama"
#'
#' @export
#'
#' @examples
#' \dontrun{
#' use_visc_report(report_name = "BAMA-PT-Report", path = "bama", report_type = "bama")
#' }
use_visc_report <- function(report_name = "PT-Report",
path = ".",
report_type = c("empty", "generic", "bama")) {

stopifnot(report_type %in% c("empty", "generic", "bama"))

if (report_type == "empty") {
rmarkdown::draft(
file = file.path(path, report_name),
template = "visc_empty",
package = "VISCtemplates",
create_dir = TRUE,
edit = FALSE
)
usethis::ui_done(
glue::glue("Creating an empty VISC report at '{{file.path(path, report_name)}}'")
)

} else {
rmarkdown::draft(
file = file.path(path, report_name),
template = "visc_report",
package = "VISCtemplates",
create_dir = TRUE,
edit = FALSE
)
usethis::ui_done(
glue::glue("Creating a VISC report at '{{file.path(path, report_name)}}'")
)
use_visc_methods(path = file.path(path, report_name), assay = report_type)
}


}

#' Use template files for methods sections in PT reports
#'
#' Creates a "methods" directory that contains 3 "child" R Markdown documents
#' used in PT reports: statistical-methods.Rmd, lab-methods.Rmd,
#' and biological-endpoints.Rmd
#'
#' @param assay "bama" or "generic"
#' @param path path within the active project
#'
#' @export
#'
#' @examples
#' \dontrun{
#' use_visc_methods(path = "bama/BAMA-PT-Report", assay = "bama")
#' }
use_visc_methods <- function(path = ".", assay = c("generic", "bama")) {

pkg_ver <- utils::packageVersion("VISCtemplates")

usethis::use_directory(file.path(path, "methods"))

usethis::use_template(
template = file.path(
paste0("methods-", assay),
paste0(assay, "-statistical-methods.Rmd")
),
data = list(pkg_ver = pkg_ver),
save_as = file.path(path, "methods", "statistical-methods.Rmd"),
package = "VISCtemplates"
)

usethis::use_template(
template = file.path(
paste0("methods-", assay),
paste0(assay, "-lab-methods.Rmd")
),
data = list(pkg_ver = pkg_ver),
save_as = file.path(path, "methods", "lab-methods.Rmd"),
package = "VISCtemplates"
)

usethis::use_template(
template = file.path(
paste0("methods-", assay),
paste0(assay, "-biological-endpoints.Rmd")
),
data = list(pkg_ver = pkg_ver),
save_as = file.path(path, "methods", "biological-endpoints.Rmd"),
package = "VISCtemplates"
)

}

#' Convert to a VISC Report PDF/LaTeX document
#'
Expand Down
3 changes: 2 additions & 1 deletion R/use_visc_gitignore.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ use_visc_gitignore <- function(directory = ".") {
# files from Latex
"*.log",
"**/figure-latex/*.pdf",
"**/figure-docx/*.pdf"
"**/figure-docx/*.pdf",
"*.zip"
),
directory = directory
)
Expand Down
Loading

0 comments on commit adcf124

Please sign in to comment.