エンリッチプロット: 機能強化結果の視覚化 (bioconductor.org)
dotplot-methods:enrichplot の dotplot:機能強化結果の視覚化 (rdrr.io)
enrichplot/R/dotplot.R at devel · YuLab-SMU/enrichplot (github.com)
dotplot-methods: enrichplot の dotplot: 機能強化結果の視覚化 (rdrr.io) ## シグネチャ 'compareClusterResult' の S4 メソッド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))
}
引数
object |
CompareClusterResult オブジェクト |
x |
x変数 |
color |
pvalue または p.adjust のいずれか |
showCategory |
カテゴリ番号 |
split |
オントロジーまたは NULL |
font.size |
フォントサイズ |
title |
図のタイトル |
by |
geneRatio、Percentage、または count のいずれか |
includeAll |
論理的な |
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 ) 引数オブジェクト CompareClusterResult オブジェクト ... 追加パラメーター x 軸の x 変数、強化された用語の色付けに使用される 'GeneRatio' および 'Count' カラー変数のいずれか、例: 'pvalue'、'p.adjust'、または 'qvalue' showCategory 数値または用語のリスト。数値の場合、最初の n 項が表示されます。用語の一覧の場合は、選択した用語が表示されます。カテゴリのサイズを調整するために使用されるサイズ変数。「geneRatio」、「Percentage」、「count」のいずれかで、ONTOLOGY または NULL フォントを分割します。size フォント サイズ title Figure title orderBy Y 軸の順序 label_format 数値でラップ長を設定するか、軸ラベルをフォーマットするカスタム関数。デフォルトでは、30 文字を超える名前は、「geneRatio」、「Percentage」、および「count」のいずれかによってラップされます。 includeAll 論理降順論理。orderBy の順序は増加する必要がありますか、それとも減少する必要がありますか? colorBy 変数は、エンリッチされた用語の色付けに使用されます。たとえば、「pvalue」、「p.adjust」、または「qvalue」は、同じグループのノードをワイヤで接続するかどうかを示す論理値をグループ化します。論理値を形成する、異なる形状のノードを使用して、それが属するグループを区別するかどうか デフォルトでは、30 文字を超える名前は、「geneRatio」、「Percentage」、および「count」のいずれかによってラップされます。 includeAll 論理降順論理。orderBy の順序は増加する必要がありますか、それとも減少する必要がありますか? colorBy 変数は、エンリッチされた用語の色付けに使用されます。たとえば、「pvalue」、「p.adjust」、または「qvalue」は、同じグループのノードをワイヤで接続するかどうかを示す論理値をグループ化します。論理値を形成する、異なる形状のノードを使用して、それが属するグループを区別するかどうか デフォルトでは、30 文字を超える名前は、「geneRatio」、「Percentage」、および「count」のいずれかによってラップされます。 includeAll 論理降順論理。orderBy の順序は増加する必要がありますか、それとも減少する必要がありますか? colorBy 変数は、エンリッチされた用語の色付けに使用されます。たとえば、「pvalue」、「p.adjust」、または「qvalue」は、同じグループのノードをワイヤで接続するかどうかを示す論理値をグループ化します。論理値を形成する、異なる形状のノードを使用して、それが属するグループを区別するかどうか