enrichplot dotplot

enrichplot: Visualization of Functional Enrichment Result (bioconductor.org)

dotplot-methods: dotplot in enrichplot: Visualization of Functional Enrichment Result (rdrr.io)

enrichplot/R/dotplot.R at devel · YuLab-SMU/enrichplot (github.com)

 

dotplot-methods: dotplot in enrichplot: Visualization of Functional Enrichment Result (rdrr.io)

## S4 method for signature 'compareClusterResult'
dotplot(
  object,
  x = ~Cluster,
  color = "p.adjust",
  showCategory = 5,
  split = NULL,
  font.size = 12,
  title = "",
  by = "geneRatio",
  includeAll = TRUE
)
##' @rdname dotplot
##' @param object compareClusterResult object
##' @param by one of "geneRatio", "Percentage" and "count"
##' @param split ONTOLOGY or NULL
##' @param includeAll logical
##' @param font.size font size
##' @param title figure title
##' @param group a logical value, whether to connect the
##' nodes of the same group with wires.
##' @param shape a logical value, whether to use nodes of
##' different shapes to distinguish the group it belongs to
##' @param colorBy variable that used to color enriched terms,
##' e.g. 'pvalue', 'p.adjust' or 'qvalue'
##' @importFrom ggplot2 facet_grid
dotplot.compareClusterResult <- function(object, x= "Cluster", colorBy="p.adjust",
                                         showCategory=5, by="geneRatio", size="geneRatio",
                                         split=NULL, includeAll=TRUE,
                                         font.size=12, title="", label_format = 30,
                                         group = FALSE, shape = FALSE) {
    color <- NULL
    if (is.null(size)) size <- by ## by may deprecated in future release

    df <- fortify(object, showCategory=showCategory, by=size,
                  includeAll=includeAll, split=split)

    if (by != "geneRatio")
        df$GeneRatio <- parse_ratio(df$GeneRatio)
    label_func <- default_labeller(label_format)
    if(is.function(label_format)) {
        label_func <- label_format
    }
    if (size %in% c("rowPercentage", "count", "geneRatio")) {
        by2 <- switch(size, rowPercentage = "Percentage",
                            count         = "Count",
                            geneRatio     = "GeneRatio")
    } else {
        by2 <- size
    }

    p <- ggplot(df, aes_string(x = x, y = "Description", size = by2)) +
        scale_y_discrete(labels = label_func)

    ## show multiply GO enrichment result in separate panels
    #if ("ONTOLOGY" %in% colnames(df) && length(unique(df$ONTOLOGY)) > 1){
    #    p = p + facet_grid(
    #        ONTOLOGY ~ .,
    #        scales = "free",
    #        space = "free"
    #    )
    #}

    if (group) {
        p <- p + geom_line(aes_string(color = "Cluster", group = "Cluster"), size=.3) +
          ggnewscale::new_scale_colour()
    }

    if (shape) {
        ggstar <- "ggstar"
        require(ggstar, character.only=TRUE)
        # p <- p + ggsymbol::geom_symbol(aes_string(symbol = "Cluster", fill = colorBy)) +
        p <- p + ggstar::geom_star(aes_string(starshape="Cluster", fill=colorBy)) +
            scale_fill_continuous(low="red", high="blue", guide=guide_colorbar(reverse=TRUE))
    }  else {
        p <- p +  geom_point(aes_string(color = colorBy))
    }

    p + scale_color_continuous(low="red", high="blue",
                    guide=guide_colorbar(reverse=TRUE)) +
        ylab(NULL) + ggtitle(title) + DOSE::theme_dose(font.size) +
        scale_size_continuous(range=c(3, 8)) +
        guides(size  = guide_legend(order = 1),
                color = guide_colorbar(order = 2))
}

Arguments

object

compareClusterResult object

x

x variable

color

one of pvalue or p.adjust

showCategory

category numbers

split

ONTOLOGY or NULL

font.size

font size

title

figure title

by

one of geneRatio, Percentage or count

includeAll

logical

dotplot.compareClusterResult( object, x = "Cluster", colorBy = "p.adjust", showCategory = 5, by = "geneRatio", size = "geneRatio", split = NULL, includeAll = TRUE, font.size = 12, title = "", label_format = 30, group = FALSE, shape = FALSE ) Arguments object compareClusterResult object ... additional parameters x variable for x-axis, one of ’GeneRatio’ and ’Count’ color variable that used to color enriched terms, e.g. ’pvalue’, ’p.adjust’ or ’qvalue’ showCategory A number or a list of terms. If it is a number, the first n terms will be displayed. If it is a list of terms, the selected terms will be displayed. size variable that used to scale the sizes of categories, one of "geneRatio", "Percentage" and "count" split ONTOLOGY or NULL font.size font size title figure title orderBy The order of the Y-axis label_format a numeric value sets wrap length, alternatively a custom function to format axis labels. by default wraps names longer that 30 characters by one of "geneRatio", "Percentage" and "count" includeAll logical decreasing logical. Should the orderBy order be increasing or decreasing? colorBy variable that used to color enriched terms, e.g. ’pvalue’, ’p.adjust’ or ’qvalue’ group a logical value, whether to connect the nodes of the same group with wires. shape a logical value, whether to use nodes of different shapes to distinguish the group it belongs to 

你可能感兴趣的:(java,前端,javascript)