Last data update: 2014.03.03

R: Construct copy-number frequency plot
cnFreqR Documentation

Construct copy-number frequency plot

Description

Given a data frame construct a plot to display copy number changes across the genome for a group of samples.

Usage

cnFreq(x, CN_low_cutoff = 1.5, CN_high_cutoff = 2.5, plot_title = NULL,
  CN_Loss_colour = "#002EB8", CN_Gain_colour = "#A30000",
  x_title_size = 12, y_title_size = 12, facet_lab_size = 10,
  plotLayer = NULL, out = "plot")

Arguments

x

Object of class data frame with rows representing the proportion of CN losses/gains across the genome (default), or actual CN values. The former option must contain columns with the following names "chromosome", "start", "end", "gain", and "loss", and the latter option must contain column names "chromosome", "start", "end", "segmean", and "sample". Windows supplied must be consistent across samples!

CN_low_cutoff

Numeric value representing the point at or below which copy number alterations are considered losses. Only used if x represents CN values.

CN_high_cutoff

Numeric value representing the point at or above which copy number alterations are considered gains. Only used if x represents CN values.

plot_title

Character string specifying the title to display on the plot.

CN_Loss_colour

Character string specifying the colour value for copy number losses.

CN_Gain_colour

Character string specifying the colour value for copy number gains.

x_title_size

Integer specifying the size of the x-axis title.

y_title_size

Integer specifying the size of the y-axis title.

facet_lab_size

Integer specifying the size of the faceted labels plotted.

plotLayer

Valid ggplot2 layer to be added to the plot.

out

Character vector specifying the the object to output, one of "data", "grob", or "plot", defaults to "plot" (see returns).

Details

cnFreq will detect the column names present in the data frame supplied to x, and will perform one of the following actions. If "gain" and "loss" columns are detected the raw data will be plotted, if "segmean" and "sample" columns are detected the frequency of copy-number gains and losses present in the cohort will be calculated and plotted. The 'plotLayer' parameter can be used to add an additional layer to the ggplot2 graphic (see vignette).

Value

One of the following, a dataframe containing data to be plotted, a grob object, or a plot.

Examples

# Create data
xstart <- seq(0,4990000,length.out=500)
xloss <- rep(runif(10,0,0.6),rep(50,10))/1.5
xloss <- xloss + jitter(xloss,amount=0.002)
x <- data.frame(chromosome=rep(paste0("chr",1:5),rep(500,5)), start=xstart,
end=xstart+10000, loss=xloss, gain=(1-xloss))

# Plot the data
cnFreq(x)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GenVisR)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/GenVisR/cnFreq.Rd_%03d_medium.png", width=480, height=480)
> ### Name: cnFreq
> ### Title: Construct copy-number frequency plot
> ### Aliases: cnFreq
> 
> ### ** Examples
> 
> # Create data
> xstart <- seq(0,4990000,length.out=500)
> xloss <- rep(runif(10,0,0.6),rep(50,10))/1.5
> xloss <- xloss + jitter(xloss,amount=0.002)
> x <- data.frame(chromosome=rep(paste0("chr",1:5),rep(500,5)), start=xstart,
+ end=xstart+10000, loss=xloss, gain=(1-xloss))
> 
> # Plot the data
> cnFreq(x)
Detected "chr" in the chromosome column of x... proceeding
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>