Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tidysq sequences #73

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f4471f0
Replace string list support with string vector support
slowikj Dec 12, 2020
582da44
Support tidysq sequences
slowikj Dec 12, 2020
38291c6
Github workflows: add tidysq github dependency
slowikj Dec 13, 2020
2734f00
Add tidysq tests
slowikj Dec 13, 2020
5234761
Fix typo in R-CMD-check.yaml
slowikj Dec 13, 2020
f528949
Github workflow: change quote
slowikj Dec 13, 2020
8dcd9d4
Install github dependencies: add Rscript -e
slowikj Dec 13, 2020
1cf6ee1
R-CMD-check.yaml: fix typo
slowikj Dec 13, 2020
6ec3e5d
Fix typo in package name
slowikj Dec 13, 2020
b36ade7
Github workflows: add CRAN repo explicitly to devtools inst.
slowikj Dec 13, 2020
0303a64
Github workflows: add required Linux packages for devtools
slowikj Dec 13, 2020
ec602ff
Add rcpp::depends
slowikj Dec 15, 2020
df09c29
Github actions: add testthat and run_covr environment variables
slowikj Dec 15, 2020
582c41d
Github workflow: replace devtools with remotes
slowikj Dec 15, 2020
25d625e
Move installing remotes package up
slowikj Dec 15, 2020
488d12e
Add RScript
slowikj Dec 15, 2020
6c9fcb3
Try removed k-mer computation
slowikj Dec 15, 2020
4c0ba0b
Temporarily remove all workflows except for windows
slowikj Dec 15, 2020
46bce42
Revert "Try removed k-mer computation"
slowikj Dec 17, 2020
2078439
Fix tidysq batch sequence indexing
slowikj Dec 17, 2020
30c0a62
Merge branch 'master' into feature/tidysq-integration
slowikj Dec 17, 2020
ee0ebe4
Update github workflow
slowikj Dec 17, 2020
d2ce553
Github workflow: fix spaces
slowikj Dec 17, 2020
bc91197
Change workflow triggers
slowikj Dec 17, 2020
abc150d
Add using namespace tidysq
slowikj Dec 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 193 additions & 44 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# NOTE: This workflow is overkill for most R packages
# check-standard.yaml is likely a better choice
# usethis::use_github_action("check-standard") will install it.
#
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
# Read more about GitHub actions the features of this GitHub Actions workflow
## at https://lcolladotor.github.io/biocthis/articles/biocthis.html#use_bioc_github_action
##
## For more details, check the biocthis developer notes vignette at
## https://lcolladotor.github.io/biocthis/articles/biocthis_dev_notes.html
##
## You can add this workflow to other packages using:
## > biocthis::use_bioc_github_action()
##
## Using GitHub Actions exposes you to many details about how R packages are
## compiled and installed in several operating system.s
### If you need help, please follow the steps listed at
## https://github.com/r-lib/actions#where-to-find-help
##
## If you found an issue specific to biocthis's GHA workflow, please report it
## with the information that will make it easier for others to help you.
## Thank you!

## Acronyms:
## * GHA: GitHub Action
## * OS: operating system

on:
push:
branches:
Expand All @@ -14,64 +30,181 @@ on:
- main
- master

name: R-CMD-check
name: R-CMD-check-bioc

## These environment variables control whether to run GHA code later on that is
## specific to testthat, covr, and pkgdown.
##
## If you need to clear the cache of packages, update the number inside
## cache-version as discussed at https://github.com/r-lib/actions/issues/86.
## Note that you can always run a GHA test without the cache by using the word
## "/nocache" in the commit message.
env:
has_testthat: 'true'
run_covr: 'true'
run_pkgdown: 'true'
has_RUnit: 'false'
cache-version: 'cache-v1'

jobs:
R-CMD-check:
build-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})
container: ${{ matrix.config.cont }}
## Environment variables unique to this job.

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}

- { os: ubuntu-latest, r: '4.0', bioc: '3.12', cont: "bioconductor/bioconductor_docker:RELEASE_3_12", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: macOS-latest, r: '4.0', bioc: '3.12'}
- { os: windows-latest, r: '4.0', bioc: '3.12'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
NOT_CRAN: true
TZ: UTC
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
## to avoid conversion of configure.ac
- name: Configure git
run: git config --global core.autocrlf false

- uses: r-lib/actions/setup-r@v1
## Set the R library to the directory matching the
## R packages cache step further below when running on Docker (Linux).
- name: Set R Library home on Linux
if: runner.os == 'Linux'
run: |
mkdir /__w/_temp/Library
echo ".libPaths('/__w/_temp/Library')" > ~/.Rprofile
## Most of these steps are the same as the ones in
## https://github.com/r-lib/actions/blob/master/examples/check -standard.yaml
## If they update their steps, we will also need to update ours.
- name: Checkout Repository
uses: actions/checkout@v2

## R is already included in the Bioconductor docker images
- name: Setup R from r-lib
if: runner.os != 'Linux'
uses: r-lib/actions/setup-r@master
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}

