diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..f62a415 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,16 @@ +.*\.Rproj$ +^\.Rproj\.user$ +^README.Rmd +^\.github$ +^doc$ +^Meta$ +^codecov\.yml$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ +Dockerfile +^LICENSE\.md$ + +node_modules$ +package-lock\.json$ +package\.json$ diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..72148b0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,52 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +## 1. Bug description + +(A clear and concise description of what the bug is.) + +### Expected behaviour + +(A clear and concise description of what you expected to happen.) + + +## 2. Reproducible example + +### Code + +(Please add the steps to reproduce the bug here. See [here](https://www.r-bloggers.com/2020/10/how-to-make-a-reprex/) for an intro to making a reproducible example (i.e. reprex) and why they're important! __This will help us to help you much faster.__) + +```R +# Paste example here + +``` + +### Console output + +``` +# Paste console output here (e.g. from R/python/command line) + +``` + +### Data + +(If possible, upload a small sample of your data so that we can reproduce the bug on our end. If that's not possible, please at least include a screenshot of your data and other relevant details.) + + +## 3. Session info + +(Add output of the R function `utils::sessionInfo()` below. This helps us assess version/OS conflicts which could be causing bugs.) + +
+ +``` +# Paste utils::sessionInfo() output + +``` +
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/rworkflows.yml b/.github/workflows/rworkflows.yml new file mode 100644 index 0000000..9b40bf2 --- /dev/null +++ b/.github/workflows/rworkflows.yml @@ -0,0 +1,58 @@ +name: rworkflows +'on': + push: + branches: + - master + - main + - devel + - RELEASE_** + pull_request: + branches: + - master + - main + - devel + - RELEASE_** +jobs: + rworkflows: + permissions: + contents: write + packages: write + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + container: ${{ matrix.config.cont }} + strategy: + fail-fast: ${{ false }} + matrix: + config: + - os: ubuntu-latest + bioc: devel + r: auto + cont: ghcr.io/bioconductor/bioconductor_docker:devel + rspm: https://packagemanager.rstudio.com/cran/__linux__/latest/release + - os: macOS-latest + bioc: release + r: auto + cont: ~ + rspm: ~ + - os: windows-latest + bioc: release + r: auto + cont: ~ + rspm: ~ + steps: + - uses: neurogenomics/rworkflows@master + with: + run_bioccheck: ${{ false }} + run_rcmdcheck: ${{ true }} + as_cran: ${{ true }} + run_vignettes: ${{ true }} + has_testthat: ${{ true }} + run_covr: ${{ true }} + run_pkgdown: ${{ true }} + has_runit: ${{ false }} + has_latex: ${{ false }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run_docker: ${{ false }} + DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} + runner_os: ${{ runner.os }} + cache_version: cache-v1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3ab2ec7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# R project files +*.Rproj +.Rproj.user +.Ruserdata +# History files +.Rhistory +.Rapp.history +# Session Data files +.RData +# User-specific files +.Ruserdata +# .DS_Store +# find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch +.DS_Store +./.DS_Store +./**/.DS_Store +./**/**/.DS_Store +./**/**/**/.DS_Store +./**/**/**/**/.DS_Store +./**/**/**/**/**/.DS_Store +./**/**/**/**/**/**/.DS_Store +# Example code in package build process +*-Ex.R +# Output files from R CMD build +/*.tar.gz +# Output files from R CMD check +/*.Rcheck/ +# RStudio files +.Rproj.user/ +# produced vignettes +vignettes/*.html +vignettes/*.pdf +vignettes/*.R +# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 +.httr-oauth +# knitr and R markdown default cache directories +*_cache/ +/cache/ +# Temporary files created by R markdown +*.utf8.md +*.knit.md +# R Environment Variables +.Renviron \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..08a5676 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,45 @@ +Package: echoverseTemplate +Type: Package +Title: echoverse module: echoversePackageTitle +Version: 0.99.0 +Authors@R: + c(person(given = "Brian", + family = "Schilder", + role = c("aut","cre"), + email = "brian_schilder@alumni.brown.edu", + comment = c(ORCID = "0000-0001-5949-2191")), + person(given = "Jack", + family = "Humphrey", + role = c("aut"), + email = "Jack.Humphrey@mssm.edu", + comment = c(ORCID = "0000-0002-6274-6620")), + person(given = "Towfique", + family = "Raj", + role = c("aut"), + email = "towfique.raj@mssm.edu", + comment = c(ORCID = "0000-0002-9355-5704")) + ) +Description: echoverse module: echoversePackageDescription. +URL: https://github.com/RajLabMSSM/echoverseTemplate +BugReports: https://github.com/RajLabMSSM/echoverseTemplate/issues +Encoding: UTF-8 +Depends: R (>= 4.1) +biocViews: + Software, Genetics, FunctionalGenomics, SystemsBiology +Imports: +Suggests: + rworkflows, + markdown, + rmarkdown, + remotes, + knitr, + BiocStyle, + covr, + testthat (>= 3.0.0), + utils, + rlang, + methods +RoxygenNote: 7.2.3 +VignetteBuilder: knitr +License: GPL-3 +Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..6ae9268 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,2 @@ +# Generated by roxygen2: do not edit by hand + diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..2aaa0b5 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# echoverseTemplate 0.99.0 + +* Added a `NEWS.md` file to track changes to the package. diff --git a/R/message_parallel.r b/R/message_parallel.r new file mode 100644 index 0000000..929e6d4 --- /dev/null +++ b/R/message_parallel.r @@ -0,0 +1,8 @@ +#' Message parallel +#' +#' Send messages to console even from within parallel processes +#' @return Null +#' @keywords internal +message_parallel <- function(...) { + system(sprintf('echo "%s"', paste0(..., collapse = ""))) +} diff --git a/R/messager.R b/R/messager.R new file mode 100644 index 0000000..f154b44 --- /dev/null +++ b/R/messager.R @@ -0,0 +1,22 @@ +#' Print messages +#' +#' Conditionally print messages. +#' Allows developers to easily control verbosity of functions, +#' and meet Bioconductor requirements that dictate the message +#' must first be stored to a variable before passing to \link[base]{message}. +#' +#' +#' @param v Whether to print messages or not. +#' @param parallel Whether to enable message print when wrapped +#' in parallelised functions. +#' +#' @return Null +#' @keywords internal +messager <- function(..., v = TRUE, parallel = FALSE) { + if(parallel){ + if(v) try({message_parallel(...)}) + } else { + msg <- paste(...) + if (v) try({message(msg)}) + } +} diff --git a/R/stopper.R b/R/stopper.R new file mode 100644 index 0000000..78cdf7c --- /dev/null +++ b/R/stopper.R @@ -0,0 +1,18 @@ +#' Stop messages +#' +#' Conditionally print stop messages. +#' Allows developers to easily control verbosity of functions, +#' and meet Bioconductor requirements that dictate the stop message +#' must first be stored to a variable before passing to \link[base]{stop}. +#' @param v Whether to print messages or not. +#' +#' @return Null +#' @keywords internal +stopper <- function(..., v = TRUE) { + msg <- paste(...) + if (v) { + stop(msg) + } else { + stop() + } +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..698240e --- /dev/null +++ b/README.Rmd @@ -0,0 +1,45 @@ +--- +title: "" +author: "`r rworkflows::use_badges(add_doi = '10.1093/bioinformatics/btab658')`" +output: + github_document +--- + +```{r, echo=FALSE, include=FALSE} +pkg <- read.dcf("DESCRIPTION", fields = "Package")[1] +description <- read.dcf("DESCRIPTION", fields = "Description")[1] |> + gsub(pattern="\n", replacement=" ") +``` + +## ``r pkg``: `r gsub("echoverse module: ","", description)` + +This R package is part of the *echoverse* suite that supports +[`echolocatoR`](https://github.com/RajLabMSSM/echolocatoR): +an automated genomic fine-mapping pipeline. + +If you use ``r pkg``, please cite: + +> `r citation(pkg)$textVersion` + +## Installation + +```R +if(!require("remotes")) install.packages("remotes") + +remotes::install_github("RajLabMSSM/`r pkg`") +library(`r pkg`) +``` +## Documentation + +### [Website](https://rajlabmssm.github.io/`r pkg`) +### [Get started](https://rajlabmssm.github.io/`r pkg`/articles/`r pkg`) + +
+ +## Contact + +Brian +M. Schilder, Bioinformatician II +Raj Lab +Department +of Neuroscience, Icahn School of Medicine at Mount Sinai diff --git a/README.md b/README.md new file mode 100644 index 0000000..5decfa5 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +
+[![License: +GPL-3](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://cran.r-project.org/web/licenses/GPL-3) +[![](https://img.shields.io/badge/doi-10.1093/bioinformatics/btab658-blue.svg)](https://doi.org/10.1093/bioinformatics/btab658) +[![](https://img.shields.io/badge/devel%20version-0.99.0-black.svg)](https://github.com/RajLabMSSM/echoverseTemplate) +[![](https://img.shields.io/github/languages/code-size/RajLabMSSM/echoverseTemplate.svg)](https://github.com/RajLabMSSM/echoverseTemplate) +[![](https://img.shields.io/github/last-commit/RajLabMSSM/echoverseTemplate.svg)](https://github.com/RajLabMSSM/echoverseTemplate/commits/master) +
[![R build +status](https://github.com/RajLabMSSM/echoverseTemplate/workflows/rworkflows/badge.svg)](https://github.com/RajLabMSSM/echoverseTemplate/actions) +[![](https://codecov.io/gh/RajLabMSSM/echoverseTemplate/branch/master/graph/badge.svg)](https://app.codecov.io/gh/RajLabMSSM/echoverseTemplate) +
+ +

+Authors: Brian Schilder, Jack Humphrey, Towfique Raj +

+ +## `echoverseTemplate`: echoversePackageDescription. + +This R package is part of the *echoverse* suite that supports +[`echolocatoR`](https://github.com/RajLabMSSM/echolocatoR): an automated +genomic fine-mapping pipeline. + +If you use `echoverseTemplate`, please cite: + +> Brian M Schilder, Jack Humphrey, Towfique Raj (2021) echolocatoR: an +> automated end-to-end statistical and functional genomic fine-mapping +> pipeline, *Bioinformatics*; btab658, +> + +## Installation + +``` r +if(!require("remotes")) install.packages("remotes") + +remotes::install_github("RajLabMSSM/echoverseTemplate") +library(echoverseTemplate) +``` + +## Documentation + +### [Website](https://rajlabmssm.github.io/echoverseTemplate) + +### [Get started](https://rajlabmssm.github.io/echoverseTemplate/articles/echoverseTemplate) + +
+ +## Contact + +Brian +M. Schilder, Bioinformatician II +Raj Lab +Department +of Neuroscience, Icahn School of Medicine at Mount Sinai diff --git a/inst/CITATION b/inst/CITATION new file mode 100644 index 0000000..b81f114 --- /dev/null +++ b/inst/CITATION @@ -0,0 +1,15 @@ +citHeader("To cite this echoverse package, please use:") + +citEntry( + entry = "Article", + title = "echolocatoR: an automated end-to-end statistical and functional genomic fine-mapping pipeline", + author = "Brian M Schilder, Jack Humphrey, Towfique Raj", + journal = "Bioinformatics", + year = "2021", + volume = "btab658", + number = NULL, + pages = NULL, + url = "https://doi.org/10.1093/bioinformatics/btab658", + textVersion = paste("Brian M Schilder, Jack Humphrey, Towfique Raj (2021) echolocatoR: an automated end-to-end statistical and functional genomic fine-mapping pipeline, *Bioinformatics*; btab658, [https://doi.org/10.1093/bioinformatics/btab658](https://doi.org/10.1093/bioinformatics/btab658)" + ) +) diff --git a/inst/hex/hex.png b/inst/hex/hex.png new file mode 100644 index 0000000..c8721ec Binary files /dev/null and b/inst/hex/hex.png differ diff --git a/inst/hex/hexSticker.Rmd b/inst/hex/hexSticker.Rmd new file mode 100644 index 0000000..cfe6efa --- /dev/null +++ b/inst/hex/hexSticker.Rmd @@ -0,0 +1,130 @@ +--- +title: "hexSticker" +author: "

Author: Brian M. Schilder

" +date: "

Updated: `r format( Sys.Date(), '%b-%d-%Y')`

" +output: + BiocStyle::html_document +vignette: > + %\VignetteIndexEntry{hexSticker} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, echo=FALSE, include=FALSE} +pkg <- read.dcf(here::here("DESCRIPTION"), fields = "Package")[1] +description <- read.dcf(here::here("DESCRIPTION"), fields = "Description")[1] +``` + +You can make awesome hex stickers for your R packages using: + +- [hexSticker](https://github.com/GuangchuangYu/hexSticker) +- [ggimage](https://github.com/GuangchuangYu/ggimage) +lets you render images as data points. +- [ggpattern](https://coolbutuseless.github.io/package/ggpattern/) +lets you fill objects with patterns or images. +- [magick](https://cran.r-project.org/web/packages/magick/vignettes/intro.html) +modify PNGs. + +# `r pkg` + +```{r setup} +# If you're using R<4.1.1, need this version of rvcheck +# devtools::install_version('rvcheck',version='0.1.8') +library(hexSticker) +library(dplyr) +library(ggplot2) +library(ggimage) +# library(ggpattern)# remotes::install_github("coolbutuseless/ggpattern") +``` + +## File path + +Create file path. + +```{r} +filename <- here::here("inst/hex/hex.png") +dir.create(dirname(filename), showWarnings = FALSE, recursive = TRUE) +``` + +## Bat logo + +Download bat logo from the +[*echoverseTemplate*](https://github.com/RajLabMSSM/echoverseTemplate/releases/tag/latest) +GitHub Release. + +```{r} +tmp <- tempfile() +#### Side view #### +URL <- "https://github.com/RajLabMSSM/echoverseTemplate/releases/download/latest/bat_silhouette.png" +#### Front view #### +# URL <- "https://github.com/RajLabMSSM/echoverseTemplate/releases/download/latest/bat_silhouette_front.png" +download.file(URL, tmp) +``` + +## Background + +Create background with `ggplot2`. + +```{r, eval=FALSE} +set.seed(1234) +n_bats <- 20 +d <- data.frame(x = -rexp(n_bats, rate = 3), + y = rexp(n_bats, rate = 3) + ) |> + dplyr::mutate(image = URL, + bsize = abs(x*y^2)) |> + dplyr::arrange(dplyr::desc(x), dplyr::desc(y)) +qplot(d$x, d$y, size=d$bsize) +``` + +Import data points for reproducibility. + +```{r} +d <- data.table::fread("https://github.com/RajLabMSSM/echoverseTemplate/releases/download/latest/echoverse_points.csv.gz") +``` + + +```{r} +gg_bats <- ggplot(d, aes(x = x, y = y, color=bsize, image=image)) + + geom_image(aes(size=I(bsize)), alpha=1) + + scale_color_gradient(low = "#194f68", high = "#56ffff") + + coord_cartesian(clip = "off") + + labs(title = "echoverse") + + theme_void() + + theme(plot.title = element_text(color = "#56ffff", size = 25, + hjust = .5, vjust = 5, family = "Aller_Rg"), + legend.position = "none") + +print(gg_bats) +``` + +## hexSticker + +```{r} +s_size = 1 +stick <- hexSticker::sticker( + subplot = gg_bats, + #### Package name #### + package = pkg, p_size=14, p_y = 1.4, + #### Subplot ##### + s_x=1, s_y=.8, s_height = s_size, s_width = s_size, + #### Fill & border #### + h_fill = "#25355c", h_color = "#41c6c8", #56ffff + #### Spotlight #### + spotlight = TRUE, l_alpha = .3, l_width = 10, + #### File output #### + filename = filename, dpi = 300) +print(stick) +``` + + +# Session Info + +
+ +```{r Session Info} +utils::sessionInfo() +``` + +
+ diff --git a/man/message_parallel.Rd b/man/message_parallel.Rd new file mode 100644 index 0000000..4c978e8 --- /dev/null +++ b/man/message_parallel.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/message_parallel.r +\name{message_parallel} +\alias{message_parallel} +\title{Message parallel} +\usage{ +message_parallel(...) +} +\value{ +Null +} +\description{ +Send messages to console even from within parallel processes +} +\keyword{internal} diff --git a/man/messager.Rd b/man/messager.Rd new file mode 100644 index 0000000..989a5af --- /dev/null +++ b/man/messager.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/messager.R +\name{messager} +\alias{messager} +\title{Print messages} +\usage{ +messager(..., v = TRUE, parallel = FALSE) +} +\arguments{ +\item{v}{Whether to print messages or not.} + +\item{parallel}{Whether to enable message print when wrapped +in parallelised functions.} +} +\value{ +Null +} +\description{ +Conditionally print messages. + Allows developers to easily control verbosity of functions, + and meet Bioconductor requirements that dictate the message + must first be stored to a variable before passing to \link[base]{message}. +} +\keyword{internal} diff --git a/man/stopper.Rd b/man/stopper.Rd new file mode 100644 index 0000000..ceb98f3 --- /dev/null +++ b/man/stopper.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stopper.R +\name{stopper} +\alias{stopper} +\title{Stop messages} +\usage{ +stopper(..., v = TRUE) +} +\arguments{ +\item{v}{Whether to print messages or not.} +} +\value{ +Null +} +\description{ +Conditionally print stop messages. +Allows developers to easily control verbosity of functions, + and meet Bioconductor requirements that dictate the stop message + must first be stored to a variable before passing to \link[base]{stop}. +} +\keyword{internal} diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..d07238f --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,7 @@ +desc_path <- list.files("../","^DESCRIPTION$", + full.names = TRUE, recursive = TRUE)[1] +pkg <- read.dcf(desc_path, fields = "Package")[1] +library(testthat) +library(pkg, character.only = TRUE) + +test_check(pkg) diff --git a/tests/testthat/test-messager.R b/tests/testthat/test-messager.R new file mode 100644 index 0000000..e955ea9 --- /dev/null +++ b/tests/testthat/test-messager.R @@ -0,0 +1,13 @@ +test_that("messager works", { + + msg <- "Hello world" + #### Default #### + msg_out <- utils::capture.output(messager(msg), + type = "message") + testthat::expect_equal(msg, msg_out) + #### Parallel #### + f <- textConnection("test3", "w") + msg_out2 <- utils::capture.output(messager(msg, parallel = TRUE), + type = "message") + testthat::expect_equal(msg_out2, character()) +}) diff --git a/tests/testthat/test-stopper.R b/tests/testthat/test-stopper.R new file mode 100644 index 0000000..f44b2d9 --- /dev/null +++ b/tests/testthat/test-stopper.R @@ -0,0 +1,6 @@ +test_that("stopper works", { + + msg <- "You have encountered an error" + testthat::expect_error(stopper(msg = msg)) + testthat::expect_error(stopper(msg = msg, v=FALSE)) +}) diff --git a/vignettes/echoverseTemplate.Rmd b/vignettes/echoverseTemplate.Rmd new file mode 100644 index 0000000..7d4b791 --- /dev/null +++ b/vignettes/echoverseTemplate.Rmd @@ -0,0 +1,42 @@ +--- +title: Get started +author: '

Authors: `r auths <- eval(parse(text = gsub("person","c",read.dcf("../DESCRIPTION", + fields = "Authors@R"))));paste(auths[names(auths)=="given"],auths[names(auths)=="family"], + collapse = ", ")`

' +date: '

Vignette updated: `r format( Sys.Date(), "%b-%d-%Y")`

' +output: BiocStyle::html_document +vignette: | + %\VignetteIndexEntry{echoverseTemplate} + %\usepackage[utf8]{inputenc} + %\VignetteEngine{knitr::rmarkdown} +--- + + +```{r, echo=FALSE, include=FALSE} +pkg <- read.dcf("../DESCRIPTION", fields = "Package")[1] +library(pkg, character.only = TRUE) +``` + + +```R +library(`r pkg`) +``` + +# Examples + +```{r} + +``` + + +# Session Info + +
+ +```{r Session Info} +utils::sessionInfo() +``` + +
+ +