Skip to content

Commit

Permalink
Merge branch 'main' into clean_simulation_vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
d-morrison authored Oct 1, 2024
2 parents 3de7671 + fb1ec50 commit e1f176a
Show file tree
Hide file tree
Showing 43 changed files with 1,492 additions and 597 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ allpopsamples_hlye.csv$
^CRAN-SUBMISSION$
^README\.qmd$
^codecov\.yml$
^\.lintr$
^man/df_to_array\.Rd$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEWS.md merge=union
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug report or feature request
about: Describe a bug you've seen or make a case for a new feature
---

Please briefly describe your problem and what output you expect.
If you have a question, please don't use this form.
Instead, ask on
<https://github.com/UCD-SERG/serocalculator/discussions/categories/q-a>.

Please include a minimal reproducible example (AKA a reprex).
If you've never heard of a [reprex](http://reprex.tidyverse.org/) before,
start by reading <https://www.tidyverse.org/help/#reprex>.

For more advice on how to write a great issue, see <https://code-review.tidyverse.org/issues/>.

Brief description of the problem

```r
# insert reprex here
```
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Thank you for taking the time to submit a pull request!

To maximize the chances of acceptance:

- [ ] The title of your PR should briefly describe the change.
- [ ] The body of your PR should contain `Fixes #issue-number` (if relevant).
- [ ] Commit/merge messages to be included in NEWS.md should begin with `-`.
- [ ] Code should follow the tidyverse [style guide](https://style.tidyverse.org).
- [ ] Documentation should use roxygen2, with Markdown syntax.
- [ ] Contributions should include unit tests (using `testthat`).

For more information see [Contributing](/.github/CONTRIBUTING.md).
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main, master]
pull_request:

name: R-CMD-check
name: R-CMD-check.yaml

jobs:
R-CMD-check:
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/check-readme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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:
branches: [main, master]

name: check-readme

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

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

strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, r: "release" }
#- { os: ubuntu-latest, r: "devel" }

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

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "latest"

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

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: devel
upgrade: "TRUE"
extra-packages: |
local::.
any::gghalves
any::ggplot2
any::quarto
any::ggridges
any::ggbeeswarm
any::PairedData
any::metaviz
any::metaplus
- name: Render README
run: |
options(
crayon.enabled = TRUE,
# warnPartialMatchArgs = TRUE,
# warnPartialMatchAttr = TRUE,
# warnPartialMatchDollar = TRUE,
warn = 2L
)
quarto::quarto_render("README.qmd")
shell: Rscript {0}
6 changes: 3 additions & 3 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

jobs:
pkgdown:
Expand All @@ -22,7 +22,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

Expand All @@ -41,7 +41,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

Expand Down
2 changes: 2 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
linters: linters_with_defaults() # see vignette("lintr")
encoding: "UTF-8"
69 changes: 41 additions & 28 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
Package: serocalculator
Type: Package
Package: serocalculator
Title: Estimating Infection Rates from Serological Data
Version: 1.2.0.9005
Version: 1.2.0.9012
Authors@R: c(
person(given = "Peter", family = "Teunis", email = "[email protected]", role = c("aut", "cph"), comment = "Author of the method and original code."),
person(given = "Kristina", family = "Lai", email = "[email protected]", role = c("aut", "cre")),
person(given = "Chris", family = "Orwa", role = "aut"),
person(given = "Kristen", family = "Aiemjoy", email = "[email protected]", role = c("aut")),
person(given = "Douglas Ezra", family = "Morrison", email = "[email protected]", role = c("aut")))
Description: Translates antibody levels measured in cross-sectional population
samples into estimates of the frequency with which seroconversions (infections)
occur in the sampled populations. Replaces the previous `seroincidence` package.
Depends: R (>= 4.1.0)
person("Peter", "Teunis", , "[email protected]", role = c("aut", "cph"),
comment = "Author of the method and original code."),
person("Kristina", "Lai", , "[email protected]", role = c("aut", "cre")),
person("Chris", "Orwa", role = "aut"),
person("Kristen", "Aiemjoy", , "[email protected]", role = "aut"),
person("Douglas Ezra", "Morrison", , "[email protected]", role = "aut")
)
Description: Translates antibody levels measured in cross-sectional
population samples into estimates of the frequency with which
seroconversions (infections) occur in the sampled populations.
Replaces the previous `seroincidence` package.
License: GPL-3
URL: https://github.com/UCD-SERG/serocalculator,
https://ucd-serg.github.io/serocalculator/
BugReports: https://github.com/UCD-SERG/serocalculator/issues
Depends:
R (>= 4.1.0)
Imports:
cli,
doParallel,
dplyr (>= 1.1.1),
foreach,
Expand All @@ -29,28 +37,33 @@ Imports:
stats,
tibble,
tidyr,
utils,
tidyselect,
cli
utils
Suggests:
parallel,
bookdown,
devtag (>= 0.0.0.9000),
DT,
fs,
ggbeeswarm,
knitr,
pak,
parallel,
readr,
rmarkdown,
tidyverse,
fs,
spelling,
ssdtools (>= 1.0.6.9016),
testthat (>= 3.0.0),
readr,
bookdown,
ggbeeswarm,
DT,
spelling
LazyData: true
Encoding: UTF-8
URL: https://github.com/UCD-SERG/serocalculator, https://ucd-serg.github.io/serocalculator/
RoxygenNote: 7.3.2
NeedsCompilation: no
tidyverse
LinkingTo:
Rcpp
Language: en-US
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/Needs/build: moodymudskipper/devtag
Encoding: UTF-8
Language: en-US
LazyData: true
NeedsCompilation: no
Remotes:
bcgov/ssdtools,
moodymudskipper/devtag
Roxygen: list(markdown = TRUE, roclets = c("collate", "rd", "namespace", "devtag::dev_roclet"))
RoxygenNote: 7.3.2
13 changes: 0 additions & 13 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,10 @@ S3method(autoplot,pop_data)
S3method(autoplot,seroincidence)
S3method(autoplot,seroincidence.by)
S3method(autoplot,summary.seroincidence.by)
S3method(get_age,pop_data)
S3method(get_age_var,pop_data)
S3method(get_biomarker_levels,pop_data)
S3method(get_biomarker_names,pop_data)
S3method(get_biomarker_names_var,pop_data)
S3method(get_id,pop_data)
S3method(get_id_var,pop_data)
S3method(get_value,pop_data)
S3method(get_value_var,pop_data)
S3method(print,seroincidence)
S3method(print,seroincidence.by)
S3method(print,summary.pop_data)
S3method(print,summary.seroincidence.by)
S3method(set_age,pop_data)
S3method(set_biomarker_var,pop_data)
S3method(set_id,pop_data)
S3method(set_value,pop_data)
S3method(strata,seroincidence.by)
S3method(summary,pop_data)
S3method(summary,seroincidence)
Expand Down
28 changes: 28 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,39 @@

