Learn R Programming

AssocBin (version 1.1-2)

depthFill: Encoding bin features to bin colour fills

Description

These functions all accept a list of bins and return a vector of colours of the same length that encode some feature of the bins. importanceFill is a special case which adjusts the residuals obtained by the binChi function by the variance of each bin to obtain a better normal approximation and then only shades those bins which are greater than 2 standard deviations from the mean with a color ramp that fully saturates for any bins which are greater than a 0.001 standard normal quantile with a Bonferroni correction applied to account for the number of bins.

Usage

depthFill(bins, colrng = c("white", "firebrick"))

residualFill( bins, resFun = binChi, maxRes, colrng = c("steelblue", "white", "firebrick"), breaks = NA, nbr = NA )

importanceFill( bins, nbr = NA, breaks = NA, colrng = c("steelblue", "white", "firebrick") )

Value

A vector of colours the same length as `bins`.

Arguments

bins

list of bins to be visualized

colrng

hue range to be passed to `colorRampPalette` to generate the final hue scale

resFun

function which returns a result with a name element `residuals` that is a numeric vector of the same length as `bins`

maxRes

numeric maximum value of the residuals to maintain the correct origin and scale the saturation correctly, taken to be the maximum observed residual if not provided

breaks

numeric vector of breakpoints to control hues, defaults to breakpoints that indicate Pearson residuals outside the asymptotic 95 percent confidence interval around zero under the null

nbr

number of breakpoints for automatic breakpoint generation if `breaks` is not provided

Functions

  • depthFill(): Fill by depth

  • residualFill(): Fill by residual values

  • importanceFill(): Fill by variance-adjusted chi residuals

Author

Chris Salahub

Details

Shadings

depthFill and residualFill do as indicated: mapping the bin depths and residual colours to saturations applied to the bins.

Examples

Run this code
bin <- makeBin(x = 1:10, y = sample(1:10))
bin2 <- halfSplit(bin, "x")
bin3 <- unlist(lapply(bin2, maxScoreSplit,
                      scorer = chiScores, minExp = 2),
               recursive = FALSE)
plotBinning(bin3, fill = depthFill(bin3)) # all the same depth
plotBinning(bin3, fill = residualFill(bin3)) # chi resids

Run the code above in your browser using DataLab