Skip to content

Commit

Permalink
version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Aron Eklund authored and gaborcsardi committed Aug 15, 2011
0 parents commit 5d81c46
Show file tree
Hide file tree
Showing 24 changed files with 1,853 additions and 0 deletions.
19 changes: 19 additions & 0 deletions DESCRIPTION
@@ -0,0 +1,19 @@
Package: squash
Version: 1.0.1
Date: 2011-08-15
Title: Color-based plots for multivariate visualization
Author: Aron Eklund
Maintainer: Aron Eklund <eklund+squash@cbs.dtu.dk>
Depends: grDevices
Description: This package provides functions for color-based
visualization of multivariate data, i.e. colorgrams or
heatmaps. Lower-level functions are provided to map numeric
values to colors, display a matrix as an array of colors, and
draw color keys. Higher-level plotting functions are provided
to generate a bivariate histogram, a dendrogram aligned with a
color-coded matrix, a triangular distance matrix, and more.
License: Artistic-2.0
URL: http://www.cbs.dtu.dk/~eklund/squash/
Packaged: 2012-10-29 08:59:49 UTC; ripley
Repository: CRAN
Date/Publication: 2012-10-29 08:59:49
23 changes: 23 additions & 0 deletions MD5
@@ -0,0 +1,23 @@
5edde01db53920785ab64fa964449afb *DESCRIPTION
6dbf5337a68b3906b42c512850aa973c *NAMESPACE
901118a222919be6fe3036ca95359e18 *NEWS
df5ecd94bce28dd57ce098b2456a400d *R/distogram.R
924597a1476cdd0f705eccde4797aa24 *R/squash.R
4939e0848ba78f083371cc51179f2000 *man/ColorPalettes.Rd
f7ea3726e2d458adc83260319d1ab8ef *man/cimage.Rd
11b8be856db2849fbc8ff4c1943850ae *man/cmap.Rd
a872f24a0494ed79599773bfdad56867 *man/colorgram.Rd
e83e81481241ce5651dba79c2642319f *man/corrogram.Rd
0a5616faaa5896b6e0f6d2deb15262bd *man/dendromat.Rd
f761c12896121179aba382303b418aec *man/diamond.Rd
1b52082a0e2e248e62a5624c8f052777 *man/distogram.Rd
62d384871fc3fd0056da717f8c01876d *man/hist2.Rd
ac1864eebb9c47bb398a7278481a40fd *man/hkey.Rd
310aa50eda0769de6a794043499c2b30 *man/makecmap.Rd
5a7eb8b7bc8ef220e793b97b1637fb92 *man/matapply.Rd
d1dec50054bc2880f9dbaf3972808556 *man/prettyInt.Rd
c6ceaba828c5db7b2ab8d78aef8d8c49 *man/savemat.Rd
7a7f36999bb0a5cf9ea49ad73f52b847 *man/squashgram.Rd
7a848b30dd989f0a1f933f3761f52cc4 *man/trianglegram.Rd
23137457888be0df19d17511c72d44fe *man/xyzmat.coords.Rd
a91a61521429f5efc2f235cccea0f99a *man/xyzmat2xyz.Rd
10 changes: 10 additions & 0 deletions NAMESPACE
@@ -0,0 +1,10 @@
# Default NAMESPACE created by R
# Remove the previous line if you edit this file

# Export all names
exportPattern(".")

# Import all packages listed as Imports or Depends
import(
grDevices
)
192 changes: 192 additions & 0 deletions NEWS
@@ -0,0 +1,192 @@
Squash NEWS


Changes in version 1.0.1 (2011-08-15)

- First CRAN release
- "hist2" now has a new argument "breaks", which defaults to "prettyInt"
- Fixed bug in "cimage" in which axes were plotted when add=TRUE
- Fixed bug in "makecmap" causing domain extension into positive numbers when x is all negative
- Fixed bug in which "prettyLog" could return only a single value
- Add check for zero-length x in "prettyInt" and "prettyLog" to match behavior of "pretty"
- "prettyInt" now performs better when x includes all of {zero, negative numbers, positive numbers}
- In "makecmap", the old argument "center" is now called "symm" (for symmetric)
- "makecmap" gets a ... argument, passed to "breaks"
- "dendromat" now ends with par(usr) set to c(0,1,0,1)) instead of something unpredictable; this should make legend placement a bit easier.
- "dendromat" now ends by resetting the clipping region, so "vkey" can be used afterwards.


Changes in version 1.0.0 (2011-08-11)

