pval2index {mdgsa} | R Documentation |
After a genomic test, p-values are numerical indexes which account for certain biological characteristic. By definition p-values are bounded between zero and one, but this may not be suitable as an index. Moreover, p-values are always derived form a statistic which sign may be important. The function helps transforming the p-value and its associated statistic into a ranking index.
pval2index(pval, sign, names = NULL, log = TRUE, offset, verbose = TRUE)
pval |
a vector or matrix of p-values. |
sign |
a vector or matrix of signs associated to the p-values. |
names |
a character vector of the names of the features. |
log |
= TRUE |
offset |
value used to replace p-values equal to zero |
verbose |
verbose |
The default transformation is (-1) * log (pval) * sign (sign). When log = FALSE the transformation is (1 - pval) * sign (sign).
If sign
is missing all p-values are associated wit a positive sign.
Missing values are allowed and return NA values.
An offset
may be provided to replace p-values equal to zero
when log = TRUE
.
In such way infinite values are not generated.
If the offset
parameter is not provided,
the minimum p-value other than zero is used for the replacement.
You can explicitly specify offset = 0
if you want Inf
values to be returned.
By default the names of the output vector (or row names in a matrix)
are those of pval
or sign
.
If names
is provided, then it is used instead.
A transformed index. A vector or matrix, depending on the input parameters.
David Montaner dmontaner@cipf.es
my.statistic <- rnorm (1000) my.pvalue <- 2 * pnorm (my.statistic) my.pvalue[my.pvalue > 1] <- 2 - my.pvalue[my.pvalue > 1] index <- pval2index (pval = my.pvalue, sign = my.statistic) #par (mfrow = c (1,2)) #plot (my.statistic, my.pvalue) #plot (my.statistic, index) ## Zero p-values p <- c (0:10)/10 p pval2index (p) pval2index (p, offset = 0) pval2index (p, offset = 0.000001) ## Missing p-values p <- c(0:10, NA)/10 p pval2index (p) pval2index (p, offset = 0) pval2index (p, offset = 0.000001) pval2index (p, log = FALSE) pval2index (p, offset = 0, log = FALSE) ## Matrix p <- matrix (c(0:10, NA)/10, ncol = 3) p pval2index (p) pval2index (p, offset = 0) pval2index (p, offset = 0.000001) pval2index (p, log = FALSE) pval2index (p, offset = 0, log = FALSE)