redimMatrix {epistack} | R Documentation |
Reduce the input matrix size by applying a summary function on cells to be fused.
redimMatrix( mat, target_height = 100, target_width = 100, summary_func = function(x) mean(x, na.rm = TRUE), output_type = 0, n_core = 1 )
mat |
the input matrix. |
target_height |
height of the output matrix
(should be smaller than or equal to |
target_width |
width of the output matrix
(should be smaller than or equal to |
summary_func |
how to summerize cells? A function such has
|
output_type |
Type of the output, to be passed to |
n_core |
number of core to use for parallel processing. |
This function is used to reduce matrix right before plotting them in order to avoid overplotting issues as well as other plotting artefacts.
a resized matrix of size target_width
x target_height
where the summary_fun
was apply
to adjacent cells.
data("stackepi") mat <- S4Vectors::mcols(stackepi) whichCols <- grepl("^window_", colnames(mat)) mat <- as.matrix(mat[, whichCols]) dim(mat) smallMat <- redimMatrix(mat, target_height = 10, target_width = ncol(mat)) dim(smallMat) mat <- matrix(sample(1:40,100,replace=TRUE),nrow=10,ncol=10) dim(mat) smallMat <- redimMatrix(mat, target_height = 5, target_width = ncol(mat), summary_func = function(x) max(x, na.rm = TRUE)) dim(smallMat)