Skip to contents

This function is used to calculate the combined P value and Z score from multiple P values. it can also be used to convert P value to Z score.

Usage

combinePvalVector(pvals, method = "Stouffer", signed = TRUE, twosided = TRUE)

Arguments

pvals

A vector of numeric, P values to be combined or converted to Z scores

method

Character, method used to combine P values: "Stouffer" (the default) or "Fisher".

signed

Logical, whether the input P values are signed or not. Usually they are signed by folder change. Default: TRUE.

twosided

Logical, whether the input P values are two-sided. If FALSE, the input P values will be treated as one-tailed. Default: TRUE.

Value

A vector containing "Z-statistics" and "P.Value".

Examples

## 1. combine P values from a vector
combinePvalVector(c(0.1,1e-3,1e-5), method = 'Stouffer')
#> Z-statistics      P.Value 
#> 5.399699e+00 6.675264e-08 

if (FALSE) { # \dontrun{
## 2. combine P values from a table
df_Pcombined <- sapply(df$Pval*sign(df$log2FC), function(x) {combinePvalVector(x, twosided = TRUE)[2]})
df_Zscore <- sapply(df$Pval*sign(df$log2FC), function(x) {combinePvalVector(x, twosided = TRUE)[1]})
} # }