knitr::opts_chunk$set(collapse = T, comment = "#>", echo = T)
#knitr::opts_chunk$set(echo = TRUE)

Introduction

The purpose of this package is to take a series of data sets containing $p$ biomarkers as represented in the columns of the data frame, and calculate a series of p-values for each column, as well as run a pooling method based on user input.

Installing

There are two options to install MetaAnalysis package from source,

  1. Open terminal application and enter command:
R CMD INSTALL [PATH_TO_FILE]/MetaAnalysis_0.1.tar.gz
  1. In RStudio, enter command:
install.packages("[PATH_TO_FOLDER]/MetaAnalysis_0.1.tar", repos = NULL, type="source")

Workflow

The package will not take less than two data frames and no more than five. In addition, the package will not run unless the number of columns between all the data frames is the same. The amount rows in each data set do not have to be the same, however, each row must be organized into a group in a column placed before all the biomarkers.

For each biomarker, the package will check the group difference (and gets a p-value). The statistical test this package choose to use will be described in next section.

The second function of this package is to take the collection of p-values and pool them by biomarker. Each biomarker will undergo pooling based on four tests (As highlighted in the “Pooling Methods” Section), the Fisher, Stouffer, Minimum p-value (minP), and Maximum p-value (maxP). If one of some of these tests is specified in the “method” parameter, the package will then provide a matrix of p-values based on these tests.

Statistical Tests

As the final result, user can see the statistical test performed, one way anova is denoted as Anova, Kruskal Wallis test as Kruskal, equal variance T test as T(eq), unequal variance T test as T(uneq), and Wilcox rank sum test as Wilcox.

Pooling Methods

  1. Fisher's Method The Fisher's method sums up the log-transformed p-values obtained from individual studies. Fisher's statistic $\chi_{Fisher}^{2} = -2 \sum_{i=1}^K \log(p_i)$ follows a $\chi^{2}$ distribution with $2K$ degrees of freedom under the null hypothesis. Smaller p-values contribute larger scores to the Fisher's statistic.

  2. Stouffer's Method Stouffer's methods sums the inverse normal trasformed p-values. Stouffer's statistic $T = \sum_{i=1}^K \frac{\Phi^{-1}(p_i)}{\sqrt{K}}$ ( $\Phi$ is the cdf of a standard normal distribution) follows a standard normal distribution under the null hypothesis. Similar to Fisher's method, smaller p-values contribute more to the Stouffer's score.

  3. Minimum p-value Method The minimun p-value method take the minimum p-value among the $K$ studies as the test statistic. It follows a beta distribution with degrees of freedom $\alpha = 1$ and $\beta = K$ under the null hypothesis.

  4. Maximum p-value Method The maximum p-value method take the maximum p-value as the test statistic. It follows a beta distribution with degrees of freedom $\alpha = K$ and $\beta = 1$ under the null hypothesis.

You can use: meta.analysis(...,method) to compute pooled p value for different biomarkers by using four different methods: Fisher, Stouffer, Maxium p value and Minium P value.

method can be a single string or a vector of the collection of the following options:

Pooling Commands

Please note that setting the type is case sensitive, and will default to all methods, i.e. c('Fisher', 'Stouffer', 'minP', 'maxP')

Example

  1. Input dataframes
    • The number of input dataframes should between 2 and 5.
    • Each dataframe should have the same number of columns.
    • The function mata.analysis() will automatically check if all inputs meet requirements.
    • Any row with missing values will be dropped.
    • If not specified, the default level of confidence is $\alpha = 0.05$.

Consider a scenario: We have collected data from 3 different institutions, each data belongs to a certain group, and have 5 numerical values of it's different biomarkers. We simulate data for illustration.

library(MetaAnalysis)
set.seed(123)  ## Fix seed for reproducible result
p <- 5
# dataframe1 has 5 columns and 3 groups
data1 <- data.frame(group=sample(1:3,200,replace=TRUE),matrix(rnorm(p*200),ncol=p))

head(data1)

data2 and data3 are generated in the same fashion.

# dataframe1 has 5 columns and 2 groups
data2 <- data.frame(group=sample(1:2,150,replace=TRUE),matrix(rnorm(p*150),ncol=p))
# dataframe1 has 5 columns and 4 groups
data3 <- data.frame(group=sample(1:4,400,replace=TRUE),matrix(rnorm(p*400),ncol=p))

To do the meta analysis using this package, input dataframes sequentially in the first three parameters, and specify pooling method/methods to use if wanted (as introduced in previous paragraph). We can also customize significance level.

res = meta.analysis(data1, data2, data3, method=c('Fisher', 'Stouffer', 'minP', 'maxP'), alpha = 0.05)

Input data error: if number of dataframes are out of limit, or number of columns are not equal.

Any row with missing values will be dropped in the package

  1. Obtaining p-value matrix
    • To view the p-values matrix, one can access the p.matrix component of resluting variable.
res$p.matrix
  1. Tests performed
    • User can also get a record of the results from tests performed, which is corresponding to p-value matrix.
res$test.performed
  1. Pooling p-values
    • Finally, show the pooled p-value by accessing pooled.p.matrix element.
res$pooled.p.matrix

Example (Comparison)

Suppose we want to see the visualized "trend" between each pooling method, we can plot the matrix using matplot function

set.seed(123)
p <- 20
data1 <- data.frame(group=sample(1:3,20,replace=TRUE), matrix(rnorm(p*20),ncol=p))
data2 <- data.frame(group=sample(1:2,15,replace=TRUE), matrix(rnorm(p*15),ncol=p))
data3 <- data.frame(group=sample(1:4,40,replace=TRUE), matrix(rnorm(p*40),ncol=p))
data4 <- data.frame(group=sample(1:3,50,replace=TRUE), matrix(rnorm(p*50),ncol=p))
data5 <- data.frame(group=sample(1:2,40,replace=TRUE), matrix(rnorm(p*40),ncol=p))

res = meta.analysis(data1, data2, data3, data4, data5,
                    method=c('Fisher',  'maxP', 'Stouffer', 'minP'), 
                    alpha = 0.05)
pooled.p.matrix = res$pooled.p.matrix

matplot(t(pooled.p.matrix), type='l', col = c('black', 'green', 'red', 'blue'), lty = 'solid')
legend(0, 0, inset=c(-10,-10), legend = rownames(pooled.p.matrix), xpd = T, col = c('black', 'green', 'red', 'blue'), lty = 'solid')


mashihill/MetaAnalysis documentation built on May 10, 2019, 2:44 p.m.