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

Introduction

library(glacier)

This is a tutorial on how to use the functions contained in the glacier package in the context of an interactive R session. The use of all exported functions will be demonstrated, but additional functionality can be explored by browsing the package documentation.

Annotations

anno_path <- system.file("extdata", "ex_anno.csv", package = "glacier")

Annotations must first be imported from annotation files. Annotation files contain the gene set name, followed by a list of annotations, and finally an optional description. Below is an example of an annotation file, notice that it contains a header and a description:

knitr::kable(read.csv(anno_path, header = TRUE), "pipe")

Annotations can thus be imported:

anno <- import_annotations(anno_path, ",", TRUE, c(2, 4), 5)

Databases

data_path <- system.file("extdata", "ex_data.csv", package = "glacier")
msig_path <- system.file("extdata", "ex_msig.xml", package = "glacier")

Databases must also be imported from database files. Database files contain the gene set name, followed by a list of genes, and finally an optional description. Below is an example of a database file, notice that it contains neither a header nor a description:

knitr::kable(read.csv(data_path, header = FALSE), "pipe")

Databases can thus be imported:

data <- import_database(data_path, ",", FALSE)

Databases in the Molecular Signatures Database (MSigDB) XML format can also be imported. These databases will allow filtering of categories and organisms later on. For example:

msig <- import_msigdb(msig_path)

Genes

Genes and gene values can be imported from the console. For example:

gene_only <- process_input_text("FCN1 FTL CLU")

Gene values can also be placed alongside gene names. However, these values will only be used when creating the overlap heatmap, and will not be used in the calculation of overlap statistics. For example:

gene_vals <- process_input_text("FCN1 0.1 FTL 0.8 CLU 0.05")

Gene values can also be imported from Seurat objects. At least one cluster of interest must be specified. For example:

seurat_path <- system.file("extdata", "ex_seurat.rds", package = "glacier")
seurat_data <- readRDS(seurat_path)

gene_seurat <- process_input_seurat(seurat_data, 0)

Computation

Overlap statistics can then be calculated. For example:

stats <- compute(gene_only, anno, data)

Upon completion, a list of annotation-gene matches, along with the overlap statistics will be returned. The following is an example of the statistics calculated:

knitr::kable(stats$stats, "pipe")

Plot statistics

The results of the overlap calculation can then be plotted:

plot_stats(stats$stats, "Fold Enrichment", "Adjusted P-value")

Plot overlap

The list of annotation-gene matches can also be plotted. Here, the gene values from the input above are used for coloring the boxes:

plot_overlap(stats$matches, "Gene Value", gene_vals, stats$stats)


lilin-yang/glacier documentation built on Oct. 3, 2020, 8:06 a.m.