Skip to content

Commit d547636

Browse files
authored
Merge pull request #17 from abichat/dev
v1.0.0
2 parents e0fa244 + 393fc3b commit d547636

37 files changed

+547
-216
lines changed

.Rbuildignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
^appveyor\.yml$
88
^_pkgdown\.yml$
99
^cran-comments\.md$
10-
^dev_history\.R$
1110
^\.github$
1211
docs/
1312
pkgdown/
13+
^dev$
14+
^data-raw$
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
8+
name: R-CMD-check-prdev
9+
10+
jobs:
11+
R-CMD-check:
12+
if: "!contains(github.event.head_commit.message, 'skip ci')"
13+
runs-on: ubuntu-latest
14+
env:
15+
GITHUB_PAT: ${{ secrets.GH_TOKEN }}
16+
R_KEEP_PKG_SOURCE: yes
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: r-lib/actions/setup-pandoc@v2
21+
22+
- uses: r-lib/actions/setup-r@v2
23+
with:
24+
use-public-rspm: true
25+
26+
- uses: r-lib/actions/setup-r-dependencies@v2
27+
with:
28+
extra-packages: any::rcmdcheck
29+
needs: check
30+
31+
- uses: r-lib/actions/check-r-package@v2
32+
with:
33+
upload-snapshots: true
34+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.github/workflows/R-CMD-check.yaml

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
55
branches: [main, master, dev]
6-
pull_request:
7-
branches: [main, master, dev]
86

97
name: R-CMD-check
108

119
jobs:
1210
R-CMD-check:
11+
if: "!contains(github.event.head_commit.message, 'skip ci')"
1312
runs-on: ${{ matrix.config.os }}
1413

1514
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
@@ -18,8 +17,8 @@ jobs:
1817
fail-fast: false
1918
matrix:
2019
config:
21-
- {os: macOS-latest, r: 'release'}
22-
- {os: windows-latest, r: 'release'}
20+
- {os: macos-latest, r: 'release'}
21+
- {os: windows-latest, r: 'release'}
2322
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
2423
- {os: ubuntu-latest, r: 'release'}
2524
- {os: ubuntu-latest, r: 'oldrel-1'}
@@ -29,18 +28,22 @@ jobs:
2928
R_KEEP_PKG_SOURCE: yes
3029

3130
steps:
32-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v4
3332

34-
- uses: r-lib/actions/setup-pandoc@v1
33+
- uses: r-lib/actions/setup-pandoc@v2
3534

36-
- uses: r-lib/actions/setup-r@v1
35+
- uses: r-lib/actions/setup-r@v2
3736
with:
3837
r-version: ${{ matrix.config.r }}
3938
http-user-agent: ${{ matrix.config.http-user-agent }}
4039
use-public-rspm: true
4140

42-
- uses: r-lib/actions/setup-r-dependencies@v1
41+
- uses: r-lib/actions/setup-r-dependencies@v2
4342
with:
44-
extra-packages: rcmdcheck
43+
extra-packages: any::rcmdcheck
44+
needs: check
4545

46-
- uses: r-lib/actions/check-r-package@v1
46+
- uses: r-lib/actions/check-r-package@v2
47+
with:
48+
upload-snapshots: true
49+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.github/workflows/pkgdown.yaml

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
5-
branches: master
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
68
release:
79
types: [published]
810
workflow_dispatch:
@@ -12,24 +14,35 @@ name: pkgdown
1214
jobs:
1315
pkgdown:
1416
runs-on: ubuntu-latest
17+
# Only restrict concurrency for non-PR jobs
18+
concurrency:
19+
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
1520
env:
1621
GITHUB_PAT: ${{ secrets.GH_TOKEN }}
22+
permissions:
23+
contents: write
1724
steps:
18-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
1926

20-
- uses: r-lib/actions/setup-pandoc@v1
27+
- uses: r-lib/actions/setup-pandoc@v2
2128

22-
- uses: r-lib/actions/setup-r@v1
29+
- uses: r-lib/actions/setup-r@v2
2330
with:
2431
use-public-rspm: true
2532

26-
- uses: r-lib/actions/setup-r-dependencies@v1
33+
- uses: r-lib/actions/setup-r-dependencies@v2
2734
with:
28-
extra-packages: pkgdown
35+
extra-packages: any::pkgdown, local::.
2936
needs: website
3037

