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
col.up
any type of R color to describe the maximum color for positive log-fold changes
col.down
any type of R color to describe the maximum color for negative log-fold changes
background
any type of R color, specifying the background color of the interaction space
zlim
a numeric scalar indicating the maximum absolute log-fold change
xlab
character string for the x-axis label on the plot, defaults to the first chromosome name
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 second chromosome name in plotDI
diag
a logical scalar specifying whether boxes should be shown above the diagonal for intra-chromosomal plots in plotDI
...
other named arguments to be passed to plot
Details
The plotDI function constructs a plaid plot on the current graphics device.
The intervals of first.region and second.region are represented by the x- and y-axes, respectively.
Each bin pair is represented by a box in the plotting space, where each side of the box represents a bin.
Plotting space that is not covered by any bin pair is shown in background.
The color of the box depends on the magnitude and sign of the log-fold change in fc.
Positive log-FCs will range from white to col.up, whereas negative log-FCs will range from white to col.down.
The chosen color is proportional to the magnitude of the log-FC, and the most extreme colors are only obtained at the maximum absolute log-FC in fc.
The maximum value can be capped at zlim for better resolution of small log-FCs.
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 rotDI function constructs a rotated plot of differential interactions, for visualization of local changes.
See rotPlaid for more details.
Value
A (rotated) plaid plot of differential interactions is produced on the current graphics device.
A function is also invisibly returned that converts log-FCs 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
plotPlaid,
rotPlaid,
squareCounts
Examples
# Setting up the objects.
a <- 10
b <- 20
regions <- GRanges(rep(c("chrA", "chrB"), c(a, b)), IRanges(c(1:a, 1:b), c(1:a, 1:b)),
seqinfo=Seqinfo(seqlengths=c(chrA=a, chrB=b), seqnames=c("chrA", "chrB")))
set.seed(3423)
all.anchor1 <- sample(length(regions), 500, replace=TRUE)
all.anchor2 <- as.integer(runif(500, 1, all.anchor1+1))
out <- InteractionSet(matrix(0, 500, 1), colData=DataFrame(lib.size=1000),
GInteractions(anchor1=all.anchor1, anchor2=all.anchor2,
regions=regions, mode="reverse"), metadata=List(width=1))
fc <- runif(nrow(out), -2, 2)
# Constructing intra-chromosomal DI plots around various regions
plotDI(out, fc, first.region=GRanges("chrA", IRanges(1, 10)),
second.region=GRanges("chrA", IRanges(1, 10)), diag=TRUE)
plotDI(out, fc, first.region=GRanges("chrA", IRanges(1, 10)),
second.region=GRanges("chrA", IRanges(1, 10)), diag=FALSE)
# Constructing inter-chromosomal DI plots around various regions
xxx <- plotDI(out, fc, first.region=GRanges("chrB", IRanges(1, 10)),
second.region=GRanges("chrA", IRanges(1, 20)), diag=TRUE)
plotDI(out, fc, first.region=GRanges("chrB", IRanges(1, 100)),
second.region=GRanges("chrA", IRanges(1, 200)), diag=TRUE, zlim=5)
# Making colorbars.
xxx((-10):10/10)
xxx((-20):20/20)
# Rotated.
rotDI(out, fc, region=GRanges("chrA", IRanges(1, 200)))
rotDI(out, fc, region=GRanges("chrB", IRanges(1, 200)))
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/plotDI.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotDI
> ### Title: Construct a plaid plot of differential interactions
> ### Aliases: plotDI rotDI
> ### Keywords: visualization
>
> ### ** Examples
>
> # Setting up the objects.
> a <- 10
> b <- 20
> regions <- GRanges(rep(c("chrA", "chrB"), c(a, b)), IRanges(c(1:a, 1:b), c(1:a, 1:b)),
+ seqinfo=Seqinfo(seqlengths=c(chrA=a, chrB=b), seqnames=c("chrA", "chrB")))
>
> set.seed(3423)
> all.anchor1 <- sample(length(regions), 500, replace=TRUE)
> all.anchor2 <- as.integer(runif(500, 1, all.anchor1+1))
> out <- InteractionSet(matrix(0, 500, 1), colData=DataFrame(lib.size=1000),
+ GInteractions(anchor1=all.anchor1, anchor2=all.anchor2,
+ regions=regions, mode="reverse"), metadata=List(width=1))
> fc <- runif(nrow(out), -2, 2)
>
> # Constructing intra-chromosomal DI plots around various regions
> plotDI(out, fc, first.region=GRanges("chrA", IRanges(1, 10)),
+ second.region=GRanges("chrA", IRanges(1, 10)), diag=TRUE)
> plotDI(out, fc, first.region=GRanges("chrA", IRanges(1, 10)),
+ second.region=GRanges("chrA", IRanges(1, 10)), diag=FALSE)
>
> # Constructing inter-chromosomal DI plots around various regions
> xxx <- plotDI(out, fc, first.region=GRanges("chrB", IRanges(1, 10)),
+ second.region=GRanges("chrA", IRanges(1, 20)), diag=TRUE)
> plotDI(out, fc, first.region=GRanges("chrB", IRanges(1, 100)),
+ second.region=GRanges("chrA", IRanges(1, 200)), diag=TRUE, zlim=5)
>
> # Making colorbars.
> xxx((-10):10/10)
[1] "#7F7FFF" "#8B8BFF" "#9898FF" "#A5A5FF" "#B2B2FF" "#BFBFFF" "#CBCBFF"
[8] "#D8D8FF" "#E5E5FF" "#F2F2FF" "#FFFFFF" "#FFF2F2" "#FFE5E5" "#FFD8D8"
[15] "#FFCBCB" "#FFBFBF" "#FFB2B2" "#FFA5A5" "#FF9898" "#FF8B8B" "#FF7F7F"
> xxx((-20):20/20)
[1] "#7F7FFF" "#8585FF" "#8B8BFF" "#9292FF" "#9898FF" "#9F9FFF" "#A5A5FF"
[8] "#ABABFF" "#B2B2FF" "#B8B8FF" "#BFBFFF" "#C5C5FF" "#CBCBFF" "#D2D2FF"
[15] "#D8D8FF" "#DFDFFF" "#E5E5FF" "#EBEBFF" "#F2F2FF" "#F8F8FF" "#FFFFFF"
[22] "#FFF8F8" "#FFF2F2" "#FFEBEB" "#FFE5E5" "#FFDFDF" "#FFD8D8" "#FFD2D2"
[29] "#FFCBCB" "#FFC5C5" "#FFBFBF" "#FFB8B8" "#FFB2B2" "#FFABAB" "#FFA5A5"
[36] "#FF9F9F" "#FF9898" "#FF9292" "#FF8B8B" "#FF8585" "#FF7F7F"
>
> # Rotated.
> rotDI(out, fc, region=GRanges("chrA", IRanges(1, 200)))
> rotDI(out, fc, region=GRanges("chrB", IRanges(1, 200)))
>
>
>
>
>
> dev.off()
null device
1
>