Skip to content

Commit

Permalink
Add github action (#2)
Browse files Browse the repository at this point in the history
* add github action

* add Dockerfile

* ignore BBSoptions

* missing imports

* roxygenise

* error on error
  • Loading branch information
kevinrue authored Jun 7, 2020
1 parent 183d4cb commit ac08cfd
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^velociraptor\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^\.github$
^\.BBSoptions$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
80 changes: 80 additions & 0 deletions .github/workflows/bioc_pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
on:
push:
branches:
- master
pull_request:
branches:
- master

name: build-check-deploy

jobs:
build_check_deploy:
runs-on: ubuntu-latest
container: bioconductor/bioconductor_docker:devel
steps:
- uses: actions/checkout@v2

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: /usr/local/lib/R/site-library
key: ${{ runner.os }}-r-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-r-1-

# This lets us augment with additional dependencies
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories(), Ncpu = 2L)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "error", check_dir = "check")
shell: Rscript {0}

- name: Publish to Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: docker.pkg.github.com/${{ github.repository }}/master:latest
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com

- name: Build pkgdown
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
PATH=$PATH:$HOME/bin/ Rscript -e 'BiocManager::install("pkgdown"); pkgdown::build_site(".")'
# deploy needs rsync? Seems so.
- name: Install deploy dependencies
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
apt-get update && apt-get -y install rsync
- name: Deploy 🚀
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs # The folder the action should deploy.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Depends:
SummarizedExperiment
Imports:
methods,
BiocGenerics,
reticulate,
S4Vectors,
DelayedArray,
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM bioconductor/bioconductor_docker:devel

WORKDIR /home/rstudio

COPY --chown=rstudio:rstudio . /home/rstudio/

RUN apt-get update && apt-get install -y libglpk-dev && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN Rscript -e "devtools::install('.', dependencies=TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE)"
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export(scvelo)
exportMethods(scvelo)
import(SummarizedExperiment)
import(basilisk)
import(methods)
importFrom(BiocGenerics,sizeFactors)
importFrom(DelayedArray,is_sparse)
importFrom(S4Vectors,DataFrame)
importFrom(S4Vectors,make_zero_col_DFrame)
importFrom(basilisk,BasiliskEnvironment)
importFrom(reticulate,import)
importFrom(scuttle,normalizeCounts)
34 changes: 18 additions & 16 deletions R/scvelo.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
#'
#' For consistency with other Bioconductor packages, we perform scaling normalization, log-transformation and subsetting
#' before starting the velocity calculations with \pkg{scvelo}.
#' This allows us to guarantee that, e.g., the spliced log-expression matrix of HVGs is the same as that used in other
#' This allows us to guarantee that, e.g., the spliced log-expression matrix of HVGs is the same as that used in other
#' applications like clustering or trajectory reconstruction.
#' Nonetheless, one can set \code{use.theirs=TRUE} to directly use the entire \pkg{scvelo} normalization and filtering pipeline.
#'
#'
#' Upon first use, this function will instantiate a conda environment containing the \pkg{scvelo} package.
#'
#' @return
#'
#' @return
#' A \linkS4class{SummarizedExperiment} is returned containing the output of the velocity calculations.
#' TODO: SOME DOCUMENTATION REQUIRED.
#'
Expand All @@ -51,24 +51,24 @@
#' unspliced <- counts(sce2)
#'
#' out <- scvelo(list(spliced, unspliced))
#'
#'
#' @author Aaron Lun
#' @name scvelo
NULL

#' @importFrom S4Vectors DataFrame
#' @importFrom scuttle normalizeCounts
.scvelo <- function(x, subset.row=NULL, log.norm=FALSE,
sf.spliced=NULL, sf.unspliced=NULL,
use.theirs=FALSE,
.scvelo <- function(x, subset.row=NULL, log.norm=FALSE,
sf.spliced=NULL, sf.unspliced=NULL,
use.theirs=FALSE,
mode=c('steady_state', 'deterministic', 'stochastic', 'dynamical'),
get.velocities=TRUE)
{
spliced <- x[[1]]
unspliced <- x[[2]]
if (!identical(as.integer(dim(spliced)), as.integer(dim(unspliced)))) {
stop("matrices in 'x' must have the same dimensions")
}
}

# Can't be bothered figuring this out.
if (log.norm && use.theirs) {
Expand All @@ -88,8 +88,8 @@ NULL
}

mode <- match.arg(mode)
output <- basiliskRun(env=velo.env, fun=.run_scvelo,
spliced=spliced, unspliced=unspliced,
output <- basiliskRun(env=velo.env, fun=.run_scvelo,
spliced=spliced, unspliced=unspliced,
use.theirs=use.theirs, mode=mode)

output
Expand All @@ -108,7 +108,7 @@ NULL
if (use.theirs) {
scv$pp$filter_and_normalize(adata)
}
scv$pp$moments(adata)
scv$pp$moments(adata)

if (mode=="dynamical") {
scv$tl$recover_dynamics(adata)
Expand All @@ -118,9 +118,10 @@ NULL
scv$tl$velocity_graph(adata)
scv$tl$velocity_pseudotime(adata)

.scvelo_anndata2sce(adata)
.scvelo_anndata2sce(adata)
}

#' @importFrom S4Vectors make_zero_col_DFrame
.scvelo_anndata2sce <- function(adata) {
assays <- .extractor_python_dict(adata$layers, c("Mu", "Ms", "velocity"), single=TRUE)
rowdata <- .extractor_python_dict(adata$obs, names(adata$obs))
Expand Down Expand Up @@ -155,9 +156,10 @@ setMethod("scvelo", "ANY", .scvelo)

#' @export
#' @rdname scvelo
setMethod("scvelo", "SummarizedExperiment", function(x, ...,
assay.spliced="counts", assay.unspliced="unspliced",
sf.spliced=sizeFactors(x), sf.unspliced=NULL)
#' @importFrom BiocGenerics sizeFactors
setMethod("scvelo", "SummarizedExperiment", function(x, ...,
assay.spliced="counts", assay.unspliced="unspliced",
sf.spliced=sizeFactors(x), sf.unspliced=NULL)
{
x <- list(assay(x, assay.spliced), assay(x, assay.unspliced))
scvelo(x, ..., size.factors=size.factors)
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# velociraptor

<!-- badges: start -->
[![R build status](https://github.com/kevinrue/velociraptor/workflows/build-check-deploy/badge.svg)](https://github.com/kevinrue/velociraptor/actions)
<!-- badges: end -->

The goal of velociraptor is to ...

## Installation

You can install the released version of velociraptor from [GitHub](https://github.com/kevinrue/velociraptor) with:

``` r
install.packages("remotes")
remotes::install_github("kevinrue/velociraptor")
```

## Example

This is a basic example which shows you how to solve a common problem:

``` r
library(velociraptor)
## basic example code
```

26 changes: 20 additions & 6 deletions man/scvelo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac08cfd

Please sign in to comment.