binMatrix: Binned representation of a matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/binMatrix.R

Description

Groups each column in a matrix into several bins of a given length for better (and faster) data plotting

Usage

1
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

binTimeSeries

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
### 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)

FCSlib documentation built on Nov. 27, 2020, 5:09 p.m.

Related to binMatrix in FCSlib...