- MAJOR update, with several function names *changed* to improve clarity; sorry for any inconvenience
- The previous "colormap" is now called "makecmap"
- The previous "num2col" is now called "cmap"
- The previous "raster" is now called "cimage"
- The option "trueRaster" is now called "useRaster" for consistency with the standard function "image".
- Remove the old "orangeblue"
- The old "orangeblue2" is now "blueorange"
- The old "darkredblue" is slightly adjusted to make the extremes distinguishable and is now called "darkbluered"
- New color palette "bluered".
- The old function "squash" is now called "matapply"
- The old function "mat2bm" is now called "savemat"
- Improvements in automatic axis naming in squashgram and matapply


Changes in version 0.4.4 (2011-08-09)

- Documentation improvements.
- Rename "pretty.log" -> "prettyLog" to avoid S3 method warnings
- Rename "pretty.int" -> "prettyInt"
- Added argument "do.dev.off" to function "mat2bm"
- 'squashgram' now uses xyz.coords, which can change the automatic axis labels
- Some 'squash', 'squashgram', and 'hist2' parameters are now NULL by default: xlim, ylim, xbreaks, ybreaks
- 'raster' now takes arguments 'xlabels', 'ylabels', and 'axes'
- Removed the mostly useless functions 'raster2' and 'colorgram2'


Changes in version 0.4.3 (2011-02-21)

- "dendromat" now looks for names in argument "x" if "labRow" is NULL.


Changes in version 0.4.2 (2010-11-01)

- Added function "raster2"; like "raster" but with categorical axes.
- Added function "colorgram2"; like "colorgram" but with categorical axes.


Changes in version 0.4.1 (2010-10-26)

- Replace "xyz.coords.matrix" with "xyzmat.coords" and "xyzmat2xyz".
- "raster" and "colorgram" now use "xyzmat.coords" as front end for input.
- Fix bug in "colormap" that could cause errors when pretty.log is used with negative values.
- Remove function "pretty.auto"
- New argument "small" in "pretty.log"
- "pretty.log" now deals with negative numbers
- Fixed bug in "pretty.log" that caused it to overshoot the maximum.
- New color palette "coolheat"


Changes in version 0.4.0 (2010-10-21)

- Several major changes!
- Modify "raster" to optionally use the (relatively) new "rasterImage" function from "graphics" package.
- Replace function "matpng" with new function "mat2bm", which works better and supports a few other graphics devices.
- Added function "xyz.coords.matrix".
- "squash" now accepts a matrix as input, using xyz.coords.matrix
- The former "minikey2h" and "minikey2v" have been replaced by "hkey" and "vkey", which are similar but have slightly different arguments
- Remove functions "minikey", "keyPlus", and "drawKey"
- "colorgram" and "distogram" updated to call hkey and vkey
- Replaced function "triplotCol" with "trianglegram", which now accepts new arguments.
- "raster" and "colorgram" no longer accept labels (character) for x and y


Changes in version 0.3.1 (2009-11-04)

- Added function "matpng".


Changes in version 0.3.0 (2009-07-21)

- Added function "orangeblue2"
- Change name of "pretty.pseudolog" to "pretty.log".
- "pretty.int" was broken in several ways, but should be fixed now.
- Removed "pretty.count".
- Added function "pretty.auto".
- "colorgram" now works differently: 1. The parameter "key" now takes numeric values to specify the type of key. 2. Removed parameter "key.width". 3. Added parameter "key.args".


Changes in version 0.2.3 (2009-07-18)

- New functions "minikey2h" and "minikey2v".
- Changed the name of this file to "NEWS" (was "ChangeLog").


Changes in version 0.2.2 (2009-05-05)

- Revert many of the changes to "colormap" made in v. 0.2.0.
- Modified the "pretty.*" functions.
- Removed "int" argument from "colorgram".
- Many other fixes and updates.
- Remove "legend.map".


Changes in version 0.2.1 (2009-05-05)

- Added arguments (xaxp, yaxp, xaxt, yaxt, bty, las) to "raster".
- Added function "pretty.count" and "pretty.pseudolog".


Changes in version 0.2.0 (2009-03-05)

- "colormap" now returns additional list items "n", "center", "equal", "type".
- In "colormap", "x" can be omitted if breakpoints are specified.
- In "colormap", new parameters: "int", "col.zero".
- "Colormap" now can do "integer-based" maps.
- In "colormap", defaults for "right" is now TRUE, which matches the defaults for "cut". (Originally, it was the other way around because this made more sense for integers).
- Added helper functions "pretty.int", "integer.intervals".
- Documentation fixes.
- Added arguments to "dendromat": "border", "cex.lab" (suggested by Chris Workman).
- Added "gap" argument to "dendromat".
- Change "triplotCol" so it only adjusts the right-hand margin by default (and not the other margins).


Changes in version 0.1.9 (2008-12-16)

- Adjust "triplotCol" such that labels fall on 1, 2, 3, ... instead of 1, 3, 5, ...
- Remove "line" parameter from "triplotCol", add "fix.mar" parameter.


