knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "show/README-",
  warning = FALSE
)

omplotr: 'ggplot2' Based RNAseq Plot Function Collection

Installation and loading

Install the latest version from GitHub as follow:

# Install
if(!require(devtools)) install.packages("devtools")
devtools::install_github("bioShaun/omplotr")

Theme

theme_onmath is a ggplot theme used in almost all rnaseq plots.

library(omplotr)
p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,colour = factor(gear)))
p + theme_onmath() + ggtitle("theme_onmath")

Plot

functions to generate plot in ngs analysis

QC

Reads GC distribution

# Fastqc GC result
head(gc_test_data, 4)

# lineplot of GC distribution across Fastq file
gc_line_plot(gc_test_data)

Reads Quality barplot

# Reads Quality result
# Bars of Quality <= 30 were marked with color 'dodgerblue', 
# Bars of Quality > 30 were marked with color 'navy'.
head(rq_test_data, 4)

# Reads Quality barplot
reads_quality_plot(rq_test_data)

Quant

expression box, violin and density plot

# expression matrix
head(exp_test_data, 4)

# sample information
head(test_sample_data, 4)

# boxplot
om_boxplot(exp_test_data, test_sample_data, 'box')

# violin
om_boxplot(exp_test_data, test_sample_data, 'violin')

# density
om_boxplot(exp_test_data, test_sample_data, 'density')
# merged plot
om_boxplot(exp_test_data, test_sample_data, 'all')

expression PCA analysis point plot

om_pca_plot(exp_test_data, test_sample_data)

expression correlation heatmap

om_correlation_plot(exp_test_data, test_sample_data)

diff expression volcano plot

# diff result
head(diff_test_data, 4)

# plot volcano plot for a single compare
om_volcano_plot(diff_test_data, 'Case_vs_Control')
# plot volcano plot for merged results
om_volcano_plot(diff_test_data, 'ALL')

expression heatmap

# plot expression heatmap
om_heatmap(exp_test_data, test_sample_data)

expression cluster line plot

# cluster result
head(cluster_test_data, 4)

# cluster plot
om_cluster_plot(cluster_test_data)

Enrichment analysis

GO enrichment analysis

# diff genes
test_diff_genes <- go_test_data_list[['test_diff_genes']]
head(test_diff_genes, 4)

# gene length
test_gene_len <- go_test_data_list[['test_gene_len']]
head(test_gene_len, 4)

# get go annotation file
gene_go_map <- system.file("extdata", "topgo_test_data.txt", package = "omplotr")
gene_go_map_df <- data.table::fread(gene_go_map, header = F)
head(gene_go_map_df, 4)

# run goseq and show result
goseq_output <- om_goseq(test_diff_genes, test_gene_len, gene_go_map)
head(goseq_output, 4)

# go enrichment bar plot
go_enrich_file <- system.file("extdata", "enrichment", 
                              "example.go.enrichment.txt", 
                              package = "omplotr")
go_enrich_list <- clean_enrich_table(go_enrich_file)
om_enrich_bar_plot(go_enrich_list$table, ylab_title=go_enrich_list$title)

GO DAG graph

# run topGO
om_topgo(gene_go_map, test_diff_genes, goseq_output)

Mapping

mapping_stats <- system.file("extdata", "all_sample.mapping.xls", package = "omplotr")

# show mapping stats table
mapping_df <- read.delim(mapping_stats)
head(mapping_df, 4)

# show mapping summary
om_bwa_mapping_plot(mapping_stats, 5)

# show detail sample information
om_bwa_mapping_plot(mapping_stats, 10)

Reads Coverage

cov_stats <- system.file("extdata", "all_sample.genome.cov.xls", package = "omplotr")

# show coverage table
cov_df <- read.delim(cov_stats)
head(cov_df, 4)

# show coverage summary
om_reads_cov_plot(cov_stats, 5, 100)
# show detail sample information
om_reads_cov_plot(cov_stats, 10, 100)

Variant Distribution

# transform variant summary data
stats_names <- om_const_reseq_variant[['var_file_labs']][1:2]
stats_dir <- system.file("extdata", "variant_stats", 
                         package = "omplotr")
impact_map_file <- system.file("extdata", "variant_stats", "snpeff_varEffects.csv", 
                               package = "omplotr")
test_pie_stats <- lapply(stats_names, om_var_pie_stats, 
                         stats_dir=stats_dir, 
                         impact_map_file=impact_map_file)
head(test_pie_stats[[1]], 4)

# plot pie plot for each sample
a_om_test_var_stats <- dplyr::filter(om_test_var_stats[[1]], variable == 'A')
om_var_pie_plot(a_om_test_var_stats)
# variant summary boxplot
om_test_var_stats_df <- plyr::ldply(om_test_var_stats, data.frame)
om_var_summary_plot(om_test_var_stats_df)


bioShaun/omplotr documentation built on June 11, 2025, 7:48 a.m.