Skip to content

Commit

Permalink
Update workflow and formatting (#121)
Browse files Browse the repository at this point in the history
* update description

* ok let's go

* test windows too

* Update r.yml

* Update r.yml

* Update r.yml

* Update r.yml
  • Loading branch information
zktuong authored Dec 6, 2024
1 parent 59caf07 commit 6e64612
Show file tree
Hide file tree
Showing 23 changed files with 1,537 additions and 1,372 deletions.
81 changes: 22 additions & 59 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,50 @@ on:
push:
branches:
- "master"
- "*"

env:
cache-version: "cache-v1"

jobs:
build:
strategy:
max-parallel: 5
matrix:
config:
- { r-version: release, os: ubuntu-latest }
- { r-version: release, os: macos-latest }
- { os: ubuntu-latest }
- { os: windows-latest }
- { os: macos-latest }
runs-on: ${{ matrix.config.os }}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
NOT_CRAN: true
TZ: UTC
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4

- name: Install ubuntu system dependencies
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt-get install git libcurl4-openssl-dev libssl-dev libicu-dev libxml2-dev make pandoc libgit2-dev libharfbuzz-dev libfribidi-dev libglpk-dev
- name: Install macOS system dependencies
if: matrix.config.os == 'macos-latest'
run: |
brew install cairo pkg-config autoconf automake libtool
- name: Set up R
uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r@v2
id: install-r
with:
r-version: ${{ matrix.config.r-version}}

- name: Setup r-lib/remotes
run: |
install.packages(c("remotes", "devtools"))
shell: Rscript {0}
use-public-rspm: true

- id: bioc
name: Check bioc version
run: |
echo "##[set-output name=mainbiocversion;]$(Rscript -e 'cat(unlist(tools:::.BioC_version_associated_with_R_version()))' | awk '{print $1}')"
echo "##[set-output name=subbiocversion;]$(Rscript -e 'cat(unlist(tools:::.BioC_version_associated_with_R_version()))' | awk '{print $2}')"
echo "##[set-output name=biocversion;]$(Rscript -e 'cat(as.character(tools:::.BioC_version_associated_with_R_version()))' | awk '{print $1}')"
shell: bash -l {0}
- uses: r-lib/actions/setup-pandoc@v2

- name: Cache ubuntu R packages
if: "!contains(github.event.head_commit.message, '/nocache') && matrix.config.os == 'ubuntu-latest'"
uses: actions/cache@v2
- name: Cache R packages
uses: actions/cache@v4
with:
path: /home/runner/work/_temp/Library
key: ${{ env.cache-version }}-${{ matrix.config.os }}-biocversion-RELEASE_${{ steps.bioc.outputs.mainbiocversion}}_${{ steps.bioc.outputs.subbiocversion}}-r-${{ matrix.config.r-version}}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ matrix.config.os }}-biocversion-RELEASE_${{ steps.bioc.outputs.mainbiocversion}}_${{ steps.bioc.outputs.subbiocversion}}-r-${{ matrix.config.r-version}}-
key: ${{ runner.OS }}-R-${{ steps.install-r.outputs.installed-r-version }}-cache-${{ hashFiles('.github/depends.Rds') }}
restore-keys: |
${{ runner.OS }}-R-${{ steps.install-r.outputs.installed-r-version }}-cache-
- name: Cache macOS R packages
if: "!contains(github.event.head_commit.message, '/nocache') && matrix.config.os != 'ubuntu-latest'"
uses: actions/cache@v2
- name: Install and check
uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ env.cache-version }}-${{ matrix.config.os }}-biocversion-RELEASE_${{ steps.bioc.outputs.mainbiocversion}}_${{ steps.bioc.outputs.subbiocversion}}-r-${{ matrix.config.r-version}}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ matrix.config.os }}-biocversion-RELEASE_${{ steps.bioc.outputs.mainbiocversion}}_${{ steps.bioc.outputs.subbiocversion}}-r-${{ matrix.config.r-version}}-

- name: Install dependencies
run: |
install.packages(c("rcmdcheck", "covr"))
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}

- name: Check
run: |
Rscript -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")'
shell: bash -l {0}
extra-packages: |
any::rcmdcheck
covr
pkgdown
needs: check

- name: Test coverage
if: github.actor == 'zktuong'
if: github.actor == 'zktuong' && matrix.config.os == 'ubuntu-latest'
run: |
Rscript -e 'covr::codecov(token = "${{ secrets.CODECOV_TOKEN }}")'
shell: bash -l {0}
37 changes: 11 additions & 26 deletions .github/workflows/vignette.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,26 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

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

