Learn R Programming

GSNA (version 0.1.4.2)

nzLog10: nzLog10

Description

Utility function to safely (non-zero) log10 transform p-values that are bounded at 0, and may be zero or may be rounded to zero in certain contexts. To get around this, prior to applying a log10 transformation the function adds a very small pseudocount to all the values if any are detected to be zero. This avoids the generation of negative infinities. (See details, below.)

Usage

nzLog10(x, quiet = FALSE, pseudocount_frxn = 0.5)

Value

A vector containing transformed values.

Arguments

x

A numerical vector containing non-negative values.

quiet

A boolean that tells the script to suppress warning messages. (default: FALSE. This does not suppress errors, however.)

pseudocount_frxn

A numerical value that sets the added pseudocount as a fraction of the minimum non-zero value. (default: 0.5)

Details

Prior to log10 transformation, this function first scans for any zeros in the input vector. If it finds any, it warns that zeros have been detected in the raw statistic, and that a pseudocount will be added. To do this the function adds a fraction of the minimum non-zero value to the values in x. (The old version of this function, nzLog10.old() determined the value of the pseudocount in a much more complex way. This is a simplification here.)

Examples

Run this code

p_vals <- c( 0.5, 0.001, 0.00001, 5e-19, 6.24e-23, 0 )
nzLog10( p_vals )

Run the code above in your browser using DataLab