Skip to content

Commit

Permalink
Split Output vignette to Raw Output and Plots
Browse files Browse the repository at this point in the history
  • Loading branch information
fruce-ki committed Apr 4, 2017
1 parent 3be771f commit 198574c
Show file tree
Hide file tree
Showing 8 changed files with 932 additions and 357 deletions.
32 changes: 0 additions & 32 deletions inst/doc/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,3 @@ print( names(mydtu$Transcripts) )
# Elements of ReplicateData
print( names(mydtu$Abundances) )

## ------------------------------------------------------------------------
# Proportion and count changes for all the transcripts of the "MIX6" gene.
plot_gene(mydtu, "MIX6", style="lines") # default

## ----eval=FALSE----------------------------------------------------------
# plot_gene(mydtu, "MIX6", style="points")
# plot_gene(mydtu, "MIX6", style="rainbow")
# plot_gene(mydtu, "MIX6", style="merged")
# plot_gene(mydtu, "MIX6", style="dashed")

## ------------------------------------------------------------------------
# Proportion change VS significance.
plot_overview(mydtu, type="volcano")

## ------------------------------------------------------------------------
# Distribution of maximum proportion change.
plot_overview(mydtu, type="maxdprop")

## ---- eval=FALSE---------------------------------------------------------
# # Start the interactive volcano plot.
# plot_shiny_volcano(mydtu)

## ------------------------------------------------------------------------
library(ggplot2)

myplot <- plot_overview(mydtu, "volcano")
myplot # display

# Change title.
myplot2 <- myplot + ggtitle("MY EPIC TITLE")
myplot2

108 changes: 2 additions & 106 deletions inst/doc/output.Rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "RATs: Output and Plots"
title: "RATs: Raw Output"
author: "Kimon Froussios"
date: "16 FEB 2017"
date: "04 APR 2017"
output:
html_document:
fig_caption: no
Expand Down Expand Up @@ -248,110 +248,6 @@ print( names(mydtu$Abundances) )
***


# Visualisation of results


The output object's tables provide a host of information. The `rats` package also includes some visualisation aides.


## Isoform abundance changes for a given gene

This function allows you to visualise what's going on in any particular gene. Both the absolute counts and the relative
proportions are plotted for each transcript. This is a very useful function for inspecting a gne if interest. It enables
quick visual evaluation of the dispersion of the replicate measurements, the magnitude of the proportion change, the
presence of outliers, and the consistency among the replicates.

```{r}
# Proportion and count changes for all the transcripts of the "MIX6" gene.
plot_gene(mydtu, "MIX6", style="lines") # default
```

Several styles of this plot are available. The recommended style is set as default. The other options represent older
styles that have been kept for backwards compatibility, but may get deprecated eventually:

```{r eval=FALSE}
plot_gene(mydtu, "MIX6", style="points")
plot_gene(mydtu, "MIX6", style="rainbow")
plot_gene(mydtu, "MIX6", style="merged")
plot_gene(mydtu, "MIX6", style="dashed")
```


## Plots of overall run

Our simulated dataset is too small to properly demonstrate what these plots typically look like.
So each one is accompanied by a static image of the same plot created with a real and much larger dataset.

Several of these plots are **likely to display warnings** about missing or non-finite values. These are due to the
presence of `NA` in the tables, where entries did not pass the thresholds, and can be ignored.

Possibly the most common plot in differential expression is the volcano plot, which plots the effect size against
the statistical significance. As it is difficult to define a single p-value and a single effect size at the gene level,
the volcano can only be plotted at the transcript level.

```{r}
# Proportion change VS significance.
plot_overview(mydtu, type="volcano")
```

This is what it looks like on a larger dataset:
![Dprop VS sig](./fig/volcano.jpg)

The next command plots the largest change in proportion seen within each gene, against the number of genes showing
such change. This is a way to inspect what effect sizes are present in the data. As an additional layer of information,
they are colour-coded by their DTU call.

```{r}
# Distribution of maximum proportion change.
plot_overview(mydtu, type="maxdprop")
```

This is what it looks like on a larger dataset:
![Max Dprop](./fig/maxdprop.jpg)


### Interactive plots

If you prefer picking points from a plot than sorting through tables, the volcano plot is also available through
a `shiny` app, that brings up the relevant abundance changes plot for any point in the volcano plot.

