binMatrix {FCSlib} | R Documentation |
Binned representation of a matrix
Description
Groups each column in a matrix into several bins of a given length for better (and faster) data plotting
Usage
binMatrix(f, lineTime, nIntervals, columns, mode = "mean", plot = TRUE)
Arguments
f |
A vector or a matrix |
lineTime |
Line (row) acquisition rate (in seconds) |
nIntervals |
Number of intervals into which the all columns will be grouped |
columns |
Number of columns of the resulting binned matrix |
mode |
Set to "mean" (default) or "sum" to average or sum all the points in every interval, respectively |
plot |
Boolean, set to TRUE (default) to plot the result |
Details
This function groups all the points in each column of the matrix 'f' into 'nIntervals' bins of length = length(f)/nIntervals. Then, averages or sums all of the points in each bin and plots the result. If 'f' is a vector, 'columns' is used to build the resulting matrix. If 'f' is a matrix, then 'columns' takes the value of the number of columns in 'f'.
Value
A matrix of 'nIntervals' rows
Author(s)
Alejandro Linares
See Also
Examples
### Please navigate to
### (https://github.com/FCSlib/FCSlib/tree/master/Sample%20Data)
### to find this sample data
# Automatic plot
x <- read.table("Pax.dat")
x <- binMatrix(x[,1], lineTime = 1e-3, nIntervals = 500,
columns = 64, mode = "mean", plot = T)
# Manual plot (useful for adding custom labels)
x <- read.table("Pax.dat")
x <- binMatrix(x[,1], lineTime = 1e-3, nIntervals = 500,
columns = 64, mode = "mean", plot = F)
image.plot(x)