README.md

MutPlot

Makes a gene and sample level plot for mutation data

Disclaimer

This is an alpha stage software. Please let me know if you like it/hate it/find bugs/have suggestions

Installation

MutPlot was written in R 3.6.1 I've not tested it on earlier versions.

Dependancies

It'll load/install: * ggplot2 - for the plotting * magrittr - so I can use pipe for nicer looking code * ggpubr - as_ggplot function for legend wrangling * plyr - for ddply * patchwork - a neat little graph combining too, you may need to install this from github, not 100% (see below)

Get the package

As we're on github you'll need "install_github" from devtools.

## If you don't already have devtools installed
BiocManager::install("devtools")

You'll probably need to install patchwork from github too for plot stitching. This can be done as follows:

library(devtools)
install_github("thomasp85/patchwork")

To install the package just use this:

library(devtools)
install_github("findlaycopley/MutPlot")

This should give you access to the package.

Input

You need to input a dataframe containing all the variant positions in long format.

It needs the following xx columns:

Sample

Gene

Info

The names of these columns can be whatever you want and they're passed to the function as you call it, i.e.:

mutationPlot(Data, SampleCol="Sample", GeneCol="Gene", InfoCol="Info")
## OR
prepareMutData(Data, SampleCol="Sample", GeneCol="Gene", InfoCol="Info")

Examples

TODO change the way you access this data

There is a dataframe included called Data that includes a small mock up for testing the package.

The pipeline is run as follows:

## Build an object of the MutationPlot class from the data.
MutationPlot <- prepareMutData(Data, SampleCol="Sample", GeneCol="Gene", InfoCol="Info")
## Plots a waterfall plot of gene vs sample. 
## Tiles are coloured by the number of mutations in that sample/gene
MutationPlot <- plotWaterfall(MutationPlot)
## Plots a bar graph of the number of mutations per gene, bars coloured by mutation info
MutationPlot <- plotGeneCount(MutationPlot)
## Plots a bar graph of the number of mutations per sample, bars coloured by mutation info
MutationPlot <- plotSampleCount(MutationPlot)
## Pulls the legend for the waterfall and bar plots and creates new plots.
MutationPlot <- plotLegend(MutationPlot)
## Combines the plots with the patchwork package.
MutationPlot <- ComboMutPlot(MutationPlot)

This will return a plot that looks like this (generated using the example data):

plot example

The whole pipeline can be run in one line with the following function:

mutationPlot(Data, SampleCol="Sample", GeneCol="Gene", InfoCol="Info")
## This version will not plot the final plot when the function is called.
mutationPlot(Data, SampleCol="Sample", GeneCol="Gene", InfoCol="Info", PRINT=FALSE)

Colouring to your own tastes

Currently the package lets ggplot2 pick the colours for the bar plots by default. However using the argument "Colour_list" allows you to specify the colours for the different groups. This argument accepts a named vector. The names as the levels of the factors and the items in the list are the colours you want them to be. You need to specify a colour for each level in the InfoCol.

e.g.

Colour_List <- c("Missense" = "goldenrod2",
        "Frame shift" = "cyan1")
mutationPlot(ExampleMutationData,
        SampleCol="Sample",
        GeneCol="Gene",
        InfoCol="Info",
        Colour_List = Colour_List)

plot example



findlaycopley/MutPlot documentation built on March 4, 2020, 5:02 p.m.