character string specifying the path to an index file produced by preparePairs
param
a pairParam object containing read extraction parameters
first.region
a GRanges object of length 1 specifying the first region
second.region
a GRanges object of length 1 specifying the second region
region
a GRanges object of length 1 specifying the region of interest
width
an integer scalar specifying the width of each bin in base pairs
col
any type of R color to describe the color of the plot elements
max.count
a numeric scalar specifying the count for which the darkest color is obtained
xlab
character string for the x-axis label on the plot, defaults to the chromosome name of first.region
max.height
a numeric scalar indicating the y-axis limit for rotPlaid
ylab
character string for the y-axis label on the plot, defaults to the chromosome name of second.regeion in plotPlaid
diag
a logical scalar specifying whether boxes should be shown above the diagonal for intra-chromosomal plots in plotPlaid
count
a logical scalar specifying whether the count for each bin should be plotted in plotPlaid
count.args
a named list of arguments to be passed to text for plotting of bin counts, if count=TRUE
...
other named arguments to be passed to plot
Details
The plotPlaid function constructs a plaid plot on the current graphics device.
The intervals of the first.region and second.region are represented by the x- and y-axes, respectively.
Each region is partitioned into bins of size width.
Each bin pair is represented by a box in the plotting space, where each side of the box represents a bin.
The color of the box depends on the number of read pairs mapped between the corresponding bins.
The resolution of colors can be controlled by varying max.count.
All boxes with counts above max.count will be assigned the maximum intensity.
Other boxes will be assigned a color of intensity proportional to the size of the count, such that a count of zero results in white space.
Smaller values of max.count will improve contrast at low counts at the cost of contrast at higher counts.
Scaling max.count is recommended for valid comparisons between libraries of different sizes (e.g., larger max.count for larger libraries).
If count=TRUE, the number of read pairs will be shown on top of each bin.
This will be slower to plot but can be useful in some cases, e.g., when more detail is required, or when the range of colors is not sufficient to capture the range of counts in the data.
If diag=TRUE, boxes will also be plotted above the diagonal for intra-chromosomal plots.
This is set as the default to avoid confusion when first.region is not set as the anchor range, i.e., it has a lower sorting order than second.region.
However, this can also be turned off to reduce redundancy in visualization around the diagonal.
The rotPlaid function constructs a plaid plot that has been rotated by 45 degrees.
This is useful for visualizing local interactions within a specified region.
In a rotated plot, the x-coordinate of a box in the plotting space represents the midpoint between two interacting bins, while the y-coordinate represents the distance between bins.
More simply, the interacting bins of a box can be identified by tracing diagonals from the edges of the box to the x-axis.
By default, max.height is chosen to include the interaction between the boundaries region in rotPlaid.
This is equivalent to the width of region.
Smaller values can be chosen to focus on interactions closer to the diagonal.
Larger values can also be used, but this is less useful as the interacting bins cannot be easily traced (as they will lie outside the x-axis limits).
Note that the plotted boxes for the bin pairs may overwrite the bounding box of the plot.
This can be fixed by running box() after each plotPlaid call.
Value
A (rotated) plaid plot is produced on the current graphics device.
For both functions, a function is invisibly returned that converts counts into colors.
This is useful for coordinating the colors, e.g., when constructing a separate color bar.
Author(s)
Aaron Lun
References
Lieberman-Aiden E et al. (2009). Comprehensive Mapping of Long-Range Interactions Reveals Folding Principles of the Human Genome. Science 326, 289-293.
See Also
preparePairs
Examples
hic.file <- system.file("exdata", "hic_sort.bam", package="diffHic")
originals <- readRDS(system.file("exdata", "cuts.rds", package="diffHic"))
param <- pairParam(originals)
# Setting up parameters
fout <- "temp_saved.h5"
invisible(preparePairs(hic.file, param, fout))
# Constructing intra-chromosomal plaid plots around various regions.
plotPlaid(fout, param, first.region=GRanges("chrA", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), width=50, diag=TRUE)
box()
xxx <- plotPlaid(fout, param, first.region=GRanges("chrA", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), width=50, diag=FALSE)
# Making colorbars.
xxx(1:2)
xxx(1:5)
xxx(1:10)
# Constructing inter-chromosomal plaid plots around various regions
plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), width=50)
plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), width=100)
# For a hypothetical second library which is half the size of the previous one:
plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), width=100, max.count=20, count=TRUE)
plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), width=100, max.count=40,
count=TRUE, count.args=list(col="blue"))
# Rotated
rotPlaid(fout, param, region=GRanges("chrA", IRanges(1, 200)), width=50)
rotPlaid(fout, param, region=GRanges("chrA", IRanges(1, 200)), width=100)
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(diffHic)
Loading required package: GenomicRanges
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: S4Vectors
Loading required package: stats4
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: InteractionSet
Loading required package: SummarizedExperiment
Loading required package: Biobase
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/diffHic/plotPlaid.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotPlaid
> ### Title: Construct a plaid plot of interactions
> ### Aliases: plotPlaid rotPlaid
> ### Keywords: visualization
>
> ### ** Examples
>
> hic.file <- system.file("exdata", "hic_sort.bam", package="diffHic")
> originals <- readRDS(system.file("exdata", "cuts.rds", package="diffHic"))
> param <- pairParam(originals)
>
> # Setting up parameters
> fout <- "temp_saved.h5"
> invisible(preparePairs(hic.file, param, fout))
>
> # Constructing intra-chromosomal plaid plots around various regions.
> plotPlaid(fout, param, first.region=GRanges("chrA", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), width=50, diag=TRUE)
> box()
> xxx <- plotPlaid(fout, param, first.region=GRanges("chrA", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), width=50, diag=FALSE)
>
> # Making colorbars.
> xxx(1:2)
[1] "#F2F2F2" "#E5E5E5"
> xxx(1:5)
[1] "#F2F2F2" "#E5E5E5" "#D8D8D8" "#CCCCCC" "#BFBFBF"
> xxx(1:10)
[1] "#F2F2F2" "#E5E5E5" "#D8D8D8" "#CCCCCC" "#BFBFBF" "#B2B2B2" "#A5A5A5"
[8] "#999999" "#8C8C8C" "#7F7F7F"
>
> # Constructing inter-chromosomal plaid plots around various regions
> plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), width=50)
> plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), width=100)
>
> # For a hypothetical second library which is half the size of the previous one:
> plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), width=100, max.count=20, count=TRUE)
> plotPlaid(fout, param, first.region=GRanges("chrB", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), width=100, max.count=40,
+ count=TRUE, count.args=list(col="blue"))
>
> # Rotated
> rotPlaid(fout, param, region=GRanges("chrA", IRanges(1, 200)), width=50)
> rotPlaid(fout, param, region=GRanges("chrA", IRanges(1, 200)), width=100)
>
> ## Don't show:
> unlink(fout, recursive=TRUE)
> ## End(Don't show)
>
>
>
>
>
> dev.off()
null device
1
>