From 8cd4b4e2d2507443b128f19052af987cc6eee3ce Mon Sep 17 00:00:00 2001 From: Jieun Kim Date: Fri, 15 Oct 2021 12:58:58 +1100 Subject: [PATCH] edit for BioC resubmission --- DESCRIPTION | 2 +- R/Cepo.R | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2ef1cc5..21744e4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Cepo Title: Cepo for the identification of differentially stable genes -Version: 0.99.3 +Version: 0.99.4 Authors@R: c( person(given = "Hani Jieun", diff --git a/R/Cepo.R b/R/Cepo.R index b8ba753..e28a1a3 100644 --- a/R/Cepo.R +++ b/R/Cepo.R @@ -86,7 +86,7 @@ Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct = ## Select only batches with more than `minCelltype` number of ## cell types - batches = names(which(rowSums(table(block, cellTypes) > minCells) >= + batches <- names(which(rowSums(table(block, cellTypes) > minCells) >= minCelltype)) ## Run Cepo by batch @@ -103,22 +103,22 @@ Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct = return(singleBatch) }) - names(batch_result) = batches + names(batch_result) <- batches - types = unique(unlist(lapply(batch_result, function(x) { - names(x$stats@listData) + types <- unique(unlist(lapply(batch_result, function(x) { + colnames(x$stats) }))) - idx = Reduce(intersect, lapply(batch_result, function(x) { - x$stats@rownames + idx <- Reduce(intersect, lapply(batch_result, function(x) { + rownames(x$stats) })) averageCepo <- lapply(types, function(celltype) { mat <- do.call(cbind, lapply(batch_result, function(x) { - x$stats@listData[[celltype]][idx] + x$stats[idx ,celltype] })) return(rowMeans(mat)) }) - names(averageCepo) = types + names(averageCepo) <- types averageStatsResult <- S4Vectors::DataFrame(sortList(averageCepo)) @@ -130,11 +130,11 @@ Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct = averageCepoPvals <- lapply(types, function(celltype) { mat <- do.call(cbind, lapply(batch_result, function(x) { - x$pvalues@listData[[celltype]][idx] + x$pvalues[idx, celltype] })) return(mat) }) - names(averageCepoPvals) = types + names(averageCepoPvals) <- types averagePvalResult <- S4Vectors::DataFrame(sortList(averageCepoPvals)) averageResult <- list(stats = averageStatsResult, pvalues = averagePvalResult) } @@ -417,7 +417,7 @@ geneStats <- function(Tstat, method = "OSP") { #' # BPPARAM = setCepoBPPARAM(workers = 1))) #' # system.time(BiocParallel::bplapply(1:3, FUN = function(i){Sys.sleep(i)}, #' # BPPARAM = setCepoBPPARAM(workers = 3))) -setCepoBPPARAM = function(workers = 1L, ...) { +setCepoBPPARAM <- function(workers = 1L, ...) { if (workers == 1) { return(BiocParallel::SerialParam()) } else if (.Platform$OS.type == "windows") {