Last data update: 2014.03.03

R: Image Scatter Plot Matrix for Large Datasets
ipairsR Documentation

Image Scatter Plot Matrix for Large Datasets

Description

Produces an image scatter plot matrix of large datasets where the colors encode the density of the points in the scatter plots.

Usage

ipairs(x,
       pixs = 1, zmax = NULL, ztransf=function(x){x},
       colramp = IDPcolorRamp, cex = par("cex"),
       lab.diag, cex.diag = NULL,
       main = NULL, d.main = 1.5, cex.main = 1.5*par("cex.main"),
       legend = TRUE, d.legend = 1.5, cex.axis = 0.8*par("cex.axis"),
       nlab.axis = 5, minL.axis = 2, las = 1, border = FALSE,
       mar = rep(0,4), oma = c(3,3,1,0), mgp = c(2,0.5,0)*cex.axis,
       tcl = -0.3, ...)

Arguments

x

data.frame or matrix

pixs

Pixel size in mm on the plotting device.

zmax

Maximum number of counts per pixel in the plot. When NULL, each scatter plot has its individual scale. If a number >= maximum number of counts per pixel is supplied, the scale will be identical for all scatter plots. The maximum number of counts per pixel is delivered by the return value.

ztransf

Function to transform the counts per pixel, which will be mapped by the function in colramp to well defined colors. The user has to make sure that the transformed counts lie in the range [0,zmax], where zmax is any positive number (>=2).

colramp

Color ramp to encode the number of counts within a pixel.

cex

See Argument cex in par

lab.diag

Labels of columns, written into the diagonal of the matrix. When NULL, the names of x are used.

cex.diag

Magnification used for text in diagonal relative to the current setting of cex. When NULL, they are calculated automatically.

main

Titel. When NULL

d.main

Vertical distance between upper border of scatter plots and the title line in multiples of title height.

cex.main

Magnification used for title relative to the current setting of cex.

legend

Logical. When FALSE, no legend is plotted and space is saved in figure region.

d.legend

Horizontal distance between right border of scatter plots and legend in multiples of title height.

cex.axis

Magnification used for axis annotation relative to the current setting of cex.

nlab.axis

Approximate number of labels on axes.

minL.axis

The minimum length of the abbreviations of factor levels, used to label the axes ticks.

las

Orientation of labels on axes.

border

Logical. When TRUE, a border is drawn around the individual colors in the legend.

mar, oma

Margin and outer margin respectively. Cf. par

mgp, tcl

Cf. par

...

Additional arguments to par

Details

The idea is similar to gplot.hexbin. The hexagons are better suited to reflect the density of points in a plane than the squares used here. Nevertheless squares are, contrary to hexagons, invariant to reflexions at the x- and y-axis and therefore better suited for scatter plot matrices and also for plotting factors.

The code is based on R function pairs V1.7.

Value

Maximum number of counts per Pixel found. Additional elements are returned when verbose == TRUE.

Note

When you get the error message "Zmax too small! Densiest aereas are out of range!" you must run the function with identical parameters but without specifying zmax. The value returned gives you the minimum value allowed for zmax.

Author(s)

Andreas Ruckstuhl, Rene Locher

See Also

ilagplot, iplot, Image

Examples

## Small numbers of different values are plotted nicer
## when converted to factors
AQ <- airquality
AQ$Month <- as.factor(AQ$Month)

zmax <- ipairs(AQ, pixs=2, main="Air Quality")
ipairs(AQ, pixs=2, zmax=zmax, main="Air Quality",border=TRUE)

## example with factors
ipairs(iris,pixs=2)

## a really huge dataset
if(require(SwissAir)) {
  data(AirQual)

  ## low correlation
  ipairs(AirQual[,c("ad.O3","lu.O3","sz.O3")],
         ztransf=function(x){x[x<1] <- 1; log2(x)})

  ipairs(AirQual[,c("ad.NO","lu.NO","sz.NO")],
         ztransf=function(x){x[x<1] <- 1; log2(x)})

  ## high correlation
  Ox <- AirQual[,c("ad.O3","lu.O3","sz.O3")]+
    AirQual[,c("ad.NOx","lu.NOx","sz.NOx")]-
      AirQual[,c("ad.NO","lu.NO","sz.NO")]
  names(Ox) <- c("ad","lu","sz")
  ipairs(Ox, ztransf=function(x){x[x<1] <- 1; log2(x)})

  ## cf. ?AirQual for the explanation of the physical and
  ## chemical background
} else print("Package SwissAir is not available")

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(IDPmisc)
Loading required package: grid
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IDPmisc/ipairs.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ipairs
> ### Title: Image Scatter Plot Matrix for Large Datasets
> ### Aliases: ipairs
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## Small numbers of different values are plotted nicer
> ## when converted to factors
> AQ <- airquality
> AQ$Month <- as.factor(AQ$Month)
> 
> zmax <- ipairs(AQ, pixs=2, main="Air Quality")
> ipairs(AQ, pixs=2, zmax=zmax, main="Air Quality",border=TRUE)
> 
> ## example with factors
> ipairs(iris,pixs=2)
> 
> ## a really huge dataset
> if(require(SwissAir)) {
+   data(AirQual)
+ 
+   ## low correlation
+   ipairs(AirQual[,c("ad.O3","lu.O3","sz.O3")],
+          ztransf=function(x){x[x<1] <- 1; log2(x)})
+ 
+   ipairs(AirQual[,c("ad.NO","lu.NO","sz.NO")],
+          ztransf=function(x){x[x<1] <- 1; log2(x)})
+ 
+   ## high correlation
+   Ox <- AirQual[,c("ad.O3","lu.O3","sz.O3")]+
+     AirQual[,c("ad.NOx","lu.NOx","sz.NOx")]-
+       AirQual[,c("ad.NO","lu.NO","sz.NO")]
+   names(Ox) <- c("ad","lu","sz")
+   ipairs(Ox, ztransf=function(x){x[x<1] <- 1; log2(x)})
+ 
+   ## cf. ?AirQual for the explanation of the physical and
+   ## chemical background
+ } else print("Package SwissAir is not available")
Loading required package: SwissAir
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>