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

Add GitHub workflow for R CMD check #24

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
^.*\.Rproj$
^\.Rproj\.user$

# Git
.gitignore
.github

# README
README.md
README.Rmd
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Workflow derived from
# https://github.com/r-lib/actions/blob/v2-branch/examples/check-standard.yaml

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

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'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

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

steps:
- uses: actions/checkout@v4

- 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

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ biocViews: Annotation, DifferentialExpression, GeneExpression,
Reactome, Software, Transcription, Visualization
License: MIT + file LICENSE
Depends:
R (>= 4.3.0)
R (>= 4.0.0)
Imports:
data.table (>= 1.13.0),
dplyr,
Expand Down
3 changes: 1 addition & 2 deletions R/set-based-enrichment-test.r
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ do_the_simulation <- function(list_of_all_genes, pool, select,DB, steps,
} else { cl <- makeCluster(spec = nthread, type = "PSOCK")}
clusterExport(cl, c("DB","list_of_all_genes", "pool", "select",
"seeds_per_thread", "steps_per_thread"), envir = environment())
clusterEvalQ(cl, c("mulea", "stats", "graphics", "grDevices", "utils",
"datasets","methods","base"))
clusterEvalQ(cl, devtools::load_all())
result_of_paralel <- clusterApplyLB(cl = cl, seq_len(nthread),
function(idx) {simulation_result_tbl <- tryCatch(
enrichment_test_simulation(DB, list_of_all_genes, pool,
Expand Down
75 changes: 0 additions & 75 deletions tests/testthat/testSubramanianTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,78 +34,3 @@ test_that("GSEA : no element_scores vector.", {
testthat::expect_error(muleaTestRes <-
run_test(mulea_ranked_based_test_model))
})

test_that("GSEA : out of ontology elements.", {
set.seed(1)
gmtMock <- data.frame(
ontology_id = "GO:0000001",
ontology_name = "Imagin gen ontology to tests.",
list_of_values = I(list(c("a", "b", "c", "d"))),
stringsAsFactors = FALSE
)
testDataMock <- c("a", "b", "e", "f")
scoreDataMock <- c(0.1, 0.5, 0.7, 1)

mulea_ranked_based_test_model <- gsea(
gmt = gmtMock,
element_names = testDataMock,
element_scores = scoreDataMock)

testthat::expect_warning(muleaTestRes <-
run_test(mulea_ranked_based_test_model))
testthat::expect_equal(muleaTestRes$p_value, 151/495)
})

test_that("GSEA : DB1 + DB2.", {
set.seed(1)
gmtMock1 <- data.frame(
ontology_id = "GO:0000001",
ontology_name = "Imagin gen ontology to tests.",
list_of_values = I(list(c("a", "b", "c", "d"))),
stringsAsFactors = FALSE
)
gmtMock2 <- data.frame(
ontology_id = "GO:0000002",
ontology_name = "Imagin gen ontology to tests.",
list_of_values = I(list(c("e", "f", "g", "h"))),
stringsAsFactors = FALSE
)
gmtMock <- rbind(gmtMock1, gmtMock2)
testDataMock <- c("d", "e", "f")
scoreDataMock <- c(-0.3, 0.4, 0.5)

mulea_ranked_based_test_model <- gsea(
gmt = gmtMock,
element_names = testDataMock,
element_scores = scoreDataMock)

muleaTestRes <- run_test(mulea_ranked_based_test_model)
testthat::expect_equal(muleaTestRes$p_value, c(169 / 330, 107 / 219))
})

test_that("GSEA : DB1 + DB2 out of background_element_names.", {
set.seed(1)
gmtMock1 <- data.frame(
ontology_id = "GO:0000001",
ontology_name = "Imagin gen ontology to tests.",
list_of_values = I(list(c("a", "b", "c", "d"))),
stringsAsFactors = FALSE
)
gmtMock2 <- data.frame(
ontology_id = "GO:0000002",
ontology_name = "Imagin gen ontology to tests.",
list_of_values = I(list(c("e", "f", "c", "d"))),
stringsAsFactors = FALSE
)
gmtMock <- rbind(gmtMock1, gmtMock2)
testDataMock <- c("b", "d", "e", "f")
scoreDataMock <- c(-1, 0, 0, 1)

mulea_ranked_based_test_model <- gsea(
gmt = gmtMock,
element_names = testDataMock,
element_scores = scoreDataMock)

muleaTestRes <- run_test(mulea_ranked_based_test_model)
testthat::expect_equal(muleaTestRes$p_value, c(156 / 653, 251 / 492))
})