- uses: r-lib/actions/setup-pandoc@v1
## pandoc is already included in the Bioconductor docker images
- name: Setup pandoc from r-lib
if: runner.os != 'Linux'
uses: r-lib/actions/setup-pandoc@master

- name: Install github dependencies
run: |
Rscript -e "install.packages('remotes')"
Rscript -e "remotes::install_github('BioGenies/tidysq')"

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'"
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-

- name: Install system dependencies
- name: Cache R packages on Linux
if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' "
uses: actions/cache@v2
with:
path: /home/runner/work/_temp/Library
key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_12-r-4.0-

- name: Install Linux system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))')
sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "20.04")), collapse = " "))')
echo $sysreqs
sudo -s eval "$sysreqs"
- name: Install macOS system dependencies
if: matrix.config.os == 'macOS-latest'
run: |
mkdir ~/.R
touch ~/.R/Makevars
echo "CXX_STD = CXX17" > ~/.R/Makevars

## Enable installing XML from source if needed
brew install libxml2
echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV
## Required to install magick as noted at
## https://github.com/r-lib/usethis/commit/f1f1e0d10c1ebc75fd4c18fa7e2de4551fd9978f#diff-9bfee71065492f63457918efcd912cf2
brew install imagemagick@6
## For textshaping, required by ragg, and required by pkgdown
brew install harfbuzz fribidi
## Helps compile RCurl from source; added forced ignoring deps
brew uninstall --ignore-dependencies curl
- name: Install Windows system dependencies
if: runner.os == 'Windows'
run: |
## Edit below if you have any Windows system dependencies
shell: Rscript {0}

- name: Install BiocManager
run: |
message(paste('****', Sys.time(), 'installing BiocManager ****'))
remotes::install_cran("BiocManager")
shell: Rscript {0}

- name: Set BiocVersion
run: |
BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE)
shell: Rscript {0}

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
## Try installing the package dependencies in steps. First the local
## dependencies, then any remaining dependencies to avoid the
## issues described at
## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html
## https://github.com/r-lib/remotes/issues/296
## Ideally, all dependencies should get installed in the first pass.
## Temporary for now due to https://github.com/ropensci/RefManageR/issues/79
remotes::install_github("ropensci/bibtex")
remotes::install_github("ropensci/RefManageR")
remotes::install_github("cboettig/knitcitations")
## Pass #1 at installing dependencies
message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****'))
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE)
## Pass #2 at installing dependencies
message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE)
## For running the checks
message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
remotes::install_cran("rcmdcheck")
BiocManager::install("BiocCheck")
shell: Rscript {0}

- name: Install BiocGenerics
if: env.has_RUnit == 'true'
run: |
## Install BiocGenerics
BiocManager::install("BiocGenerics")
shell: Rscript {0}

- name: Install covr
if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux'
run: |
remotes::install_cran("covr")
shell: Rscript {0}

- name: Install pkgdown
if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
run: |
remotes::install_cran("pkgdown")
shell: Rscript {0}