- id: bioc
name: Check bioc version
run: |
echo "##[set-output name=mainbiocversion;]$(Rscript -e 'cat(unlist(tools:::.BioC_version_associated_with_R_version()))' | awk '{print $1}')"
echo "##[set-output name=subbiocversion;]$(Rscript -e 'cat(unlist(tools:::.BioC_version_associated_with_R_version()))' | awk '{print $2}')"
echo "##[set-output name=biocversion;]$(Rscript -e 'cat(as.character(tools:::.BioC_version_associated_with_R_version()))' | awk '{print $1}')"
shell: bash -l {0}

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
${{ env.R_LIBS_USER }}
!${{ env.R_LIBS_USER }}/pak
key: ${{ env.cache-version }}-${{ matrix.config.os }}-biocversion-RELEASE_${{ steps.bioc.outputs.mainbiocversion}}_${{ steps.bioc.outputs.subbiocversion}}-r-${{ matrix.config.r-version}}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ env.cache-version }}-${{ matrix.config.os }}-biocversion-RELEASE_${{ steps.bioc.outputs.mainbiocversion}}_${{ steps.bioc.outputs.subbiocversion}}-r-${{ matrix.config.r-version}}-
path: /home/runner/work/_temp/Library
key: ${{ runner.OS }}-R-${{ steps.install-r.outputs.installed-r-version }}-cache-${{ hashFiles('.github/depends.Rds') }}
restore-keys: |
${{ runner.OS }}-R-${{ steps.install-r.outputs.installed-r-version }}-cache-
- name: Install dependencies
run: |
pak::local_install_dev_deps(upgrade = TRUE, dependencies = c("all", "Config/Needs/website"))
pak::pkg_install("pkgdown")
shell: Rscript {0}
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: pkgdown

- name: Install package
run: R CMD INSTALL .
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Suggests:
scater,
testthat,
covr,
plyr
LazyData: true
RoxygenNote: 7.2.3
plyr,
styler
LazyData: false
RoxygenNote: 7.3.2
Collate:
'combine_cpdb.R'
'correlationSpot.R'
Expand Down
20 changes: 9 additions & 11 deletions R/combine_cpdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
#' @return combine results from multiple cellphonedb runs.
#' @import dplyr
#' @import purrr
#' @examples
#' \donttest{
#' combine_cpdb(means, means2, means3)
#' combine_cpdb(pvals, pvals2, pvals3)
#' combine_cpdb(decon, decon2, decon3)
#' }
#' @export
combine_cpdb <- function(...) {
output <- list(...)
anames <- c("id_cp_interaction", "interacting_pair", "partner_a", "partner_b",
anames <- c(
"id_cp_interaction", "interacting_pair", "partner_a", "partner_b",
"gene_a", "gene_b", "secreted", "receptor_a", "receptor_b", "annotation_strategy",
"is_integrin")
bnames <- c("gene_name", "uniprot", "is_complex", "protein_name", "complex_name",
"id_cp_interaction")
"is_integrin"
)
bnames <- c(
"gene_name", "uniprot", "is_complex", "protein_name", "complex_name",
"id_cp_interaction"
)
if (all(colnames(output[[1]])[1:11] == anames)) {
out <- output %>%
reduce(full_join, by = anames)
Expand All @@ -26,4 +24,4 @@ combine_cpdb <- function(...) {
reduce(full_join, by = bnames)
}
return(out)
}
}
15 changes: 10 additions & 5 deletions R/correlationSpot.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
#' @return SpatialFeaturePlot
#' @export

correlationSpot <- function(st, genes = NULL, celltypes = NULL, geneset = NULL, mode = c("high",
"low", "both"), cutoff = 0.5, standardize = TRUE, dims = 1:30, k.params = 10,
resolution = 1, rna_slot = "SCT", label_slot = "predictions", by = c("image",
"expression"), average_by_cluster = FALSE, ...) {
correlationSpot <- function(
st, genes = NULL, celltypes = NULL, geneset = NULL, mode = c(
"high",
"low", "both"
), cutoff = 0.5, standardize = TRUE, dims = 1:30, k.params = 10,
resolution = 1, rna_slot = "SCT", label_slot = "predictions", by = c(
"image",
"expression"
), average_by_cluster = FALSE, ...) {
requireNamespace("Seurat")
requireNamespace("FNN")

Expand Down Expand Up @@ -213,4 +218,4 @@ correlationSpot <- function(st, genes = NULL, celltypes = NULL, geneset = NULL,

g <- Seurat::SpatialFeaturePlot(st, features = "correlation", ...)
return(g)
}
}
2 changes: 1 addition & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@
#' interaction_scores_v5 - Dataframe of CellPhoneDB output interaction_scores.txt file
#' @rdname kidneyimmune
#' @docType data
"interaction_scores_v5"
"interaction_scores_v5"
Loading

0 comments on commit 6e64612

Please sign in to comment.