knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>", 
  ## edited options below
  fig.width = 8,
  fig.asp = 0.8,
  out.width = "100%",
  dpi = 300
)

Introduction

This vignette provides a quick guide to ontoClust package.

Installation

devtools::install_github("altintasali/ontoClust")
library(ontoClust)

Gene enrichment results

In a typical differential expression analysis, you may want to check the ontology terms (e.g. GO, KEGG) enriched using the differentially expressed genes. A typical enrichment result looks like this:

head(sample_data$GOBP)

Let's check how many enriched terms there are for a given comparison (so called "contrast").

enr <- sample_data$GOBP
enrSub <- enr[enr$Condition == "AvsB",]
enrSub <- enrSub[enrSub$qvalue < 0.05,]
nrow(enrSub)

As you can imagine, it is really hard to go through r nrow(enrSub) GO terms manually. This is where ontoClust becomes handy.

Creating Ontology Networks

In order to create ontology (GO) networks, we need to provide a similarity metric across GO terms in a pairwise fashion. ontoClust uses Jaccard Similarity Index using the gene content of each ontology term. createOntologyNetwork function makes this process easy for you.

For the sake of computation time, let's work with a random subset of those r nrow(enrSub) GO terms. 75 terms is ideal for a quick run.

# set.seed(6)
# subsetTerms <- sample(x = enrSub$ID, size = 100)
subsetTerms <- enrSub$ID[1:75]
head(subsetTerms)

Now that we have the terms to work with, we can create the network.

network <- createOntologyNetwork(subsetTerms)
head(network)

Creating Link Communities

In order to create link communities, we need to provide the network of GO terms. The getLC will help us to do that.

lc <- getLC(network, verbose = FALSE)
lc

Creating Ontology Clusters

Finally, we can calculate the clusters of GO Terms:

oc <- getOntoClust(lc, verbose = FALSE)
head(oc$result)
tail(oc$result)
table(oc$ontology_clusters)

Plot Ontology Clusters

Heatmap

heatmapOntoClust(oc, filename = "heatmapOntoClust.png", silent = TRUE)
knitr::include_graphics("heatmapOntoClust.png")

Network Plot

plotOntoNetwork(oc)
plotOntoNetwork(oc, facet_by = "ontology_cluster", label_n = 3)
plotOntoNetwork(oc, facet_by = "ontology_cluster", background = FALSE, label_n = 3)

Word Cloud

Although Word Clouds are not the best way of scientific visualization, it can be helpful to get a quick grasp of the ontology clusters. You can create Word Clouds by using the functions below.

wc <- createWordCloud(oc)
# plot top 10 words for each ontology clusters
plotWordCloud(wc, n = 10)

Session Info

sessionInfo()


altintasali/ontoClust documentation built on Dec. 19, 2021, 1:36 a.m.