Skip to content
Open
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
9 changes: 4 additions & 5 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
## Ignore build and temp file
^\.travis\.yml$
^figure*
^figure$
^vignettes/figure$
^.README\.*
^inst/.README\.*
^README\.Rmd$
^inst/extdata\.*
^inst/TUTORIAL*
^LICENSE\.md$
^\.github$
^codecov\.yml$
^doc$
^Meta$
..Rcheck
^vignette_cache$
^\.bumpversion\.cfg$
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.99.0
current_version = 1.99.5
commit = True
tag = True
tag_name = v{new_version}
Expand All @@ -10,7 +10,7 @@ search = Version: {current_version}
replace = Version: {new_version}

[bumpversion:file:NEWS.md]
search = ## Changes in version {current_version}
search = ## Unreleased changes
replace = ## Changes in version {new_version}

[bumpversion:file:vignettes/SpiecEasi.Rmd]
Expand Down
43 changes: 42 additions & 1 deletion .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ jobs:
key: ${{ matrix.config.os }}-${{ matrix.config.r }}-biocmanager-${{ env.cache-version }}
restore-keys: ${{ matrix.config.os }}-${{ matrix.config.r }}-biocmanager-

## Cache individual vignette builds to speed up builds
- name: Cache vignette builds
uses: actions/cache@v4
with:
path: |
vignettes/SpiecEasi.RData
vignettes/phyloseq-integration.RData
vignettes/cross-domain-interactions.RData
vignettes/latent-variable-models.RData
vignettes/pulsar-parallel.RData
vignettes/troubleshooting.RData
key: ${{ matrix.config.os }}-${{ matrix.config.r }}-vignettes-${{ env.cache-version }}-${{ hashFiles('vignettes/*.Rmd') }}
restore-keys: ${{ matrix.config.os }}-${{ matrix.config.r }}-vignettes-${{ env.cache-version }}-

## remotes is needed for isntalling the Linux system dependencies
## as well as other R packages later on.
- name: Install remotes
Expand Down Expand Up @@ -244,7 +258,34 @@ jobs:
run: |
## 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, force = TRUE)
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = FALSE, upgrade = TRUE, force = TRUE)
shell: Rscript {0}

- name: Build vignettes with caching
env:
FORCE_VIGNETTE_REBUILD: ${{ github.event.head_commit.message && contains(github.event.head_commit.message, '/rebuild-vignettes') || 'FALSE' }}
run: |
## Build vignettes separately to enable caching
message(paste('****', Sys.time(), 'building vignettes with caching ****'))
message(paste('FORCE_VIGNETTE_REBUILD:', Sys.getenv("FORCE_VIGNETTE_REBUILD")))

## Load individual vignette cache files if they exist
vignette_caches <- c("SpiecEasi.RData", "phyloseq-integration.RData",
"cross-domain-interactions.RData", "latent-variable-models.RData",
"pulsar-parallel.RData", "troubleshooting.RData")

for (cache_file in vignette_caches) {
cache_path <- file.path("vignettes", cache_file)
if (file.exists(cache_path)) {
message(paste("Loading cached data from", cache_file))
# Load into global environment so vignettes can access the data
load(cache_path, envir = .GlobalEnv)
} else {
message(paste("No cache found for", cache_file, "- will build from scratch"))
}
}

tools::buildVignettes(dir = ".", tangle = TRUE)
shell: Rscript {0}