* Updated `simulate_xsectionalData.Rmd()` (linting, removing deprecated functions).

* Added default value for `antigen_isos` argument in `log_likelihood()` (#286)

* Updated enteric fever example article with upgraded code and visualizations (#290)

* Added template for reporting Issues
(from `usethis::use_tidy_issue_template()`) (#270)

* Added template for pull requests
(from <https://github.com/bcgov/ssdtools>) (#265)

## Developer-facing changes

* initialized [`lintr`](https://lintr.r-lib.org/) with `lintr::use_lint()` (#278)

* created unit test for `df_to_array()` (#276)

* fixed `dplyr::select()` deprecation warning in `df_to_array()` (#276)

* Added `devtag` to package (using `devtag::use_devtag()`) (#292)
* Added `@dev` tag to `?df_to_array()` (#292)

* Generalized `get_()` and `set_()` methods to be general-purpose
(no S3 class-specific methods needed yet) (#274).

* Updated GitHub Action files and reformatted `DESCRIPTION` (#268)
* Added `.gitattributes` file (<https://git-scm.com/docs/gitattributes>)
copied from <https://github.com/tidyverse/ggplot2>

* Added additional automated checks through
[GitHub actions](https://docs.github.com/en/actions),
including:
- check that `README.qmd` still compiles
(advice from [preventive-r-package-care](https://indrajeetpatil.github.io/preventive-r-package-care)) (#259)
- check `NEWS.md` for updated change log (#257)
- lint changed files (#256)

Expand Down
26 changes: 16 additions & 10 deletions R/as_curve_params.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#' Load antibody decay curve parameter
#'
#' @param data a [data.frame()] or [tibble::tbl_df]
#' @param antigen_isos [character()] vector of antigen isotypes to be used in analyses
#' @returns a `curve_data` object (a [tibble::tbl_df] with extra attribute `antigen_isos`)
#' @param antigen_isos a [character()] vector of antigen isotypes
#' to be used in analyses
#' @returns a `curve_data` object
#' (a [tibble::tbl_df] with extra attribute `antigen_isos`)
#' @export
#' @examples
#' library(magrittr)
Expand All @@ -14,8 +16,7 @@
#' print(curve_data)
as_curve_params <- function(data, antigen_isos = NULL) {

if(!is.data.frame(data))
{
if (!is.data.frame(data)) {
cli::cli_abort(
class = "not data.frame",
message = c(
Expand All @@ -31,16 +32,18 @@ as_curve_params <- function(data, antigen_isos = NULL) {
data %>%
tibble::as_tibble()

# check if object has expected columns:

# define curve columns
curve_cols <- c("antigen_iso", "y0", "y1", "t1", "alpha", "r")

# check if object is curve (with columns)
if (!all(is.element(curve_cols, curve_data %>% names()))) {
# get columns from provided data
data_cols <- data %>% names()
# get columns from provided data
data_cols <- data %>% names()

# get any missing column(s)
missing_cols <- setdiff(x = curve_cols, y = data_cols)

# get any missing column(s)
missing_cols <- setdiff(x = curve_cols, y = data_cols)
if (length(missing_cols) > 0) {

cli::cli_abort(
class = "not curve_params",
Expand All @@ -67,5 +70,8 @@ as_curve_params <- function(data, antigen_isos = NULL) {
# assign antigen attribute
attr(curve_data, "antigen_isos") <- antigen_isos

curve_data <- curve_data %>%
set_biomarker_var(biomarker = "antigen_iso", standardize = FALSE)

return(curve_data)
}
Loading

0 comments on commit e1f176a

Please sign in to comment.