Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions R/cnetplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @param size_edge relative size of edge
#' @param node_label one of 'all', 'none', 'category', 'item', 'exclusive' or 'share'
#' @param foldChange numeric values to color the item (e.g, foldChange of gene expression values)
#' @param fc_threshold threshold for filtering genes by absolute fold change (e.g., fc_threshold = 1 keeps only genes with |foldChange| > 1)
#' @param hilight selected category to be highlighted
#' @param hilight_alpha transparent value for not selected to be highlight
#' @param ... additional parameters
Expand All @@ -33,13 +34,25 @@ cnetplot.enrichResult <- function(
size_edge = .5,
node_label = "all",
foldChange = NULL,
fc_threshold = NULL,
hilight = "none",
hilight_alpha = .3,
...
) {
geneSets <- extract_geneSets(x, showCategory)
foldChange <- fc_readable(x, foldChange)

# Filter genes by absolute fold change threshold
if (!is.null(fc_threshold) && !is.null(foldChange)) {
keep_genes <- names(foldChange)[abs(foldChange) > fc_threshold]
foldChange <- foldChange[keep_genes]
geneSets <- lapply(geneSets, function(gs) {
intersect(gs, keep_genes)
})
# Remove empty gene sets
geneSets <- geneSets[sapply(geneSets, length) > 0]
}

p <- cnetplot(
geneSets,
layout = layout,
Expand Down