31-
- name: Deploy package
32-
run: |
33-
git config --local user.name "$GITHUB_ACTOR"
34-
git config --local user.email "[email protected]"
35-
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
38+
- name: Build site
39+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
40+
shell: Rscript {0}
41+
42+
- name: Deploy to GitHub pages 🚀
43+
if: github.event_name != 'pull_request'
44+
uses: JamesIves/[email protected]
45+
with:
46+
clean: false
47+
branch: gh-pages
48+
folder: docs

DESCRIPTION

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: yatah
22
Title: Yet Another TAxonomy Handler
3-
Version: 0.2.1
3+
Version: 1.0.0
44
Authors@R:
55
person("Antoine", "Bichat", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-6599-7081"))
@@ -14,6 +14,7 @@ Depends:
1414
R (>= 2.10)
1515
Imports:
1616
ape,
17+
lifecycle,
1718
purrr,
1819
stats,
1920
stringr
@@ -29,4 +30,4 @@ Encoding: UTF-8
2930
Language: en-US
3031
LazyData: true
3132
Roxygen: list(markdown = TRUE)
32-
RoxygenNote: 7.2.1
33+
RoxygenNote: 7.3.1

NAMESPACE

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(all_clades)
4+
export(get_all_clades)
5+
export(get_clade)
6+
export(get_last_clade)
7+
export(get_last_rank)
8+
export(is_at_least_rank)
49
export(is_clade)
510
export(is_lineage)
611
export(is_rank)
@@ -14,6 +19,7 @@ export(trim_void)
1419
importFrom(ape,collapse.singles)
1520
importFrom(ape,read.tree)
1621
importFrom(ape,write.tree)
22+
importFrom(lifecycle,deprecate_warn)
1723
importFrom(purrr,map)
1824
importFrom(purrr,transpose)
1925
importFrom(stats,na.omit)

NEWS.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# yatah 1.0.0
2+
3+
* `last_clade()`, `last_rank()` and `all_clades()` are now deprecated in favor
4+
of `get_last_clade()`, `get_last_rank()` and `get_all_clades()` (#11).
5+
6+
* New functions `get_clade()` (#12) and `is_at_least_rank()`.
7+
8+
* New dataset `all_ranks`.
9+
110
# yatah 0.2.1
211

312
* Use of Roxygen 7.2.1.

R/abundances.R R/data.R

+8
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@
1414
#' dim(abundances)
1515
#' abundances[1:5, 1:7]
1616
"abundances"
17+
18+
#' Ranks handled by `yatah`
19+
#'
20+
#' @keywords datasets
21+
#' @examples
22+
#' all_ranks
23+
"all_ranks"
24+

R/deprecated.R

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#' Deprecated functions
2+
#'
3+
#' @importFrom lifecycle deprecate_warn
4+
#'
5+
#' @description
6+
#' `r lifecycle::badge("deprecated")`
7+
#'
8+
#' Use [get_last_clade()] instead of `last_clade()`.
9+
#'
10+
#' @export
11+
#' @keywords internal
12+
#' @name deprecated
13+
last_clade <- function(...) {
14+
deprecate_warn("1.0.0", "last_clade()", "get_last_clade()")
15+
16+
get_last_clade(...)
17+
}
18+
19+
#' @rdname deprecated
20+
#'
21+
#' @description
22+
#'
23+
#' Use [get_last_rank()] instead of `last_rank()`.
24+
#'
25+
#' @export
26+
last_rank <- function(...) {
27+
deprecate_warn("1.0.0", "last_rank()", "get_last_rank()")
28+
29+
get_last_rank(...)
30+
}
31+
32+
#' @rdname deprecated
33+
#'
34+
#' @description
35+
#'
36+
#' Use [get_all_clades()] instead of `all_clades()`.
37+
#'
38+
#' @export
39+
all_clades <- function(...) {
40+
deprecate_warn("1.0.0", "all_clades()", "get_all_clades()")
41+
42+
get_all_clades(...)
43+
}

R/extract.R R/get.R

+41-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Extract the last clade of a lineage
22
#'
33
#' @inheritParams is_rank
4-
#' @param same logical. Does the lineage have the same depth? Default to TRUE.
4+
#' @param same logical. Does the lineage have the same depth? Default to `TRUE`.
55
#'
66
#' @return A string. The last clades of the given lineages.
77
#' @importFrom stringr str_remove
@@ -10,8 +10,8 @@
1010
#' @examples
1111
#' lineage1 <- "k__Bacteria|p__Verrucomicrobia|c__Verrucomicrobiae"
1212
#' lineage2 <- "k__Bacteria|p__Firmicutes|c__Clostridia"
13-
#' last_clade(c(lineage1, lineage2))
14-
last_clade <- function(lineage, same = TRUE) {
13+
#' get_last_clade(c(lineage1, lineage2))
14+
get_last_clade <- function(lineage, same = TRUE) {
1515

1616
error_lineage(lineage)
1717

@@ -20,10 +20,41 @@ last_clade <- function(lineage, same = TRUE) {
2020
str_remove(lineage, ".*__")
2121
}
2222

23+
#' Extract the clade of a desired rank in a lineage
24+
#'
25+
#' @inheritParams get_last_clade
26+
#' @param rank The desired rank of the clade.
27+
#'
28+
#' @return A string.
29+
#'
30+
#' @importFrom stringr str_extract str_remove_all
31+
#' @export
32+
#'
33+
#' @examples
34+
#' lineage1 <- "k__Bacteria|p__Verrucomicrobia|c__Verrucomicrobiae"
35+
#' lineage2 <- "k__Bacteria|p__Firmicutes|c__Clostridia"
36+
#' get_clade(c(lineage1, lineage2), "phylum")
37+
get_clade <- function(lineage, rank = yatah::all_ranks, same = TRUE) {
38+
39+
error_lineage(lineage)
40+
41+
if (same) depth(lineage)
42+
43+
rank <- match.arg(rank)
44+
letter <- names(which(.ranks == rank))
45+
46+
sep <- getOption("yatah_sep", default = "\\|")
47+
48+
str_remove_all(
49+
str_extract(lineage, paste0("(?<=", letter, "__).*")),
50+
paste0(sep, ".*")
51+
)
52+
}
53+
2354

2455
#' Extract the last rank of a lineage
2556
#'
26-
#' @inheritParams last_clade
57+
#' @inheritParams get_last_clade
2758
#'
2859
#' @return A string. The last rank of the given lineages.
2960
#' @importFrom stringr str_remove
@@ -32,8 +63,8 @@ last_clade <- function(lineage, same = TRUE) {
3263
#' @examples
3364
#' lineage1 <- "k__Bacteria|p__Verrucomicrobia|c__Verrucomicrobiae"
3465
#' lineage2 <- "k__Bacteria|p__Firmicutes|c__Clostridia"
35-
#' last_rank(c(lineage1, lineage2))
36-
last_rank <- function(lineage, same = TRUE) {
66+
#' get_last_rank(c(lineage1, lineage2))
67+
get_last_rank <- function(lineage, same = TRUE) {
3768

3869
error_lineage(lineage)
3970

@@ -54,7 +85,7 @@ last_rank <- function(lineage, same = TRUE) {
5485
#' clades with same name and same rank when \code{simplify} is set to
5586
#' \code{FALSE}.
5687
#'
57-
#' @inheritParams last_clade
88+
#' @inheritParams get_last_clade
5889
#' @param simplify logical. Should the output be a vector or a dataframe?
5990
#'
6091
#' @return The clades present in the lineage. Vector of ordered strings
@@ -66,9 +97,9 @@ last_rank <- function(lineage, same = TRUE) {
6697
#' lineage1 <- "k__Bacteria|p__Verrucomicrobia|c__Verrucomicrobiae"
6798
#' lineage2 <- "k__Bacteria|p__Firmicutes|c__Clostridia"
6899
#' lineage3 <- "k__Bacteria|p__Actinobacteria|c__Actinobacteria"
69-
#' all_clades(c(lineage1, lineage2, lineage3))
70-
#' all_clades(c(lineage1, lineage2, lineage3), simplify = FALSE)
71-
all_clades <- function(lineage, simplify = TRUE) {
100+
#' get_all_clades(c(lineage1, lineage2, lineage3))
101+
#' get_all_clades(c(lineage1, lineage2, lineage3), simplify = FALSE)
102+
get_all_clades <- function(lineage, simplify = TRUE) {
72103

73104
error_lineage(lineage)
74105

0 commit comments

Comments
 (0)