Skip to content

Commit

Permalink
facet with compareCluster result
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Nov 3, 2015
1 parent 35ddb9a commit a8fe7b9
Show file tree
Hide file tree
Showing 40 changed files with 86 additions and 59 deletions.
13 changes: 7 additions & 6 deletions DESCRIPTION
Expand Up @@ -2,7 +2,7 @@ Package: clusterProfiler
Type: Package
Title: statistical analysis and visulization of functional profiles for
genes and gene clusters
Version: 2.5.1
Version: 2.5.2
Authors@R: c(person(given = "Guangchuang", family = "Yu",
email = "guangchuangyu@gmail.com",
role = c("aut", "cre")),
Expand All @@ -13,7 +13,7 @@ Authors@R: c(person(given = "Guangchuang", family = "Yu",
email = "giovanni.dallolio@upf.edu",
role = "ctb"))
Author: Guangchuang Yu <guangchuangyu@gmail.com> with contributions from
Li-Gen Wang and Giovanni Dall'Olio.
Li-Gen Wang and Giovanni Dall'Olio.
Maintainer: Guangchuang Yu <guangchuangyu@gmail.com>
Description: This package implements methods to analyze and visualize
functional profiles (GO and KEGG) of gene and gene clusters.
Expand All @@ -23,7 +23,7 @@ Imports:
DOSE,
GOSemSim,
AnnotationDbi,
methods,
methods,
stats4,
tidyr,
plyr,
Expand All @@ -40,13 +40,14 @@ Suggests:
KEGG.db,
knitr,
org.Hs.eg.db,
pathview,
pathview,
ReactomePA,
RDAVIDWebService
VignetteBuilder: knitr
License: Artistic-2.0
URL: https://github.com/GuangchuangYu/clusterProfiler
BugReports: https://github.com/GuangchuangYu/clusterProfiler/issues
Packaged: NA
biocViews: Annotation, Clustering, GeneSetEnrichment, GO, KEGG, MultipleComparison, Pathways, Reactome, Visualization

biocViews: Annotation, Clustering, GeneSetEnrichment, GO, KEGG,
MultipleComparison, Pathways, Reactome, Visualization
RoxygenNote: 5.0.0
3 changes: 2 additions & 1 deletion NAMESPACE
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.1.1): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(ALLEXTID,BP)
S3method(ALLEXTID,CC)
Expand Down Expand Up @@ -88,6 +88,7 @@ importFrom(KEGGREST,keggLink)
importFrom(KEGGREST,keggList)
importFrom(ggplot2,"%+%")
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,coord_flip)
importFrom(ggplot2,element_text)
Expand Down
5 changes: 5 additions & 0 deletions NEWS
@@ -1,3 +1,8 @@
CHANGES IN VERSION 2.5.2
------------------------
o facet with compareCluster result <2015-11-03, Tue>
+ see https://github.com/GuangchuangYu/clusterProfiler/issues/32

CHANGES IN VERSION 2.5.1
------------------------
o read.gmt function for parsing gmt file for enricher and GSEA <2015-10-28, Wed>
Expand Down
18 changes: 16 additions & 2 deletions R/compareCluster.R
Expand Up @@ -65,9 +65,21 @@ compareCluster <- function(geneClusters, fun="enrichGO", data='', ...) {
stop("No enrichment found in any of gene cluster, please check your input...")
}

clProf.df <- rename(clProf.df, c(.id="Cluster"))
clProf.df <- rename(clProf.df, c(.id="Cluster"))
clProf.df$Cluster = factor(clProf.df$Cluster, levels=clusters.levels)

if (is.data.frame(data) && grepl('+', grouping.formula)) {
groupVarName <- strsplit(grouping.formula, split="\\+") %>% unlist %>%
gsub("~", "", .) %>% gsub("^\\s*", "", .) %>% gsub("\\s*$", "", .)
groupVars <- sapply(as.character(clProf.df$Cluster), strsplit, split="\\.") %>% do.call(rbind, .)
for (i in seq_along(groupVarName)) {
clProf.df[, groupVarName[i]] <- groupVars[,i]
}
i <- which(colnames(clProf.df) %in% groupVarName)
j <- (1:ncol(clProf.df))[-c(1, i)]
clProf.df <- clProf.df[, c(1, i, j)]
}

