@@ -86,7 +86,7 @@ Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct =
8686
8787 # # Select only batches with more than `minCelltype` number of
8888 # # cell types
89- batches = names(which(rowSums(table(block , cellTypes ) > minCells ) > =
89+ batches <- names(which(rowSums(table(block , cellTypes ) > minCells ) > =
9090 minCelltype ))
9191
9292 # # Run Cepo by batch
@@ -103,22 +103,22 @@ Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct =
103103 return (singleBatch )
104104
105105 })
106- names(batch_result ) = batches
106+ names(batch_result ) <- batches
107107
108- types = unique(unlist(lapply(batch_result , function (x ) {
109- names (x $ stats @ listData )
108+ types <- unique(unlist(lapply(batch_result , function (x ) {
109+ colnames (x $ stats )
110110 })))
111- idx = Reduce(intersect , lapply(batch_result , function (x ) {
112- x $ stats @ rownames
111+ idx <- Reduce(intersect , lapply(batch_result , function (x ) {
112+ rownames( x $ stats )
113113 }))
114114
115115 averageCepo <- lapply(types , function (celltype ) {
116116 mat <- do.call(cbind , lapply(batch_result , function (x ) {
117- x $ stats @ listData [[ celltype ]][ idx ]
117+ x $ stats [ idx , celltype ]
118118 }))
119119 return (rowMeans(mat ))
120120 })
121- names(averageCepo ) = types
121+ names(averageCepo ) <- types
122122 averageStatsResult <- S4Vectors :: DataFrame(sortList(averageCepo ))
123123
124124
@@ -130,11 +130,11 @@ Cepo <- function(exprsMat, cellTypes, minCells = 20, minCelltype = 3, exprsPct =
130130
131131 averageCepoPvals <- lapply(types , function (celltype ) {
132132 mat <- do.call(cbind , lapply(batch_result , function (x ) {
133- x $ pvalues @ listData [[ celltype ]][ idx ]
133+ x $ pvalues [ idx , celltype ]
134134 }))
135135 return (mat )
136136 })
137- names(averageCepoPvals ) = types
137+ names(averageCepoPvals ) <- types
138138 averagePvalResult <- S4Vectors :: DataFrame(sortList(averageCepoPvals ))
139139 averageResult <- list (stats = averageStatsResult , pvalues = averagePvalResult )
140140 }
@@ -417,7 +417,7 @@ geneStats <- function(Tstat, method = "OSP") {
417417# ' # BPPARAM = setCepoBPPARAM(workers = 1)))
418418# ' # system.time(BiocParallel::bplapply(1:3, FUN = function(i){Sys.sleep(i)},
419419# ' # BPPARAM = setCepoBPPARAM(workers = 3)))
420- setCepoBPPARAM = function (workers = 1L , ... ) {
420+ setCepoBPPARAM <- function (workers = 1L , ... ) {
421421 if (workers == 1 ) {
422422 return (BiocParallel :: SerialParam())
423423 } else if (.Platform $ OS.type == " windows" ) {
0 commit comments