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

fix RUV error on Lxgn data #190

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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: 6 additions & 3 deletions R/pgx-correct.R
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,9 @@ svaCorrect <- function(X, y) {
# pp <- paste0(model.par, collapse = "+")
# lm.expr <- paste0("lm(t(X) ~ ", pp, ", data=pheno)")
X.r <- t(stats::resid(lm(t(X) ~ y)))
n.sv <- isva::EstDimRMT(X.r, FALSE)$dim + 1
##n.sv <- isva::EstDimRMT(X.r, FALSE)$dim + 1
n.sv <- isva::EstDimRMT(X.r, FALSE)$dim
n.sv
## top 1000 genes only (faster)
X1 <- Matrix::head(X[order(-matrixStats::rowSds(X, na.rm = TRUE)), ], 1000)
## add a little bit of noise to avoid singular error
Expand Down Expand Up @@ -2071,10 +2073,11 @@ ruvCorrect <- function(X, y, k = NULL, type = c("III", "g"), controls = 0.10) {
if (any(is.na(X))) {
stop("[ruvCorrect] cannot handle missing values in X.")
}

sdx <- matrixStats::rowSds(X,na.rm=TRUE)

## F-test using limma just variables
if (!is.null(y) && length(controls) == 1 && is.numeric(controls[1])) {
ii <- which(!duplicated(rownames(X)))
ii <- which(!duplicated(rownames(X)) & sdx > 0)
jj <- which(!is.na(y))
F <- gx.limmaF(X[ii, jj], y[jj], lfc = 0, fdr = 1, method = 1, sort.by = "none", compute.means = FALSE, verbose = 0)
nc <- pmax(nrow(X) * as.numeric(controls), 1)
Expand Down
Loading