##colnames(clProf.df)[1] <- "Cluster"
new("compareClusterResult",
compareClusterResult = clProf.df,
Expand Down Expand Up @@ -182,6 +194,7 @@ setMethod("plot", signature(x="compareClusterResult"),
##' @rdname dotplot-methods
##' @aliases dotplot,compareClusterResult,ANY-method
##' @param object compareClusterResult object
##' @param x x variable
##' @param colorBy one of pvalue or p.adjust
##' @param showCategory category numbers
##' @param by one of geneRatio, Percentage or count
Expand All @@ -192,14 +205,15 @@ setMethod("plot", signature(x="compareClusterResult"),
##' @exportMethod dotplot
setMethod("dotplot", signature(object="compareClusterResult"),
function(object,
x = ~Cluster,
colorBy="p.adjust",
showCategory=5,
by="geneRatio",
includeAll=TRUE,
font.size=12,
title=""
) {
dotplot.compareClusterResult(object, colorBy, showCategory, by, includeAll, font.size, title)
dotplot.compareClusterResult(object, x=x, colorBy, showCategory, by, includeAll, font.size, title)
})


Expand Down
6 changes: 3 additions & 3 deletions R/dotplot.R
@@ -1,6 +1,6 @@
dotplot.compareClusterResult <- function(object, colorBy="p.adjust", showCategory=5, by="geneRatio", includeAll=TRUE, font.size=12, title="") {
dotplot.compareClusterResult <- function(object, x=~Cluster, colorBy="p.adjust", showCategory=5, by="geneRatio", includeAll=TRUE, font.size=12, title="") {
df <- fortify(object, showCategory=showCategory, by=by, includeAll=includeAll)
plotting.clusterProfile(df, type="dot", colorBy=colorBy, by=by, title=title, font.size=font.size)
plotting.clusterProfile(df, x=x, type="dot", colorBy=colorBy, by=by, title=title, font.size=font.size)
}

##' @title fortify
Expand Down Expand Up @@ -51,7 +51,7 @@ fortify.compareClusterResult <- function(model, data, showCategory=5, by="geneRa

## remove zero count
result$Description <- as.character(result$Description) ## un-factor
GOlevel <- result[,c(2,3)] ## GO ID and Term
GOlevel <- result[,c("ID", "Description")] ## GO ID and Term
GOlevel <- unique(GOlevel)

result <- result[result$Count != 0, ]
Expand Down
8 changes: 5 additions & 3 deletions R/utilities.R
Expand Up @@ -333,6 +333,7 @@ getGOLevel <- function(ont, level) {
##' @return ggplot object
##' @importFrom ggplot2 ggplot
##' @importFrom ggplot2 aes
##' @importFrom ggplot2 aes_
##' @importFrom ggplot2 aes_string
##' @importFrom ggplot2 geom_bar
##' @importFrom ggplot2 coord_flip
Expand All @@ -348,6 +349,7 @@ getGOLevel <- function(ont, level) {
##' @importFrom DOSE theme_dose
##' @author Guangchuang Yu \url{http://ygc.name}
plotting.clusterProfile <- function(clProf.reshape.df,
x = ~Cluster,
type = "dot",
colorBy = "p.adjust",
by = "geneRatio",
Expand All @@ -371,13 +373,13 @@ plotting.clusterProfile <- function(clProf.reshape.df,
if (type == "dot") {
if (by == "rowPercentage") {
p <- ggplot(clProf.reshape.df,
aes(x = Cluster, y = Description, size = Percentage))
aes_(x = x, y = ~Description, size = ~Percentage))
} else if (by == "count") {
p <- ggplot(clProf.reshape.df,
aes(x = Cluster, y = Description, size = Count))
aes_(x = x, y = ~Description, size = ~Count))
} else if (by == "geneRatio") {
p <- ggplot(clProf.reshape.df,
aes(x = Cluster, y = Description, size = GeneRatio))
aes_(x = x, y = ~Description, size = ~GeneRatio))
} else {
## nothing here
}
Expand Down
2 changes: 1 addition & 1 deletion man/DataSet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/GSEA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/Gff2GeneTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/bitr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/buildGOmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/buildKEGGmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/clusterProfiler-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/cnetplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/compareCluster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/compareClusterResult-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions man/dotplot-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/download.KEGG.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/dropGO.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/enrichDAVID.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/enrichGO.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/enrichKEGG.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/enrichMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/enricher.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions man/fortify.compareClusterResult.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getGOLevel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gofilter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/groupGO.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/groupGOResult-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gseGO.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gseKEGG.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gseaplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/idType.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/merge_result.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a8fe7b9

Please sign in to comment.