The ldsc function is used for LDSC analysis
ldsc(
Glist = NULL,
ldscores = NULL,
sets = NULL,
method = "regression",
residual = FALSE,
z = NULL,
b = NULL,
seb = NULL,
af = NULL,
stat = NULL,
tol = 1e-08,
n = NULL,
intercept = TRUE,
what = "h2",
maxZ2 = NULL,
SE.h2 = FALSE,
SE.rg = FALSE,
blk = 200
)
Returns a matrix of heritability estimates when what="h2", and if SE.h2=TRUE standard errors (SE) and significance levels (P) are returned. If what="rg" an n-by-n matrix of correlations is returned where the diagonal elements being h2 estimates. If SE.rg=TRUE a list is returned with n-by-n matrices of genetic correlations, estimated standard errors and significance levels.
list of information about genotype matrix stored on disk
vector of LD scores (optional as LD scores are stored within Glist)
Optional list specifying sets of SNPs for mapping.
the regression method to use, options include "regression", "bayesC", "bayesR".
logical if TRUE then add a residual that capture the h2 not explained by the sets
matrix of z statistics for n traits
matrix of marker effects for n traits if z matrix not is given
matrix of standard errors of marker effects for n traits if z matrix not is given
vector of allele frequencies
dataframe with marker summary statistics
smallest value for h2
vector of sample sizes for the traits (element i corresponds to column vector i in z matrix)
logical if TRUE the LD score regression includes intercept
either computation of heritability (what="h2") or genetic correlation between traits (what="rg")
maximum value for squared value of z-statistics
logical if TRUE standard errors and significance for the heritability estimates are computed using a block jackknife approach
logical if TRUE standard errors and significance for the genetic correlations are computed using a block jackknife approach
numeric size of the blocks used in the jackknife estimation of standard error (default = 200)
Peter Soerensen
Palle Duun Rohde
# Plink bed/bim/fam files
#bedfiles <- system.file("extdata", paste0("sample_chr",1:2,".bed"), package = "qgg")
#bimfiles <- system.file("extdata", paste0("sample_chr",1:2,".bim"), package = "qgg")
#famfiles <- system.file("extdata", paste0("sample_chr",1:2,".fam"), package = "qgg")
#
## Summarize bed/bim/fam files
#Glist <- gprep(study="Example", bedfiles=bedfiles, bimfiles=bimfiles, famfiles=famfiles)
#
## Filter rsids based on MAF, missingness, HWE
#rsids <- gfilter(Glist = Glist, excludeMAF=0.05, excludeMISS=0.05, excludeHWE=1e-12)
#
## Compute sparse LD (msize=size of LD window)
##ldfiles <- system.file("extdata", paste0("sample_chr",1:2,".ld"), package = "qgg")
##Glist <- gprep(Glist, task="sparseld", msize=200, rsids=rsids, ldfiles=ldfiles, overwrite=TRUE)
#
#
##Simulate data
#W1 <- getG(Glist, chr=1, scale=TRUE)
#W2 <- getG(Glist, chr=2, scale=TRUE)
#W <- cbind(W1,W2)
#causal <- sample(1:ncol(W),5)
#b1 <- rnorm(length(causal))
#b2 <- rnorm(length(causal))
#y1 <- W[, causal]%*%b1 + rnorm(nrow(W))
#y2 <- W[, causal]%*%b2 + rnorm(nrow(W))
#data1 <- data.frame(y = y1, mu = 1)
#data2 <- data.frame(y = y2, mu = 1)
#X1 <- model.matrix(y ~ 0 + mu, data = data1)
#X2 <- model.matrix(y ~ 0 + mu, data = data2)
## Linear model analyses and single marker association test
#maLM1 <- lma(y=y1, X=X1,W = W)
#maLM2 <- lma(y=y2,X=X2,W = W)
#
## Compute heritability and genetic correlations for trait 1 and 2
#z1 <- maLM1[,"stat"]
#z2 <- maLM2[,"stat"]
#z <- cbind(z1=z1,z2=z2)
#h2 <- ldsc(Glist, z=z, n=c(500,500), what="h2")
#rg <- ldsc(Glist, z=z, n=c(500,500), what="rg")
Run the code above in your browser using DataLab