- name: Session info
Expand All @@ -81,32 +214,48 @@ jobs:
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
- name: Run CMD check
env:
_R_CHECK_CRAN_INCOMING_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check")
run: |
rcmdcheck::rcmdcheck(
args = c("--no-build-vignettes", "--no-manual", "--timings"),
build_args = c("--no-manual", "--no-resave-data"),
error_on = "error",
check_dir = "check"
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
## Might need an to add this to the if: && runner.os == 'Linux'
- name: Reveal testthat details
if: env.has_testthat == 'true'
run: find . -name testthat.Rout -exec cat '{}' ';'

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
- name: Run RUnit tests
if: env.has_RUnit == 'true'
run: |
BiocGenerics:::testPackage()
shell: Rscript {0}

- name: Install covr
if: github.ref == 'refs/heads/master' && env.run_covr == 'true'
- name: Run BiocCheck
run: |
remotes::install_cran("covr")
BiocCheck::BiocCheck(
dir('check', 'tar.gz$', full.names = TRUE),
`quit-with-status` = TRUE,
`no-check-R-ver` = TRUE,
`no-check-bioc-help` = TRUE,
`no-check-vignettes` = TRUE,
`no-check-man-doc` = TRUE,
`no-check-bioc-views` = TRUE
)
shell: Rscript {0}

- name: Test coverage
if: github.ref == 'refs/heads/master' && env.run_covr == 'true'
if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux'
run: |
covr::codecov()
shell: Rscript {0}

- name: Install package
if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
run: R CMD INSTALL .
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set(R_LIBRARY "~/R/x86_64-pc-linux-gnu-library/3.6/")
set(R_INCLUDE "/usr/share/R/include/")
include_directories(${R_LIBRARY}/Rcpp/include)
include_directories(${R_LIBRARY}/RcppParallel/include)
include_directories(${R_LIBRARY}/tidysq/include)

include_directories(${R_INCLUDE})

add_library(seqR
Expand Down
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ Imports:
Rcpp (>= 1.0.4),
RcppParallel,
slam,
rlang
rlang,
tidysq
Depends:
R(>= 3.6)
LinkingTo:
Rcpp,
RcppParallel,
BH
BH,
tidysq
SystemRequirements: c++17
RoxygenNote: 7.1.0
Encoding: UTF-8
Expand Down
16 changes: 12 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ NULL
.Call('_seqR_count_contiguous_kmers_numeric', PACKAGE = 'seqR', sequenceMatrix, alphabet, rcppParams)
}

.count_contiguous_kmers_list <- function(sq, alphabet, rcppParams) {
.Call('_seqR_count_contiguous_kmers_list', PACKAGE = 'seqR', sq, alphabet, rcppParams)
.count_contiguous_kmers_string_vector <- function(sq, alphabet, rcppParams) {
.Call('_seqR_count_contiguous_kmers_string_vector', PACKAGE = 'seqR', sq, alphabet, rcppParams)
}

.count_contiguous_kmers_tidysq <- function(sq, alphabet, rcppParams) {
.Call('_seqR_count_contiguous_kmers_tidysq', PACKAGE = 'seqR', sq, alphabet, rcppParams)
}

.count_gapped_kmers_string <- function(sequenceMatrix, alphabet, rcppParams) {
Expand All @@ -38,7 +42,11 @@ NULL
.Call('_seqR_count_gapped_kmers_numeric', PACKAGE = 'seqR', sequenceMatrix, alphabet, rcppParams)
}

.count_gapped_kmers_list <- function(sq, alphabet, rcppParams) {
.Call('_seqR_count_gapped_kmers_list', PACKAGE = 'seqR', sq, alphabet, rcppParams)
.count_gapped_kmers_string_vector <- function(sq, alphabet, rcppParams) {
.Call('_seqR_count_gapped_kmers_string_vector', PACKAGE = 'seqR', sq, alphabet, rcppParams)
}

.count_gapped_kmers_tidysq <- function(sq, alphabet, rcppParams) {
.Call('_seqR_count_gapped_kmers_tidysq', PACKAGE = 'seqR', sq, alphabet, rcppParams)
}

4 changes: 0 additions & 4 deletions R/count_kmers.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ count_kmers <- function(sequences,
stop("batch size field must be a positive integer number")
}

if(is.vector(sequences)) {
sequences <- matrix(data=sequences, nrow=1)
}

if(!is_positive_integer(hash_dim) || hash_dim > 8) {
stop("hash_dim is a single integer number from the range [1, 8]")
}
Expand Down
9 changes: 6 additions & 3 deletions R/kmer_functions_provider.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
}

.get_kmer_function <- function(sequences) {
if (is.list(sequences)) {
.kmer_functions_map[["list"]]
if(tidysq::is.sq(sequences)) {
.kmer_functions_map[["tidysq"]]
} else if (is.vector(sequences)) {
.kmer_functions_map[["string_vector"]]
} else if (has_integers_only(sequences)) {
.kmer_functions_map[["integer"]]
} else if (is.numeric(sequences)) {
Expand All @@ -25,5 +27,6 @@
"integer" = list(.count_contiguous_kmers_integer_proxy, .count_gapped_kmers_integer_proxy),
"string" = list(.count_contiguous_kmers_string_proxy, .count_gapped_kmers_string_proxy),
"numeric" = list(.count_contiguous_kmers_numeric_proxy, .count_gapped_kmers_numeric_proxy),
"list" = list(.count_contiguous_kmers_list_proxy, .count_gapped_kmers_list_proxy)
"string_vector" = list(.count_contiguous_kmers_string_vector_proxy, .count_gapped_kmers_string_vector_proxy),
"tidysq" = list(.count_contiguous_kmers_tidysq_proxy, .count_gapped_kmers_tidysq_proxy)
)
Loading