geneJAM: Cluster multiple traits via polygenic scores

View source: R/geneJAM.R

geneJAMR Documentation

Cluster multiple traits via polygenic scores

Description

This function clusters traits that share some genetic component via polygenic scores (PSs). It fits a sparse precision matrix via graphical lasso. The regularisation path is computed for the lasso penalty at a grid of values for the regularisation parameter rho. The clusters are used to specify the structure of the error covariance matrix of a GLS model and the feasible GLS estimator is used for estimating the unknown parameters in a linear regression model with a certain unknown degree of correlation between the residuals.

Usage

geneJAM(
  x,
  y,
  rho = NULL,
  nrho = ifelse(is.null(rho), 20, length(rho)),
  logrho = FALSE,
  rho.min.ratio = 0.001
)

Arguments

x

Input matrix, of dimension nobs x nvars of PGSs with nvars = nouts. Can be in sparse matrix format.

y

Quantitative response matrix, of dimension nobs x nouts.

rho

(Non-negative) regularisation parameter for lasso passed to glasso. rho=0 means no regularisation. Can be a scalar (usual) or a symmetric nouts by nouts matrix, or a vector of length nouts. In the latter case, the penalty matrix has jkth element sqrt(rho[j]*rho[k]).

nrho

The number of rho values - default is 40.

logrho

Logical flag for log transformation of the rho sequence. Default is logrho = FALSE.

rho.min.ratio

Smallest value for rho, as a fraction of rho.max, the (data derived) entry value (i.e. the smallest value for which all coefficients are zero) - default is 10e-04.

Details

...

Value

An object of class "geneJAM" is returned.

call

The call that produced this object.

xi

A matrix of intercepts of dimension nouts x length(rho)

beta

A matrix of coefficients for the PSs of dimension nouts x length(rho)

A

A length(rho) list of estimated adjacency matrices A of 0s and 1s, where A_ij is equal to 1 iff edges i and j are adjacent and A_ii is 0.

P

A length(rho) list of estimated precision matrices (matrix inverse of correlation matrices).

Sigma

A length(rho) list of estimated correlation matrices.

rho

The actual sequence of rho values used.

PS

Polygenic scores used. If scores = FALSE they are computed by ps.geneJAM

logrho

Logical flag for log transformation of the rho sequence. Default is logrho = FALSE.

nobs

Number of observations.

xiStderr

Standard error of coefficients xi.

betaStderr

Standard error of coefficients beta.

betaSD

Standard error of the mean of coefficients beta for clustered traits.

betaSD0

Standard error of the mean of all coefficients beta.

rho.min

Value of rho that gives minimum non-zero betaSD.

Examples

N <- 1000 #
q <- 10 #
p <- 1000 #
set.seed(1)
# Sample 1
X0 <- matrix(rbinom(n = N*p, size = 2, prob = 0.3), nrow=N, ncol=p)
B <- matrix(0, nrow = p, ncol = q)
B[1, 1:2] <- 1
B[3, 3] <- 2
y0 <- X0 %*% B + matrix(rnorm(N*q), nrow = N, ncol = q)
#y0 <- apply(y0, 2, scale)
beta <- ps.geneJAM(X0, y0)$beta
# Sample 2
X <- matrix(rbinom(n = N*p, size = 2, prob = 0.3), nrow=N, ncol=p)
y <- X %*% B + matrix(rnorm(N*q), nrow = N, ncol = q)
#y <- apply(y, 2, scale)
#Sigma <- diag(1, q)
#Sigma[1, 2] <- Sigma[2, 1] <- .8
#y <- X %*% B + MASS::mvrnorm(n = N, mu = rep(0, q), Sigma = Sigma)
x <- X %*% beta
#x <- MASS::mvrnorm(n = N, mu = rep(0, q), Sigma = diag(1, q))
###
pc <- geneJAM(x, y)


abuchardt/EdGwas documentation built on Nov. 28, 2022, 11:49 a.m.