Skip to content

Pairwise comparison of peaks [interactive plotting using R]

pongorlorinc edited this page Mar 27, 2020 · 8 revisions

This is a short tutorial to demonstrate how you can compare samples with X-Y heatmap dotplots from peak quantifications calculated with BAMscale.

With this tool, you can do pairwise visualization of any normalized tables (FPKM, TPM, library size) generated by BAMscale.

This should help prepare figures like this:

If you have any questions, or need help, please let us know by opening an issue, or emailing us directly!

Input files

As input, the app needs a normalized data table generated by the BAMscale cov function. In principal any data matrix can be visualized, where the columns are the samples, and rows are the peaks (features).

Next to the scripts, there is a test file named "FPKM_normalized_coverages.tsv"

The file was calculated from the analysis shown here, where we reprocessed ATAC-seq data from:

"SLFN11 Blocks Stressed Replication Forks Independently of ATR. Mol Cell, 2018"

Requirements

The scripts are available in the R subfolder of BAMscale: https://github.com/ncbi/BAMscale/tree/master/R/BAMscale_plot_peak_density

The main requirement is an R installation. Can be downloaded here, or installed through BREW (MAC) and command line (Linux based systems).

R packages

The script uses "Shiny" R for interactive visualization, and uses the following packages: shiny, ggplot2, tidyr, ggrepel and gridExtra. These should be installed automatically, when running the script, but in case they do not, please install them manually by starting R in command line or Rstudio and running the following command:

install.packages("shiny", "ggplot2", "tidyr", "ggrepel", "gridExtra")

or separately:

install.packages("shiny")
install.packages("ggplot2")
install.packages("tidyr")
install.packages("ggrepel")
install.packages("gridExtra")

Running the tool

There are two main ways.

Running the executable

One way is to double click on the executable (MAC or linux-based operating systems). This should start a web browser with the running app.

If you get an error with access privilege error, try modifying it to be an executable (from the base directory of BAMscale that was cloned from github):

chmod +x R/BAMscale_plot_peak_density/peakDensity.command

Alternatively, you can open the R script PlotXY.R with Rstudio, and run it as an app.

Once you start the app, you will get an empty web page:

Loading data

Once you started the tools, you can either select the file browser to navigate to the file, or you can drop the file onto the browser button.

Visualization

Once you loaded a normalized file, there are three things that can be changed. The samples can be selected separately for the X-axis (blue) and Y-axis (green). By default, the X-axis and Y-axis values are set to the 99th percentile of the two samples to remove any potential outliers. The value can be changed with a slider at the top (highlighted in orange) above the plot.

Example

Finally, we can select for the X-axis the CEM untreated (CEM_CPT0H.sorted.dedup.bam) and for the Y-axis the 4h treated CEM cell line data (CEM_CPT4H.sorted.dedup.bam). This should result in the following figure: