% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metalcor.R
\name{metalcor}
\alias{metalcor}
\title{Meta-Analysis of Correlated Genetic Association Studies}
\usage{
metalcor(studies, median = TRUE, df = 1, tol = 1e-08)
}
\arguments{
\item{studies}{A list of \code{S} studies, each of which is a data frame with the following required columns: \code{id}, \code{chr}, \code{pos}, \code{beta}, \code{se}, \code{n}.
Column names have to match exactly.
\code{id} is used to match variants between studies (they must be unique for different variants, and be the same for the same variant).
\code{chr} and \code{pos} are used solely to sort variants after the studies have been merged.
\code{beta} and \code{se} are required to perform meta-analysis.
\code{n} is used to report locus-specific total sample sizes under missingness.}

\item{median}{If \code{TRUE} (default), estimates correlations from sample medians instead of means.
Passed to \code{\link[=estimate_R]{estimate_R()}}.}

\item{df}{Degree of freedom for calculating the p-values from the z-scores (default of 1 is best practically always).}

\item{tol}{Determinant tolerance for singularity test of R estimate}
}
\value{
A list with two named elements:
\itemize{
\item \code{assoc}: the meta-analyzed study, a tibble with columns \code{id}, \code{chr}, \code{pos}, \code{n}, \code{n_studies}, \code{beta}, \code{se}, \code{z}, and \code{p}; sorted by \code{chr} and \code{pos}.
\item \code{R}: the \code{S}-by-\code{S} estimated z-score covariance matrix
}
}
\description{
This function accepts the summary statistics from several studies, estimates their z-score correlation matrix, and performs the meta-analysis taking those correlations into account.
}
\examples{
# construct two toy studies just to run example, with minimal columns
study1 <- data.frame(
  id = paste0( 'rs', 1:5 ),
  chr = 1,
  pos = 1:5,
  n = 2000,
  beta = rnorm( 5 ),
  se = rnorm( 5 )
)
# note the second study is missing the 5th SNP, this is fine
study2 <- data.frame(
  id = paste0( 'rs', 1:4 ),
  chr = 1,
  pos = 1:4,
  n = 5000,
  beta = rnorm( 4 ),
  se = rnorm( 4 )
)

# gather the studies in a list
studies <- list( study1, study2 )
# this performs the meta-analysis modeling covariance!
out <- metalcor( studies )
# this is the meta-analyzed association table
out$assoc
# and this is the estimated study covariance matrix
out$R

}
\seealso{
\code{\link[=estimate_R]{estimate_R()}}
}
