Closed tallulandrews closed 4 years ago
`collapsePathways <- function(fgseaRes, pathways, stats, pval.threshold=0.05, nperm=10/pval.threshold, gseaParam=1) { universe <- names(stats)
pathways <- pathways[fgseaRes$pathway]
pathways <- lapply(pathways, intersect, universe)
parentPathways <- setNames(rep(NA, length(pathways)), names(pathways))
for (i in seq_along(pathways)) {
p <- names(pathways)[i]
if (!is.na(parentPathways[p])) {
next
}
pathwaysToCheck <- setdiff(names(which(is.na(parentPathways))), p)
pathwaysUp <- fgseaRes[pathway %fin% pathwaysToCheck & ES >= 0][, pathway] #### This line and
pathwaysDown <- fgseaRes[pathway %fin% pathwaysToCheck & ES < 0][, pathway] #### This line use "pathway" that is not defined
if (length(pathwaysToCheck) == 0) {
break
}
minPval <- setNames(rep(1, length(pathwaysToCheck)), pathwaysToCheck)
u1 <- setdiff(universe, pathways[[p]])
fgseaResUp1 <- fgseaSimple(pathways = pathways[pathwaysUp], stats=stats[u1],
nperm=nperm, maxSize=length(u1)-1, nproc=1,
gseaParam=gseaParam, scoreType = "pos")
fgseaResDown1 <- fgseaSimple(pathways = pathways[pathwaysDown], stats=stats[u1],
nperm=nperm, maxSize=length(u1)-1, nproc=1,
gseaParam=gseaParam, scoreType = "neg")
fgseaRes1 <- rbindlist(list(fgseaResUp1, fgseaResDown1), use.names = TRUE)
minPval[fgseaRes1$pathway] <- pmin(minPval[fgseaRes1$pathway], fgseaRes1$pval)
u2 <- pathways[[p]]
fgseaResUp2 <- fgseaSimple(pathways = pathways[pathwaysUp], stats=stats[u2],
nperm=nperm, maxSize=length(u2)-1, nproc=1,
gseaParam=gseaParam, scoreType = "pos")
fgseaResDown2 <- fgseaSimple(pathways = pathways[pathwaysDown], stats=stats[u2],
nperm=nperm, maxSize=length(u2)-1, nproc=1,
gseaParam=gseaParam, scoreType = "neg")
fgseaRes2 <- rbindlist(list(fgseaResUp2, fgseaResDown2), use.names = TRUE)
minPval[fgseaRes2$pathway] <- pmin(minPval[fgseaRes2$pathway], fgseaRes2$pval)
parentPathways[names(which(minPval > pval.threshold))] <- p
}
return(list(mainPathways=names(which(is.na(parentPathways))),
parentPathways=parentPathways))
} `
No, this is not a typo, it takes pathway
column from fgseaRes
, which is a data.table
object.
Please, post an actual error that you get, with a reproducible example, if possible.
There is a typo or something in the collapsePathways function as it uses a variable called "pathway" that is not defined anywhere in the function. This seems to have appeared sometime between the current version and version 1.8.1 as my computer with the older version runs just fine.
Best, Tallulah