... | ... |
@@ -1194,6 +1194,18 @@ getDetails <- function(analysis, collection) |
1194 | 1194 |
} |
1195 | 1195 |
|
1196 | 1196 |
|
1197 |
+.loadPerts <- function(rp, coll) { |
|
1198 |
+ return(colnames(rp$get(coll)$ES)) |
|
1199 |
+} |
|
1200 |
+ |
|
1201 |
+.loadPEPs <- function(rp, coll, subset) { |
|
1202 |
+ peps <- list( |
|
1203 |
+ ES = rp$get(coll)$ES[, subset, drop=F], |
|
1204 |
+ PV = rp$get(coll)$PV[, subset, drop=F] |
|
1205 |
+ ) |
|
1206 |
+ return(peps) |
|
1207 |
+} |
|
1208 |
+ |
|
1197 | 1209 |
|
1198 | 1210 |
#' Performs Condition Set Enrichment Analysis |
1199 | 1211 |
#' |
... | ... |
@@ -1276,10 +1288,10 @@ CondSEA <- function(rp_peps, pgset, bgset="all", collections="all", |
1276 | 1288 |
for(i in seq_along(dbs)) { |
1277 | 1289 |
say(paste0("Working on collection: ", dbs[i])) |
1278 | 1290 |
|
1279 |
- peps <- rp_peps$get(dbs[i]) |
|
1291 |
+ allperts <- .loadPerts(rp, dbs[i]) |
|
1280 | 1292 |
|
1281 | 1293 |
if(length(bgset) == 1 && bgset=="all") |
1282 |
- bgset <- colnames(peps[[1]]) |
|
1294 |
+ bgset <- allperts |
|
1283 | 1295 |
|
1284 | 1296 |
if(length(intersect(pgset, bgset))>0) { |
1285 | 1297 |
bgset <- setdiff(bgset, pgset) |
... | ... |
@@ -1288,14 +1300,15 @@ CondSEA <- function(rp_peps, pgset, bgset="all", collections="all", |
1288 | 1300 |
|
1289 | 1301 |
rankingset <- c(bgset, pgset) |
1290 | 1302 |
|
1291 |
- if(!all(rankingset %in% colnames(peps$ES))) |
|
1303 |
+ if(!all(rankingset %in% allperts)) |
|
1292 | 1304 |
say(paste("The following conditions could not be found:", |
1293 | 1305 |
paste( |
1294 | 1306 |
setdiff(rankingset, colnames(peps$ES)), |
1295 | 1307 |
collapse = ", ")), "error") |
1296 |
- |
|
1308 |
+ |
|
1309 |
+ peps <- .loadPEPs(rp_peps, dbs[i], rankingset) |
|
1297 | 1310 |
say(paste0("Row-ranking collection")) |
1298 |
- ranked <- rankPEPsByRows(peps, rankingset) |
|
1311 |
+ ranked <- rankPEPsByRows(peps) |
|
1299 | 1312 |
say(paste0("Computing enrichments")) |
1300 | 1313 |
|
1301 | 1314 |
ks <- apply(ranked, 1, function(row) { |
... | ... |
@@ -1458,7 +1471,7 @@ PathSEA <- function(rp_peps, pathways, bgsets="all", collections="all", |
1458 | 1471 |
say("Common pathway sets removed from bgset") |
1459 | 1472 |
} |
1460 | 1473 |
rankingset <- c(gmd, bgset) |
1461 |
- peps <- rp_peps$get(collections[i]) |
|
1474 |
+ peps <- .loadPEPs(rp_peps$get, collections[i]) |
|
1462 | 1475 |
notok <- rankingset[rankingset %in% rownames(peps)] |
1463 | 1476 |
if(length(notok)>0) |
1464 | 1477 |
say(paste0("Pathway set ids not found in ", collections[i], ": ", |
... | ... |
@@ -1733,12 +1746,9 @@ rankPEPsByCols <- function(peps, rankingset="all") |
1733 | 1746 |
} |
1734 | 1747 |
|
1735 | 1748 |
|
1736 |
-rankPEPsByRows <- function(peps, rankingset="all") |
|
1749 |
+rankPEPsByRows <- function(peps) |
|
1737 | 1750 |
{ |
1738 |
- if(length(rankingset) == 1 && rankingset == "all") |
|
1739 |
- rankingset <- seq_len(ncol(peps[["ES"]])) |
|
1740 |
- |
|
1741 |
- ESs <- peps[["ES"]][, rankingset, drop=FALSE] |
|
1751 |
+ ESs <- peps[["ES"]] |
|
1742 | 1752 |
x <- t(apply(-ESs, 1, rank, ties.method = "random", na.last="keep")) |
1743 | 1753 |
return(x) |
1744 | 1754 |
} |
... | ... |
@@ -1906,3 +1916,9 @@ convertFromGSetClass <- function(gsets) { |
1906 | 1916 |
db_ids <- paste(dbs, subdbs, sep="_") |
1907 | 1917 |
return(db_ids) |
1908 | 1918 |
} |
1919 |
+ |
|
1920 |
+.extractWorkingPEPs <- function(rp, coll, fgset, bgset) { |
|
1921 |
+ ishdf5 <- "#rhdf5" %in% rp$tags(coll) |
|
1922 |
+ |
|
1923 |
+ |
|
1924 |
+} |
... | ... |
@@ -135,6 +135,8 @@ oldpep2 <- rp$get(colls[2]) |
135 | 135 |
rp$rm(tags="pep", force=T) |
136 | 136 |
importFromRawMode(rp) |
137 | 137 |
|
138 |
+library(DelayedArray) |
|
139 |
+ |
|
138 | 140 |
pep2 <- list(ES=h5read(rp$get(colls[2]), "ES"), |
139 | 141 |
PV=h5read(rp$get(colls[2]), "PV")) |
140 | 142 |
rownames(pep2$ES) <- rownames(pep2$PV) <- h5read(rp$get(colls[2]), "rownames") |
... | ... |
@@ -330,12 +332,10 @@ name3 <- colnames(testgep)[randj3] |
330 | 332 |
test_that("PathSEA", { |
331 | 333 |
expect_equal(getDetails(res, "c3_TFT"), res$details[["c3_TFT"]]) |
332 | 334 |
expect_equal(getResults(res, "c3_TFT"), res$PathSEA[["c3_TFT"]]) |
333 |
- |
|
334 | 335 |
expect_equal(unname(res[["PathSEA"]][[db1]][name1, "ES"]), |
335 | 336 |
ks1$ES) |
336 | 337 |
expect_equal(unname(res[["PathSEA"]][[db1]][name1, "PV"]), |
337 | 338 |
ks1$p.value) |
338 |
- |
|
339 | 339 |
expect_equal(unname(res[["PathSEA"]][[db3]][name3, "ES"]), |
340 | 340 |
ks3$ES) |
341 | 341 |
expect_equal(unname(res[["PathSEA"]][[db3]][name3, "PV"]), |