UQ R Markdown template
logo





Welcome in the QIMR Markdown template. This document describes how the template looks like, building an interactive Manhattan plot.

Loading data


Let’s load a GWAS summary statistic stored in the qqman library. This library is:

  • Made by Stephen Turner
  • Good to plot a quick Manhattan plot
library(qqman)

Show data in a table


It’s often handy to keep a trace of the raw data somewhere in your document. The DT library allows to build interactive tables that you can search, filter, highlight and more.

library(DT)
## Warning: package 'DT' was built under R version 3.4.3
datatable(gwasResults, rownames = FALSE, filter="top", options = list(pageLength = 5, scrollX=T) )

Manhattan plot


Using HTML outputs you can embed some interactive graphics. For example, the plotly library can transform any of your ggplot2 graphic in an interactive chart:

# Make the plot
p <- ggplot(don, aes(x=BPcum, y=-log10(P), text=text)) +

    # Show all points
    geom_point( aes(color=as.factor(CHR)), alpha=0.8, size=1.3) +
    scale_color_manual(values = rep(c("grey", "#563986"), 22 )) +

    # custom X axis:
    scale_x_continuous( label = axisdf$CHR, breaks= axisdf$center ) +
    scale_y_continuous(expand = c(0, 0) ) +     # remove space between plot area and x axis

    # Add highlighted points
    geom_point(data=subset(don, is_highlight=="yes"), color="orange", size=2) +

    # Custom the theme:
    theme_bw() +
    theme(
      legend.position="none",
      panel.border = element_blank(),
      panel.grid.major.x = element_blank(),
      panel.grid.minor.x = element_blank()
    ) +
    ylim(0, 10)

ggplotly(p, tooltip="text")
 




A work by Yan Holtz

yan.holtz.data@gmail.com