Skip to contents

This function performs Kyoto Encyclopedia of Genes and Genomes (KEGG) pathway enrichment analysis on a provided list of gene identifiers using the `clusterProfiler` package. It supports human and mouse organisms. Optionally, it can generate bar plots or bubble plots to visualize the top enriched KEGG pathways.

Usage

get_KEGG(
  input_list,
  organism = c("Homo sapiens", "Mus musculus"),
  plot = c("no", "bar_plot", "bubble_plot")
)

Arguments

input_list

A character vector of gene identifiers, ideally ENTREZ IDs, for which to perform KEGG enrichment analysis. If other key types are used, ensure they can be mapped to ENTREZ IDs by `clusterProfiler`.

organism

A character string specifying the organism. Must be one of "Homo sapiens" (for human, uses KEGG code 'hsa') or "Mus musculus" (for mouse, uses KEGG code 'mmu').

plot

A character string specifying the type of plot to generate.

  • "no": No plot is generated; only the KEGG enrichment table is returned.

  • "bar_plot": Generates a bar plot of the top 20 enriched KEGG pathways. Bars are colored by `-log10(pvalue)`.

  • "bubble_plot": Generates a bubble plot of the top 20 enriched KEGG pathways. Bubble size represents `Count` (number of genes in the pathway), and color represents `-log10(pvalue)`.

Value

If `plot = "no"`, returns a `data.frame` of KEGG enrichment results. If `plot = "bar_plot"` or `plot = "bubble_plot"`, returns a `list` containing:

  • `KEGG_data`: A `data.frame` of KEGG enrichment results.

  • `plot`: A `ggplot` object representing the combined plot of top KEGG pathways.

Examples

if (FALSE) { # \dontrun{
# Example for Homo sapiens using ENTREZIDs
# A gene list (replace with your actual ENTREZ IDs)
human_entrez_genes <- c("597", "1000", "1001", "10010", "10011", "10012",
                        "10013", "10014", "10015", "10016", "10017", "10018")

# Get KEGG data only
kegg_results_human_table <- get_KEGG(input_list = human_entrez_genes,
                                          organism = "Homo sapiens",
                                          plot = "no")
print(head(kegg_results_human_table))

# Get KEGG data and bar plot
kegg_results_human_bar_plot <- get_KEGG(input_list = human_entrez_genes,
                                             organism = "Homo sapiens",
                                             plot = "bar_plot")
print(head(kegg_results_human_bar_plot$KEGG_data))
kegg_results_human_bar_plot$plot # This will display the plot

# Example for Mus musculus using ENTREZIDs
# A gene list (replace with your actual ENTREZ IDs)
mouse_entrez_genes <- c("12536", "12543", "12551", "12574", "12610", "12613",
                        "12614", "12615", "12618", "12620", "12621", "12623")

# Get KEGG data and bubble plot for mouse
kegg_results_mouse_bubble_plot <- get_KEGG(input_list = mouse_entrez_genes,
                                                 organism = "Mus musculus",
                                                 plot = "bubble_plot")
print(head(kegg_results_mouse_bubble_plot$KEGG_data))
kegg_results_mouse_bubble_plot$plot # This will display the plot
} # }