Description Usage Arguments Details Value Author(s) Examples
View source: R/keepMaxStatRow.R
A common task in expression analysis is to collapse multiple features that are mapped to the same gene by some statistic. This function does this job by keeping the matrix row (normally features) with the higheest statistic specified by the user.
1 2 3 4 5 6 7 8 |
matrix |
A numeric matrix |
keys |
A vector of character giving the keys the rows are mapped to. A common scenario is that each row represents one probeset, while the vector keys give the genes that the probesets are mapped to. Thus keys can be redundant, namely multiple probesets can map to the same gene. |
keepNArows |
Logical, whether rows with |
stat |
The function to calculate the univariate statistic. By default
the |
levels |
How should the information of the levels of keys, e.g. unique
keys, be kept. |
... |
Other parameters passed to the |
isMaxStatRow
returns a logical vector, with rows with maximal
statistics each key as TRUE
and otherwise as FALSE
.
keepMaxStatRowInd
returns the integer indices of such rows. Finally
keepMaxStatRow
returns the resulting matrices.
For use see examples
A numeric matrix with rows mapped to unique keys, selected by the maximum statistics. See examples below
Jitao David Zhang <jitao_david.zhang@roche.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | myFun1 <- function(x) mean(x, na.rm=TRUE)
myFun2 <- function(x) sd(x, na.rm=TRUE)
mat1 <- matrix(c(1,3,4,-5,
0,1,2,3,
7,9,5,3,
0,1,4,3), ncol=4, byrow=TRUE)
keys1 <- c("A", "B", "A", "B")
isMaxStatRow(mat1, keys1, stat=myFun1)
isMaxStatRow(mat1, keys1, stat=myFun2)
keepMaxStatRowInd(mat1, keys1, stat=myFun1)
keepMaxStatRowInd(mat1, keys1, stat=myFun2)
keepMaxStatRow(mat1, keys1, stat=myFun1)
keepMaxStatRow(mat1, keys1, stat="myFun2")
keepMaxStatRow(mat1, keys1, stat="myFun2", levels="discard")
keepMaxStatRow(mat1, keys1, stat="myFun2", levels="attribute")
mat2 <- matrix(c(1,3,4,5,
0,1,2,3,
7,9,5,3,
0,1,4,3,
4,0,-1,3.1,
9,4,-3,2,
8,9,1,2,
0.1,0.2,0.5,NA,
NA, 4, 3,NA), ncol=4, byrow=TRUE,
dimnames=list(LETTERS[1:9], NULL))
keys2 <- c("A", "B", "A", "B", NA, NA, "C", "A", "D")
isMaxStatRow(mat2, keys2, keepNArows=FALSE, stat=myFun1)
keepMaxStatRowInd(mat2, keys2, keepNArows=FALSE, stat=myFun1)
keepMaxStatRow(mat2, keys2, keepNArows=FALSE, stat=myFun1)
keepMaxStatRow(mat2, keys2, keepNArows=TRUE, stat=myFun1)
keepMaxStatRow(mat2, keys2, keepNArows=TRUE, stat=myFun1, levels="discard")
keepMaxStatRow(mat2, keys2, keepNArows=TRUE, stat=myFun1, levels="attribute")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.