1. By hovering over points on the volcano plot in the app, you can see the respective transcript identifier(s).
2. Clicking will pull up information on the effect size, significance and confidence of the point(s), as well as
the respective isoform abundance changes plot for the point nearest to the click.

```{r, eval=FALSE}
# Start the interactive volcano plot.
plot_shiny_volcano(mydtu)
```

This is what it looks like for the example data (remember that the emulated data example has very few transcripts).

![Transc Conf VS DTU](./fig/shiny_screenshot.png)

You will need to close down the app to return to your R terminal.


## Plot customisation

You can save any of the plots as a `ggplot2` object and use [ggplot2](http://ggplot2.org) manipulations on it, such as changing the axis scales.
Other `ggplot2` customisations include the axis tick marks, axis values, labels, titles, colours... Consult the [ggplot2](http://ggplot2.org)
documentation for more help on these.

```{r}
library(ggplot2)
myplot <- plot_overview(mydtu, "volcano")
myplot # display
# Change title.
myplot2 <- myplot + ggtitle("MY EPIC TITLE")
myplot2
```


***


# Contact information

The `rats` R package was developed within [The Barton Group](http://www.compbio.dundee.ac.uk) at [The University of Dundee](http://www.dundee.ac.uk)
Expand Down
113 changes: 0 additions & 113 deletions inst/doc/output.html

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions inst/doc/plots.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
## ----setup, include=FALSE------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)

## ------------------------------------------------------------------------
library(rats)

# Simulate some data.
simdat <- sim_sleuth_data(cnames = c("controls", "patients"))
# For convenience let's assign the contents of the list to separate variables.
myslo <- simdat$slo
myannot <- simdat$annot

# Call DTU
mydtu <- call_DTU(annot = myannot, slo = myslo, name_A = "controls", name_B = "patients",
varname= "condition", verbose= FALSE,
description="Comparison of two conditions using a simulated sleuth object
for the purposes of the tutorial. Simulated using built-in functionality
of RATs.")

## ------------------------------------------------------------------------
# Split by condition for easier view of the overall gene profile.
plot_gene(mydtu, "MIX6", style="plain")

## ------------------------------------------------------------------------
# Isoforms paired up for easier individual comparisons.
plot_gene(mydtu, "MIX6", style="paired")

## ------------------------------------------------------------------------
# Split by condition.
plot_gene(mydtu, "MIX6", style="points")

## ------------------------------------------------------------------------
# Paired by isoform.
plot_gene(mydtu, "MIX6", style="pairedpnt")

## ------------------------------------------------------------------------
# Split by condition.
# This is the DEFAULT view if the style is omitted, as it is the most informative.
plot_gene(mydtu, "MIX6", style="lines")

## ------------------------------------------------------------------------
# A cleaner version, although it no longer shows which isoforms are DTU.
plot_gene(mydtu, "MIX6", style="linesonly")

## ------------------------------------------------------------------------
# You can change the information that is colour-coded.
plot_gene(mydtu, "MIX6", style="plain", fillby="DTU")
plot_gene(mydtu, "MIX6", style="points", fillby="isoform", colourby="replicate")
plot_gene(mydtu, "MIX6", style="pairedpnt", colourby="isoform", shapeby="replicate")

# For a less colourful look, the layered information can be disabled.
plot_gene(mydtu, "MIX6", style="points", fillby="none", colourby="none", shapeby="none")

## ------------------------------------------------------------------------
# You can also customise the colours used by specifying new values for
# condcolvec, replcolvec, isofcolvec, dtucolvec and nonecol.
plot_gene(mydtu, "MIX6", style="lines", fillby="condition", condcolvec=c("magenta", "cyan"))

## ------------------------------------------------------------------------
# Proportion change VS significance.
plot_overview(mydtu, type="volcano")

## ------------------------------------------------------------------------
# Distribution of maximum proportion change.
plot_overview(mydtu, type="maxdprop")

## ---- eval=FALSE---------------------------------------------------------
# # Start the interactive volcano plot.
# plot_shiny_volcano(mydtu)

## ------------------------------------------------------------------------
library(ggplot2)

myplot <- plot_overview(mydtu, "volcano")
myplot # display

# Change title.
myplot2 <- myplot + ggtitle("MY EPIC TITLE")
myplot2

Loading

0 comments on commit 198574c

Please sign in to comment.