Skip to content

Commit

Permalink
Merge pull request with unit testing etc
Browse files Browse the repository at this point in the history
pull request #4 from TheOafidian/feature/unit-testing
  • Loading branch information
SWittouck authored Jul 31, 2023
2 parents dab17eb + 99bf240 commit b8f2d0e
Show file tree
Hide file tree
Showing 70 changed files with 19,835 additions and 109 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.github$
^codecov\.yml$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
65 changes: 65 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 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
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
push:
branches: [main, master, feature/unit-testing]
pull_request:
branches: [main, master]
workflow_dispatch:

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'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
# dada2 needs atleast R3.6
# - {os: ubuntu-latest, r: 'oldrel-4'}

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

steps:
- uses: actions/checkout@v3

- 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
error-on: '"error"'
46 changes: 46 additions & 0 deletions .github/workflows/pkgdown.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/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]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3

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

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
branch: gh-pages
folder: docs
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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, feature/unit-testing]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

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

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
35 changes: 25 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
Package: tidyamplicons
Type: Package
Package: tidyamplicons
Title: Functions to Manipulate and Visualize Amplicon Abundance Data
Version: 0.2.2
Authors@R: c(person("Stijn", "Wittouck", email = "stijn.wittouck@uantwerpen.be", role = c("aut", "cre")))
Description: A toolkit for processing and visualizing amplicon abundance data, based on the tidyverse framework.
Authors@R:
person("Stijn", "Wittouck", , "stijn.wittouck@uantwerpen.be", role = c("aut", "cre"))
Description: A toolkit for processing and visualizing amplicon abundance
data, based on the tidyverse framework.
License: GPL-3
Encoding: UTF-8
LazyData: true
Depends: R (>= 3.6.0)
Imports:
ggplot2,
tidyr,
dplyr,
ggplot2,
magrittr,
purrr,
readr,
rlang (>= 0.4.11),
stringr,
tibble,
tidyr,
vegan
Suggests:
covr,
vdiffr,
dada2,
knitr,
phyloseq,
rmarkdown,
phyloseq
VignetteBuilder: knitr
RoxygenNote: 7.1.1
roxygen2,
testthat (>= 3.0.0)
VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Config/testthat/edition: 3
19 changes: 19 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(":=")
export(.data)
export(abundances)
export(abundances_matrix)
export(add_alphas)
Expand Down Expand Up @@ -28,6 +31,8 @@ export(aggregate_samples)
export(aggregate_taxa)
export(as_abundances)
export(as_abundances_matrix)
export(as_label)
export(as_name)
export(as_phyloseq)
export(as_tidyamplicons)
export(bar_plot)
Expand All @@ -36,7 +41,10 @@ export(change_id_samples)
export(change_id_taxa)
export(classify_taxa)
export(codifab_plot)
export(create_test_ta)
export(create_tidyamplicons)
export(enquo)
export(enquos)
export(everything)
export(filter_abundances)
export(filter_samples)
Expand Down Expand Up @@ -65,6 +73,7 @@ export(process_taxon_selection)
export(rank_names)
export(rarefy)
export(read_tidyamplicons)
export(remove_empty_samples)
export(report_numbers)
export(reset_ids)
export(sample_plot)
Expand All @@ -86,3 +95,13 @@ import(ggplot2)
import(stringr)
import(tidyr)
import(vegan)
importFrom(magrittr,"%>%")
importFrom(readr,read_csv)
importFrom(readr,write_csv)
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(rlang,as_label)
importFrom(rlang,as_name)
importFrom(rlang,enquo)
importFrom(rlang,enquos)
importFrom(tibble,tibble)
15 changes: 7 additions & 8 deletions R/adders_samples.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' # Initiate sample tibble
#' sample <- c("sample1", "sample2")
#' environment <- c("food fermentation", "human stool")
#' sample_tibble <- tibble(sample, environment)
#' sample_tibble <- tibble::tibble(sample, environment)
#'
#' # Add sample tibble to tidyamplicons object
#' data <- data %>%
Expand All @@ -40,7 +40,7 @@
#' @export
add_sample_tibble <- function(ta, sample_tibble) {

modify_at(ta, "samples", left_join, sample_tibble)
purrr::modify_at(ta, "samples", left_join, sample_tibble)

}

Expand Down Expand Up @@ -137,7 +137,6 @@ add_lib_size <- function(ta, step = "current") {
#' # Add total abundance
#' data <- data %>%
#' add_diversity_measures()
#'
#' @export
add_alphas <- function(ta) {

Expand Down Expand Up @@ -175,7 +174,7 @@ add_diversity_measures <- function(ta) {

ta %>%
add_alphas %>%
modify_at(
purrr::modify_at(
"samples", rename, div_observed = observed,
div_inv_simpson = inverse_simpson
)
Expand Down Expand Up @@ -258,11 +257,11 @@ add_sample_clustered <- function(ta) {
#' @examples
#' # Initiate abundance matrix
#' x <- matrix(
#' c(1500, 1300, 280, 356),
#' ncol = 2
#' c(1500, 1300, 280, 356, 456, 678),
#' ncol = 3
#' )
#' rownames(x) <- c("taxon1", "taxon2")
#' colnames(x) <- c("sample1", "sample2")
#' colnames(x) <- c("sample1", "sample2", "sample3")
#'
#' # Convert to tidyamplicons object
#' data <- create_tidyamplicons(x,
Expand Down Expand Up @@ -396,7 +395,7 @@ add_spike_ratio <- function(ta, spike_taxon) {
#'
#' # Add total abundance
#' data <- data %>%
#' add_cluster(n_clusters = 5)
#' add_cluster(n_clusters = 2)
#'
# Adds a variable "cluster" to the samples table
# To do: merge with add_sample_clustered somehow
Expand Down
Loading

0 comments on commit b8f2d0e

Please sign in to comment.