Skip to content

Commit

Permalink
Merge pull request #61 from huerqiang/readable
Browse files Browse the repository at this point in the history
Enable `setReadable` for compareCluster(GSEA algorithm) result
  • Loading branch information
GuangchuangYu authored Dec 14, 2021
2 parents 751ca5f + 0521e74 commit 5ce906f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: DOSE
Type: Package
Title: Disease Ontology Semantic and Enrichment analysis
Version: 3.21.1.9001
Version: 3.21.1.9002
Authors@R: c( person(given = "Guangchuang", family = "Yu", email = "[email protected]", role = c("aut", "cre")),
person(given = "Li-Gen", family = "Wang", email = "[email protected]", role = "ctb"),
person(given = "Vladislav", family = "Petyuk", email = "[email protected]", role = "ctb"),
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# DOSE 3.21.1.9001
# DOSE 3.21.1.9002

+ enable `setReadable` for compareCluster(GSEA algorithm) result(2021-12-13, Mon)
+ update the default order of GSEA result (2021-12-09, Thu)
- if p.adjust is identical, sorted by `abs(NES)`

Expand Down
25 changes: 17 additions & 8 deletions R/accessor.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,23 @@ geneInCategory.compareClusterResult <- function(x) {
## return(list_new)



reslist <- split(x@compareClusterResult, x@compareClusterResult$Cluster)

res <- lapply(reslist, function(y)
setNames(
strsplit(y$geneID, split="/", fixed=TRUE),
y$ID
))
x <- as.data.frame(x)
# reslist <- split(x@compareClusterResult, x@compareClusterResult$Cluster)
reslist <- split(x, x$Cluster)
if ("core_enrichment" %in% colnames(x)) {
res <- lapply(reslist, function(y)
setNames(
strsplit(y$core_enrichment, split="/", fixed=TRUE),
y$ID
))
} else {
res <- lapply(reslist, function(y)
setNames(
strsplit(y$geneID, split="/", fixed=TRUE),
y$ID
))
}

res[vapply(res, length, numeric(1)) != 0]
}

Expand Down
11 changes: 9 additions & 2 deletions R/setReadable.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ setReadable <- function(x, OrgDb, keyType="auto") {
if (isGSEA) {
genes <- names(x@geneList)
} else if (isCompare) {
genes <- unique(unlist(x@geneClusters))
if ("core_enrichment" %in% colnames(as.data.frame(x))) {
geneslist <- x@geneClusters
names(geneslist) <- NULL
genes <- unique(names(unlist(geneslist)))
} else {
genes <- unique(unlist(x@geneClusters))
}
} else {
genes <- x@gene
}
Expand Down Expand Up @@ -73,7 +79,8 @@ setReadable <- function(x, OrgDb, keyType="auto") {


geneID <- sapply(gc, paste0, collapse="/")
if (isGSEA) {
# if (isGSEA) {
if ("core_enrichment" %in% colnames(as.data.frame(x))) {
res$core_enrichment <- unlist(geneID)
} else {
res$geneID <- unlist(geneID)
Expand Down

0 comments on commit 5ce906f

Please sign in to comment.