Changes in version 0.1.8 (2008-12-12)

- Minor documentation updates.
- Added "diamond", "distogram", "corrogram", "triplotCol", and "miniKey".


Changes in version 0.1.7 (2008-08-05)

- Added color palette "darkredblue".


Changes in version 0.1.6 (2008-05-03)

- Added function "dendromat".
- Misc. documentation fixes.


Changes in version 0.1.5 (2008-03-02)

- Change "raster" to set up plot in normal way (i.e. with "plot"), and remove "..." argument, which was pretty much useless.
- Update "raster" to work work with non-evenly spaced breakpoints/midpoints and non-1 zsize.
- These changes also fix buggy behavior in raster.
- Misc. documentation fixes.


Changes in version 0.1.4 (2008-02-28)

- Added "heat" as a new palette.
- Added "keyPlus" function.
- In "drawKey", changed default las.axis = 1


Changes in version 0.1.3 (2008-02-26)

- Documentation improvements.
- "squash" now uses "xyz.coords" for input, and returns additional list items "xlab", "ylab", and "zlab".
- Similarly, "hist2" now used "xy.coords".
- The argument in "colorgram" formerly called "key.lab" is now called "zlab", for compatibility with "persp". Also, "xlab" and "ylab" are specifically included in the argument list.
- "colorgram" and "raster" now try harder to assign dimension labels.
- "raster" is a bit more flexible with input (but still not ideal).


Changes in version 0.1.2 (2008-02-23)

- A few documentation improvements.
- Several improvements to "drawKey":
- Added "digits" and "by" arguments to control axis formatting.
- Removed "at" argument (use "by" instead).
- Default "las.lab" argument is now 0.
- Default "las.axis" argument is now 2.
- "side" = 1 and "side" = 3 now work.
- By default (i.e., when "by" = NA), the function tries to avoid plotting axis labels on top of each other.

81 changes: 81 additions & 0 deletions R/distogram.R
@@ -0,0 +1,81 @@
# distogram.R
#
# Aron Eklund
#


diamond <- function(x, y = NULL, radius, ...) {
xy <- xy.coords(x, y)
xL <- xy$x - radius
xC <- xy$x
xR <- xy$x + radius
yB <- xy$y - radius
yC <- xy$y
yT <- xy$y + radius
n <- length(xL)
x2 <- rbind(rep.int(NA, n), xC, xL, xC, xR)[-1]
y2 <- rbind(rep.int(NA, n), yB, yC, yT, yC)[-1]
polygon(x2, y2, ...)
}


trianglegram <- function(x, labels = rownames(x),
lower = TRUE, diag = FALSE, right = FALSE,
add = FALSE, xpos = 0, ypos = 0, xlim, ylim, ...) {
if(nrow(x) != ncol(x))
stop("x must be a square matrix")
n <- nrow(x)
if(lower) {
wh <- lower.tri(x, diag = diag)
} else {
wh <- upper.tri(x, diag = diag)
}
## x1, y1 = unrotated coordinates
x1 <- col(x)[wh]
y1 <- row(x)[wh]
## rotated coordinates
if(right) {
x2 <- ( y1 - x1) / 2
y2 <- (x1 + y1) / 2
} else { # right
x2 <- (- y1 + x1) / 2
y2 <- (x1 + y1) / 2
}
x2 <- x2 + xpos
y2 <- y2 + ypos
if(is.null(labels)) labels <- 1:n
if(!add) {
if(missing(xlim)) xlim <- c(-n/2, n/2) + xpos
if(missing(ylim)) ylim <- c(0.5, n + 0.5) + ypos
plot(xlim, ylim, type = 'n',
axes = FALSE, xlab = '', ylab = '', ...)
}
diamond(x2, y2, radius = 0.5, col = x[wh])
if(diag) offset <- 0.5 else offset <- 0
if(right) {
text(0, 1:n, labels = labels, pos = 2, offset = offset, xpd = NA)
} else {
text(0, 1:n, labels = labels, pos = 4, offset = offset, xpd = NA)
}
}


distogram <- function(x, map, n = 10, base = NA, colFn = heat,
key = TRUE, title = NA, ...) {
if(class(x) == 'dist') x <- as.matrix(x)
stopifnot(nrow(x) == ncol(x))
if (missing(map)) {
map <- makecmap(x, n = n, base = base, colFn = colFn)
}
trianglegram(cmap(x, map = map), ...)
if(key) hkey(map = map, title = title)
invisible(map)
}


corrogram <- function(...) {
map <- makecmap(c(-1,1), n = 20, colFn = blueorange, include.lowest = TRUE)
distogram(..., map = map)
}


0 comments on commit 5d81c46

Please sign in to comment.