- name: Install BiocGenerics
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ README_files/*
/Meta/
SpiecEasi.BiocCheck/*
check/*
#vignette_cache/
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SpiecEasi
Title: Sparse Inverse Covariance for Ecological Statistical Inference
Version: 1.99.0
Date: 2025-05-13
Version: 2.0.0
Date: 2026-03-19
Authors@R: c(
person("Zachary", "Kurtz", role = c("aut", "cre"), email="zdkurtz@gmail.com"),
person("Christian", "Mueller", role = "aut"),
Expand All @@ -11,7 +11,7 @@ Authors@R: c(
Description: Estimate networks from the precision matrix of compositional microbial abundance data.
License: GPL (>= 3)
URL: https://github.com/zdk123/SpiecEasi
BugReports: https://github.com/zdk123/SpiecEasi//issues/
BugReports: https://github.com/zdk123/SpiecEasi/issues
biocViews: Software, Microbiome, Metagenomics, GraphAndNetwork, NetworkInference
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
48 changes: 43 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
# SpiecEasi NEWS

## Changes in version 1.99.0
## Changes in version 1.99.5

### BUG FIXES

* Fixed vignette rebuild error with pulsar >= 0.3.13: resolve the estimation function before passing to `pulsar()` - this avoids lazy `match.fun` evaluation that fails on PSOCK cluster workers.

### INFRASTRUCTURE

* Removed obsolete `CXX_STD = CXX11` from `src/Makevars` (R >= 4.6 defaults to C++20)
* Fixed `.Rbuildignore` to exclude leftover `vignettes/figure` directory from knitr

## Changes in version 1.99.4

### BUG FIXES

* Fixed vignette build failure caused by `makeCluster(4, type = "SOCK")` requiring unavailable `snow` package
* Replaced broken snow cluster example with reference to `batch.pulsar` with `conffile='snow'`
* Set batch mode vignette chunks to `eval=FALSE` to avoid build failures on systems without `batchtools` infrastructure

## Changes in version 1.99.3

### BUG FIXES

* Fixed BugReports URL in DESCRIPTION (removed double slash)
* Replaced sapply with vapply in R/fitdistr.R for improved type stability
* Fixed incomplete final line in .Rbuildignore file

### IMPROVEMENTS

* Added BiocManager installation instructions to main vignette
* Added runnable examples to man pages for getOptInd, robustPCA, stars.roc, and triu functions
* Cleaned up promotional language in NEWS entries
* Removed unused inst/extdata files to reduce package size

### INFRASTRUCTURE

* Added .registration = TRUE to useDynLib in NAMESPACE
* Updated package version to 0.99.2 for Bioconductor submission
* Verified vignette runtime compliance with Bioconductor guidelines

## Changes in version 1.99.2

### NEW FEATURES

* Added comprehensive Bioconductor package infrastructure and compliance
* Added comprehensive Bioconductor package infrastructure
* Added automated GitHub Actions workflow for Bioconductor continuous integration
* Added test coverage reporting and automated testing
* Added Bioconductor-style vignettes and documentation
- Package now fully compliant with Bioconductor standards and guidelines
- Added biocViews categorization: Software, Microbiome, Metagenomics, GraphAndNetwork, NetworkInference
- Added comprehensive support documentation and issue templates
- Implemented proper code of conduct and contribution guidelines
Expand All @@ -23,8 +62,7 @@

### BUG FIXES

* Package now passes all Bioconductor validation checks
* Resolved any compliance issues identified during BiocCheck
* Resolved compliance issues identified during BiocCheck
* Enhanced error handling and package robustness

## Changes in version 1.1.3
Expand Down
1 change: 1 addition & 0 deletions R/SparseICov.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ sparseiCov <- function(data, method, npn=FALSE, verbose=FALSE, cov.output = TRUE
#' @param ncores number of cores for distributing the model fitting
#' @param sym symmetrize the neighborhood using the 'or' (default)/'and' rule
#' @param ... further arguments to glmnet
#' @return A sparse inverse covariance matrix estimated using neighborhood selection
#' @importFrom Matrix t
#' @export
#' @examples
Expand Down
188 changes: 7 additions & 181 deletions R/SparseLowRankICov.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ admm2 <- function(SigmaO, lambda, beta, r, tol=1e-2, shrinkDiag=TRUE, opts) {
#' @param L the p x p rank-r ('residual') inverse covariance matrix from \code{spiec.easi} run argument method='slr'.
#' @param inverse flag to indicate the L is the inverse covariance matrix
#' @returns a named list with n x r matrix of scores and r x r matrix of loadings
#' @examples
#' # Create sample data
#' data(amgut1.filt)
#' data.clr <- t(clr(t(amgut1.filt), 1))
#' # Perform robust PCA
#' pca_result <- robustPCA(data.clr, diag(ncol(data.clr)))
#' @export
robustPCA <- function(X, L, inverse=TRUE) {
Lsvd <- svd(L)
Expand All @@ -143,184 +149,4 @@ robustPCA <- function(X, L, inverse=TRUE) {

scores <- X %*% t(loadings)
return(list(scores=scores, loadings=loadings))
}
# #' @importFrom Matrix sparseMatrix forceSymmetric
# admm <- function(SigmaO, lambda, beta, r, LPD=FALSE, eigsolve=FALSE, tol=1e-5, shrinkDiag=TRUE, opts) {
# n <- nrow(SigmaO)
# defopts <- list(mu=n, eta=99/100, muf=1e-4, maxiter=500, newtol=1e-4)
# if (!missing(opts)) for (o in names(opts)) defopts[[ o ]] <- opts [[ o ]]
# opts <- defopts
# ABSTOL <- tol
# RELTOL <- tol
# over_relax_par <- 1.6
# Ip <- sparseDiag(n)
# Id <- diag(n)
# J <- matrix(1/n, n, n)
# R <- S <- Ip
# L <- zeros(n,n)
# RY <- Id; SY <- Id; LY <- L
# Y <- cbind(RY, SY, LY)
# Lambda1 <- zeros(ncol(R)); Lambda2 <- Lambda1; Lambda3 <- Lambda1
# mu <- opts$mu
# eta <- opts$eta
# objval <- vector('numeric', opts$maxiter)
# r_norm <- vector('numeric', opts$maxiter)
# # s_norm <- vector('numeric', opts$maxiter)
# eps_pri <- vector('numeric', opts$maxiter)
# # eps_dual <- vector('numeric', opts$maxiter)
# for (iter in 1:opts$maxiter) {
# ## update X = (R,S,L)
# RA <- RY + mu*Lambda1
# SA <- SY + mu*Lambda2
# LA <- LY + mu*Lambda3
# if (eigsolve) {
# tmp <- mu*SigmaO-RA
# tmp <- (tmp+t(tmp))/2
# eV <- eigen(tmp) ; U <- eV$vectors ; D <- eV$values ; d = sparseDiag(D)
# eigR <- (-d + sqrt(d^2+4*mu))/2
# R <- U%*%sparseDiag(Matrix::diag(eigR))%*%t(U)
# R <- (R+t(R))/2
# } else {
# K <- mu*SigmaO - RA
# KI <- sqrtmNewt(as(K %*% K, 'matrix') + 4*mu*Id, Id, errTol=opts$newtol)
# R <- MATAVE2(KI, as.matrix(-K)) #.5*(KI-K)
# }
# S <- SOFTTHRESH(as(SA, 'matrix'), lambda*mu, shrinkDiag=shrinkDiag)
# # S <- forceSymmetric(S)
# # LA <- forceSymmetric(LA)
# if (LPD) {
# # if (iter>1) {
# eV <- eigen(LA) ; U <- Re(eV$vectors) ; d <- Re(eV$values)
# if (missing(beta))
# beta <- d[r+1]/mu #*1.01
# eigL <- sparseDiag(pmax(d-mu*beta,0))
# L <- U %*% eigL %*% t(U)
# L <- as(forceSymmetric(L), 'sparseMatrix')
# # } else L <- LA
# } else {
# if (iter==1) {
# L <- LA
# } else {
# if (missing(beta)) {
# tmp <- softSVT(as(LA, 'matrix'), k=r)
# # beta <- tmp$tau/mu
# L <- tmp$M
# } else {
# tmp <- softSVT(as(LA, 'matrix'), tau=mu*beta)
# L <- tmp$M
# }
# }
# }
# X <- cbind(R, S, L)
# RO <- over_relax_par*R + (1-over_relax_par)*RY
# SO <- over_relax_par*S + (1-over_relax_par)*SY
# LO <- over_relax_par*L + (1-over_relax_par)*LY
# ## update Y = (RY,SY,LY)
# Y_old <- Y
# RA <- RO - mu*Lambda1
# SA <- SO - mu*Lambda2
# LA <- LO - mu*Lambda3
# TA <- (RA-SA+LA)/3
# RY <- RA - TA ; SY <- SA + TA ; LY <- LA - TA
#
# ## update Lambda
# Lambda1 <- (Lambda1 - (RO-RY)/mu); # Lambda1 = forceSymmetric(Lambda1)
# Lambda2 <- (Lambda2 - (SO-SY)/mu); #Lambda2 = forceSymmetric(Lambda2)
# Lambda3 <- (Lambda3 - (LO-LY)/mu); #Lambda3 = forceSymmetric(Lambda3)
# Lambda <- cbind(Lambda1, Lambda2, Lambda3)
#
# Y <- cbind(RY, SY, LY)
# ## diagnostics, reporting, termination checks
# # k = iter
# # objval[iter] = objective(R,SigmaO,eigR,S,eigL,lambda,beta);
#
# r_norm[iter] <- Matrix::norm(X - Y, 'F')
# # s_norm[iter] = max(svd(-(Y - Y_old)/mu, nu=0, nv=0)$d)
# eps_pri[iter] <- sqrt(3*n*n)*ABSTOL +
# RELTOL*max(Matrix::norm(X,'F'), Matrix::norm(Y,'F'))
# # eps_dual[iter]= sqrt(3*n*n)*ABSTOL + RELTOL*Matrix::norm(Lambda,'F')
# # print(r_norm[iter] - eps_pri[iter])
# if (r_norm[iter] < eps_pri[iter]) # & s_norm[k] < eps_dual[k])
# break
# ## TODO: make this optional
# mu <- max(mu*eta, opts$muf)
# }
#
# history <- list(objval=objval, r_norm=r_norm,eps_pri=eps_pri)
# # eigR = eigR, eigL = eigL,
# list(R=R, S = S, L = L, RA=RA, LA=LA, SA=SA, mu=mu, obj = objval[iter], iter = iter, history=history)
# }
#
# zeros <- function(n, p=n, sparse=TRUE) {
# if (!sparse)
# matrix(0, nrow=n, ncol=p)
# else
# Matrix::sparseMatrix(i=NULL, j=NULL, dims=c(n,p), symmetric=TRUE)
# }
#
# sparseDiag <- function(x) {
# if (length(x) == 1 && as.integer(x) == x) {
# M <- zeros(x, sparse=TRUE)
# diag(M) <- 1
# } else {
# M <- zeros(length(x), sparse=TRUE)
# diag(M) <- x
# }
# as(M, 'dsCMatrix')
# }
#
#
# .sqrtNewton <- function(C, sqrtC0=diag(ncol(C)), errTol=5e-1) {
# # compute square root of symmetric matrix C
# # init
# n <- ncol(C)
# X <- sqrtC0
# err <- Inf
# while (err > errTol) {
# X_new <- .5*(X + Matrix::solve(X, C)) #.5*sqrt(mu)*Id)))
# err <- Matrix::norm(X_new - X, 'F')
# X <- X_new
# }
# X
# }
#
#
# objective <- function(R,SigmaO,eigR,S,eigL,lambda,beta) {
# sum(sum(R*SigmaO)) - sum(log(eigR)) + lambda*sum(abs(S)) + beta*sum(eigL)
# }
#
#
# hardsvdthresh <- function(M, tau, k=ncol(M)) {
# Msvd <- svdPow(M, min(ncol(M), k+1), k+2)
# # Msvd <- svd(M)
# if (k < ncol(M))
# tau <- Msvd$d[k+1]*1.01 #min(tau, Msvd$d[k+1])
# ind <- which(Msvd$d - tau > 0)
# tmpd <- sparseDiag(Msvd$d[ind])
# M <- Msvd$u[,ind,drop=FALSE] %*% tmpd %*% t(Msvd$v[,ind,drop=FALSE])
# return(list(M=M, tau=tau, d=tmpd))
# }
#
#
# svdPow <- function(A, k, q) {
# l <- k
# m <- nrow(A)
# n <- ncol(A)
# P <- matrix(rnorm(m*l), nrow=m, ncol=l)
# QR <- qr(t(t(P)%*%A))
# Q <- qr.Q(QR)
# R <- qr.R(QR)
# # return(list(Q=Q, R=R))
# for (j in 1:q) {
# PR <- qr(A%*%Q)
# P <- qr.Q(PR)
# R <- qr.R(PR)
# QR <- qr(t(t(P)%*%A))
# Q <- qr.Q(QR)
# R <- qr.R(QR)
# }
# Asvd <- svd(A%*%Q)
# list(u=Asvd$u, #[,1:k,drop=FALSE],
# d=Asvd$d, #[1:k,drop=FALSE],
# v=(Q%*%Asvd$v), P=P, Q=Q) #[,1:k,drop=FALSE])
# }
}
Loading
Loading