knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

mogo

mogo is a package for generating GO analysis using M.oryzae genes only. You can provide the main function with the list of genes of interest and it does (most of) the rest!

Installation

To install you'll need the devtools R package. From the R console in RStudio type

install.packages("devtools")

Once devtools is installed you can use that to install mogo

devtools::install_github("TeamMacLean/mogo")

Preparation

The first step is to load our gene expression data file and get a simple list of genes for GO analysis

Data loading

First read in your gene expression file. You can do that with read_csv(). Minimally it should contain the gene ID, the log fold change and the $p$-value.

library(readr)
library(dplyr)

gene_expression <- read_csv(system.file("extdata","sample_gene_expression.csv", package="mogo"))
gene_expression

Filter as required

We can now filter the genes to select only the ones with e.g $p <= 0.05$, using filter()

filtered_gene_expression <- filter(gene_expression, p.adj <= 0.05)
filtered_gene_expression

Extract the gene id column

We can now extract the gene_id column using the $ syntax

gene_ids <- filtered_gene_expression$gene_id
gene_ids

GO enrichment

The GO enrichment is done in the mogo package. Load that and use the do_enrich() function, passing it the vector of gene_ids to calculate the enrichment.

library(mogo)
enrich <- do_enrich(gene_ids)
enrich

As you can see the enrich object has a lot of information in it. The result table can be extracted using as.data.frame() to convert the enrich to a data.frame (note glimpse is a helpful function for printing out big dataframes).

result_table <- as.data.frame(enrich)
glimpse(result_table)

You can save the result to an excel-compatible csv file with, write_csv()

write_csv(result_table, "my_GO_results.csv")

Plotting

The enrich object is from the package ClusterProfiler and can be used directly in most of it's plot types. See them at the ClusterProfiler page http://yulab-smu.top/clusterProfiler-book/chapter12.html#bar-plot

Barplot

Works ok, but the text can make it a bit unwieldy

library(clusterProfiler)
library(enrichplot)
barplot(enrich, showCategory=5)

Dotplot

Similar

dotplot(enrich, showCategory=5)

UpSetPlot

These are like a really sophisticated Venn/Euler diagram. https://jku-vds-lab.at/tools/upset/

upsetplot(enrich)

GoPlot

Plots from the package GoPlot such as bubble plots can be made, but need you to convert the enrich object to a DAVID compatible object, and make an accessory data.frame of the expression information. Use enricher_to_david() for the first part, and the relevant columns of the gene expression data you created at the beginning for the second part.

david <- enricher_to_david(enrich)
expr_info <- data.frame(
  ID = filtered_gene_expression$gene_id,
  logFC = filtered_gene_expression$log2fc
)

Then you can convert that to the data format needed for GoPlot

library(GOplot)
circ <- circle_dat(david, expr_info)

Go Bar

A different sort of GO barchart

GOBar(subset(circ, category == 'BP'))

Go Bubble

A plot with bubbles

GOBubble(circ, labels=3)


TeamMacLean/mogo documentation built on April 14, 2023, 3:51 p.m.