Skip to content
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/bioc-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
extra-packages: |
any::BiocCheck
any::rcmdcheck
stan-dev/cmdstanr

# Setup Python for reticulate (cross-platform)
- name: Setup Python
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
extra-packages: |
any::rcmdcheck
any::covr
stan-dev/cmdstanr
needs: |
website
coverage
Expand Down
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ Suggests:
readr,
RColorBrewer,
quantro,
fgsea
fgsea,
cmdstanr
Additional_repositories: https://stan-dev.r-universe.dev
Remotes: jnpaulson/pandaR
VignetteBuilder: knitr
RoxygenNote: 7.3.3
Expand Down
14 changes: 6 additions & 8 deletions R/TIGER.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ tiger = function(expr,prior,method="VB",TFexpressed = TRUE,
#1. compile stan model, only once
write_stan <- .get_cmdstanr_fun("write_stan_file")
f = write_stan(TIGER_C) # save to .stan file in root folder
#mod = cmdstanr::cmdstan_model(f,cpp_options = list(stan_threads = TRUE)) # compile stan program, allow within-chain parallel
stan_model <- .get_cmdstanr_fun("cmdstan_model")
mod = stan_model(f)

Expand Down Expand Up @@ -203,9 +202,11 @@ tiger = function(expr,prior,method="VB",TFexpressed = TRUE,
if (!requireNamespace("loo", quietly = TRUE)) {
stop("Package 'loo' is required but not installed.")
}
loocv = loo::loo(fit$draws("log_lik",format = "draws_array"),
r_eff=loo::relative_eff(fit$draws("log_lik",format = "draws_array")),
moment_match=TRUE)
loo_fn <- utils::getFromNamespace("loo", "loo")
relative_eff_fn <- utils::getFromNamespace("relative_eff", "loo")
loocv = loo_fn(fit$draws("log_lik",format = "draws_array"),
r_eff=relative_eff_fn(fit$draws("log_lik",format = "draws_array")),
moment_match=TRUE)
print(loocv)
elpd_loo = loocv$pointwise[,"elpd_loo"]
}else{
Expand All @@ -222,10 +223,7 @@ tiger = function(expr,prior,method="VB",TFexpressed = TRUE,
return(tiger_fit)
}

#' This function exists as a workaround for calling packages from cmdstanr without
#' triggering package warnings. We cannot use cmdstanr::function() because cmdstanr
#' is not included in Suggests under the DESCRIPTION file. It cannot be included
#' under Suggests because it is not supported by Bioconductor.
#' Helper to retrieve an exported function from cmdstanr.
#' @keywords internal
.get_cmdstanr_fun <- function(fun) {
pkg <- "cmdstanr"
Expand Down
15 changes: 0 additions & 15 deletions R/YARN.R
Original file line number Diff line number Diff line change
Expand Up @@ -760,18 +760,3 @@ qstats <- function(exprs, groups, window) {
#' pp.648-660.
#'
NULL

#' Skin dataset
#'
#' Skin RNA-seq data from the GTEx consortium. V6 release.
#' @docType data
#' @keywords datasets
#' @name skin
#' @usage data(skin)
#' @format An object of class "ExpressionSet".
#' @return An object of class "ExpressionSet".
#' @references GTEx Consortium, 2015. The Genotype-Tissue Expression (GTEx)
#' pilot analysis: Multitissue gene regulation in humans. Science, 348(6235),
#' pp.648-660.
#'
NULL
24 changes: 0 additions & 24 deletions man/skin.Rd

This file was deleted.

1 change: 1 addition & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if (!identical(Sys.getenv("NETZOOR_SKIP_DOWNLOADS"), "true")) {
download_if_missing('https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/dragon/dragon_python_prec.csv', 'dragon_python_prec.csv')
download_if_missing('https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/dragon/dragon_python_parcor.csv', 'dragon_python_parcor.csv')
download_if_missing('https://netzoo.s3.us-east-2.amazonaws.com/netZooR/example_datasets/dragon/risk_grid_netzoopy.csv', 'risk_grid_netzoopy.csv')
download_if_missing('https://netzoo.s3.us-east-2.amazonaws.com/netZooR/unittest_datasets/yarn/skin.rdata', 'skin.rdata')
}

test_check("netZooR")
9 changes: 7 additions & 2 deletions tests/testthat/test-tiger.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,18 @@ test_that("adj2regulon() creates valid regulon from adjacency", {

test_that("priorPp() filters inconsistent edges", {
skip_if_not_installed("GeneNet")
# Skip: corpcor::cor.shrink() has a latent C-level heap corruption bug
# that causes SIGABRT on CI runners. The crash is non-deterministic and
# depends on memory layout at package load time. See netZoo/netZooR#383.
skip("corpcor C-level crash in cor.shrink (netZoo/netZooR#383)")
set.seed(42)
tfs <- paste0("TF", 1:3)
genes <- paste0("G", 1:5)
prior <- matrix(sample(c(-1, 0, 1), 15, replace = TRUE), nrow = 3,
dimnames = list(tfs, genes))
expr <- matrix(rnorm(80), nrow = 8,
dimnames = list(c(tfs, genes), paste0("S", 1:10)))
n_samples <- 50L
expr <- matrix(rnorm(8 * n_samples), nrow = 8,
dimnames = list(c(tfs, genes), paste0("S", seq_len(n_samples))))

result <- priorPp(prior, expr)

Expand Down
70 changes: 70 additions & 0 deletions tests/testthat/test-yarn.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,73 @@ test_that("checkMisAnnotation() returns coordinates without error", {
controlGenes = "all", plotFlag = FALSE)
expect_true(!is.null(result))
})

# ---- Tests using the skin dataset (downloaded at test runtime) ----

# Helper to load the skin dataset from the downloaded file
load_skin <- function() {
skin_path <- file.path("skin.rdata")
if (!file.exists(skin_path)) skip("skin.rdata not available (download failed)")
env <- new.env(parent = emptyenv())
load(skin_path, envir = env)
env$skin
}

test_that("skin dataset loads and is an ExpressionSet", {
skin <- load_skin()
expect_s4_class(skin, "ExpressionSet")
expect_true(nrow(skin) > 0)
expect_true(ncol(skin) > 0)
})

test_that("checkTissuesToMerge() works on skin data", {
skin <- load_skin()
result <- checkTissuesToMerge(skin, "SMTS", "SMTSD", plotFlag = FALSE)
expect_true(!is.null(result))
})

test_that("filterGenes() works on skin data", {
skin <- load_skin()
filtered <- filterGenes(skin, labels = c("X", "Y", "MT"),
featureName = "chromosome_name")
remaining <- Biobase::fData(filtered)[, "chromosome_name"]
expect_true(!any(remaining %in% c("X", "Y", "MT")))
})

test_that("filterLowGenes() works on skin data", {
skip_if_not_installed("edgeR")
skin <- load_skin()
filtered <- filterLowGenes(skin, "SMTSD")
expect_true(nrow(filtered) <= nrow(skin))
})

test_that("filterMissingGenes() works on skin data", {
skin <- load_skin()
filtered <- filterMissingGenes(skin)
expect_s4_class(filtered, "ExpressionSet")
})

test_that("filterSamples() works on skin data", {
skin <- load_skin()
filtered <- filterSamples(skin, ids = "Skin - Not Sun Exposed (Suprapubic)",
groups = "SMTSD")
remaining <- Biobase::pData(filtered)[, "SMTSD"]
expect_true(!any(remaining == "Skin - Not Sun Exposed (Suprapubic)"))
})

test_that("plotCMDS() works on skin data", {
skin <- load_skin()
coords <- plotCMDS(skin, comp = 1:2, plotFlag = FALSE)
expect_true(is.matrix(coords) || is.data.frame(coords))
expect_equal(ncol(coords), 2)
})

test_that("normalizeTissueAware() works on skin data", {
skip_if_not_installed("preprocessCore")
skin <- load_skin()
# Use a small subset for speed
skinSub <- skin[1:100, ]
normalized <- normalizeTissueAware(skinSub, "SMTSD",
normalizationMethod = "quantile")
expect_s4_class(normalized, "ExpressionSet")
})
Loading