| Title: | GWAS for Multiple Observations on Related Individuals |
|---|---|
| Description: | Performs genome-wide association studies (GWAS) on individuals that are both related and have repeated measurements. For each Single Nucleotide Polymorphism (SNP), it computes score statistic based p-values for a linear mixed model including random polygenic effects and a random effect for repeated measurements. The computed p-values can be visualized in a Manhattan plot. For more details see Ronnegard et al. (2016) <doi:10.1111/2041-210X.12535> and for more examples see <https://github.com/larsronn/RepeatABEL_Tutorials>. |
| Authors: | Lars Ronnegard [aut, cre] |
| Maintainer: | Lars Ronnegard <[email protected]> |
| License: | GPL |
| Version: | 2.0 |
| Built: | 2026-06-05 07:33:52 UTC |
| Source: | https://github.com/cran/RepeatABEL |
Gets the chromosome numbers.
chromosome(genabel.data)chromosome(genabel.data)
genabel.data |
A GenABEL-like data of class gwaa.data2. |
Returns an array of chromosome numbers
Lars Ronnegard
One method for GRM computations implemented.
compute.GRM(gen.data)compute.GRM(gen.data)
gen.data |
The GenABEL-like object. |
Returns a genomic relationship matrix.
Lars Ronnegard
Constructs the (co)variance matrix for y.
constructV(Z, RandC, ratio)constructV(Z, RandC, ratio)
Z |
The incidence matrix for the random effects column binded with the Cholesky of the GRM |
RandC |
The number of columns in the two matrices combined in Z. |
ratio |
The ratios between random effect variances and the residual variance. |
Returns a (co)variance matrix of y.
Lars Ronnegard
Creates a gwaa.data2 object from input.
Create_gwaa_data2(genotypes, chromosome = NULL, map = NULL, phenotypes = NULL)Create_gwaa_data2(genotypes, chromosome = NULL, map = NULL, phenotypes = NULL)
genotypes |
A matrix with genotype values coded as (0,1,2) or (-1,0,1) |
chromosome |
An array of characters for the chromosomes. Length equal to the number of SNPs. |
map |
An array with the order of the SNPs. |
phenotypes |
A data frame including columns with phenotypes and a column with ids, called "id" |
Returns a gwaa.data2-object.
Lars Ronnegard
Creates a scan.gwaa2 object from the rGLS output.
Create_gwaa_scan2(data, P1df, SNP.eff)Create_gwaa_scan2(data, P1df, SNP.eff)
data |
A gwaa.data2 object |
P1df |
P-values computed from external analysis |
SNP.eff |
Estimated additive SNP effects |
Returns a scan.gwaa2 object.
Lars Ronnegard
Estimates lambda from P-values. Most code copied from the archived GenABEL package
estlambda(data, plot = FALSE, method = "regression", filter = TRUE)estlambda(data, plot = FALSE, method = "regression", filter = TRUE)
data |
An array of P-values |
plot |
Logical. TRUE to produce a plot |
method |
Either "regression" or "median". |
filter |
Logical. If TRUE the extreme P-values are not included in the estimate of lambda. |
Returns a list with estimate and standard error.
Lars Ronnegard
An S4 class to represent GWAS input data
phdataPhenotype information including id
gtdataobject of class snp.data with genotype information
Gets the idnames.
idnames(genabel.data)idnames(genabel.data)
genabel.data |
A GenABEL-like data of class gwaa.data2. |
Returns an array with the names of the individuals (as character).
Lars Ronnegard
Extracts a subset of the data.
keep_gwaa_data(genabel.data, indx.keep = NULL)keep_gwaa_data(genabel.data, indx.keep = NULL)
genabel.data |
A GenABEL-like data of class gwaa.data2. |
indx.keep |
Indeces to extract. |
Lars Ronnegard
Gets the map.
map(genabel.data)map(genabel.data)
genabel.data |
A GenABEL-like data of class gwaa.data2. |
Lars Ronnegard
Gets nids.
nids(genabel.data)nids(genabel.data)
genabel.data |
A GenABEL-like data of class gwaa.data2. |
Returns the number of individuals.
Lars Ronnegard
Creates a Manhattan plot
## S3 method for class 'scan.gwaa2' plot( x, y, ..., ystart = 0, col = c("blue", "green"), sort = TRUE, ylim, main = NULL )## S3 method for class 'scan.gwaa2' plot( x, y, ..., ystart = 0, col = c("blue", "green"), sort = TRUE, ylim, main = NULL )
x |
A scan.gwaa2 object created by the rGLS function |
y |
A parameter not used in the current version |
... |
Possible additional parameters (not used in the current version) |
ystart |
Lowest value on the y-axis |
col |
Default is c("blue","green") |
sort |
Logical. If TRUE the SNPs are sorted before plotting. |
ylim |
Limits of the y-axis |
main |
Plot title |
No return value, called for side effects
Lars Ronnegard
Uses a GenABEL-like object and phenotype data as input. The model is fitted using the hglm function in the hglm package.
preFitModel( fixed = y ~ 1, random = ~1 | id, id.name = "id", genabel.data, phenotype.data, corStruc = NULL, GRM = NULL, Neighbor.Matrix = NULL, verbose = TRUE )preFitModel( fixed = y ~ 1, random = ~1 | id, id.name = "id", genabel.data, phenotype.data, corStruc = NULL, GRM = NULL, Neighbor.Matrix = NULL, verbose = TRUE )
fixed |
A formula including the response and fixed effects |
random |
A formula for the random effects |
id.name |
The column name of the IDs in phen.data |
genabel.data |
An GenABEL-like object including marker information. This object has one observation per individual. |
phenotype.data |
A data frame including the repeated observations and IDs. |
corStruc |
A list specifying the correlation structure for each random effect. The options are: |
GRM |
A genetic relationship matrix. If not specified whilst the |
Neighbor.Matrix |
A neighborhood matrix having non-zero value for an element (i,j) where the observations i and j come from neighboring locations. The diagonal elements should be zero. |
verbose |
If TRUE the progress of the computations is printed. |
Returns a list including the fitted hglm object fitted.hglm, the variance-covariance matrix V and the ratios between estimated variance components for the random effects divided by the residual variance, ratio.
Lars Ronnegard
####### FIRST EXAMPLE USING GRM ############# set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200) Phen.Data <- simulate_PhenData(y ~ 1, genabel.data=Gen.Data, n.obs=rep(4, nids(Gen.Data)), SNP.eff=2, SNP.nr=100, VC=c(1,1,1)) GWAS1 <- rGLS(y ~ 1, genabel.data = Gen.Data, phenotype.data = Phen.Data) plot(GWAS1, main="") summary(GWAS1) #Summary for variance component estimation without SNP effects summary(GWAS1@call$hglm) #The same results can be computed using the preFitModel as follows fixed = y ~ 1 Mod1 <- preFitModel(fixed, random=~1|id, genabel.data = Gen.Data, phenotype.data = Phen.Data, corStruc=list( id=list("GRM","Ind") )) GWAS1b <- rGLS(fixed, genabel.data = Gen.Data, phenotype.data = Phen.Data, V = Mod1$V) plot(GWAS1b, main="Results using the preFitModel function")####### FIRST EXAMPLE USING GRM ############# set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200) Phen.Data <- simulate_PhenData(y ~ 1, genabel.data=Gen.Data, n.obs=rep(4, nids(Gen.Data)), SNP.eff=2, SNP.nr=100, VC=c(1,1,1)) GWAS1 <- rGLS(y ~ 1, genabel.data = Gen.Data, phenotype.data = Phen.Data) plot(GWAS1, main="") summary(GWAS1) #Summary for variance component estimation without SNP effects summary(GWAS1@call$hglm) #The same results can be computed using the preFitModel as follows fixed = y ~ 1 Mod1 <- preFitModel(fixed, random=~1|id, genabel.data = Gen.Data, phenotype.data = Phen.Data, corStruc=list( id=list("GRM","Ind") )) GWAS1b <- rGLS(fixed, genabel.data = Gen.Data, phenotype.data = Phen.Data, V = Mod1$V) plot(GWAS1b, main="Results using the preFitModel function")
It is used to perform genome-wide association studies on individuals that are both related and have repeated measurements. The function computes score statistic based p-values for a linear mixed model including random polygenic effects and a random effect for repeated measurements. A p-value is computed for each marker and the null hypothesis tested is a zero additive marker effect.
rGLS( formula.FixedEffects = y ~ 1, genabel.data, phenotype.data, id.name = "id", GRM = NULL, V = NULL, memory = 1e+08, verbose = TRUE )rGLS( formula.FixedEffects = y ~ 1, genabel.data, phenotype.data, id.name = "id", GRM = NULL, V = NULL, memory = 1e+08, verbose = TRUE )
formula.FixedEffects |
Formula including the response variable and cofactors as fixed effects. |
genabel.data |
A GenABEL-like object including marker information. This object has one observation per individuals. |
phenotype.data |
A data frame including the repeated observations and IDs. |
id.name |
The column name of the IDs in phen.data |
GRM |
An optional genetic relationship matrix (GRM) can be included as input. Otherwise the GRM is computed within the function. |
V |
An optional (co)variance matrix can be included as input. Otherwise it is computed using the hglm function. |
memory |
Used to optimize computations. The maximum number of elements in a matrix that can be stored efficiently. |
verbose |
If TRUE the progress of the computations is printed. |
A generalized squares (GLS) is fitted for each marker given a (co)variance matrix V.
The computations are made fast by transforming the GLS to
an ordinary least-squares (OLS) problem using an eigen-decomposition of V.
The OLS are computed using QR-factorization. If V is not specified then a model
including random polygenic effects and permanent environmental effects is
fitted (using the hglm package) to compute V. A GenABEL-like object (scan.gwaa2 class)
is returned (including also the hglm results).
Let e.g. GWAS1 be an object returned by the rGLS function.
Then a Manhattan plot can be produced by calling plot(GWAS1) and
the top SNPs using summary(GWAS1).
The results from the fitted linear mixed model without any SNP effect included
are produced by calling summary(GWAS1@call$hglm).
Returns a gwaa.scan2-object.
Lars Ronnegard
set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200) Phen.Data <- simulate_PhenData(y ~ 1, genabel.data=Gen.Data, n.obs=rep(4, nids(Gen.Data)), SNP.eff=2, SNP.nr=100, VC=c(1,1,1)) GWAS1 <- rGLS(y ~ 1, genabel.data = Gen.Data, phenotype.data = Phen.Data) plot(GWAS1, main="") summary(GWAS1) #Summary for variance component estimation without SNP effects summary(GWAS1@call$hglm)set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200) Phen.Data <- simulate_PhenData(y ~ 1, genabel.data=Gen.Data, n.obs=rep(4, nids(Gen.Data)), SNP.eff=2, SNP.nr=100, VC=c(1,1,1)) GWAS1 <- rGLS(y ~ 1, genabel.data = Gen.Data, phenotype.data = Phen.Data) plot(GWAS1, main="") summary(GWAS1) #Summary for variance component estimation without SNP effects summary(GWAS1@call$hglm)
An S4 class to represent SNP data
resultsThe results from the rGLS function as a data.frame
lambdaComputed inflation factor as list
idnamesIdnames as character
mapSNP order as numeric
chromosomeThe chromosome name for each SNP as numeric
callThe call made by rGLS as call
familyThe assumed distribution of the outcome. Only "gaussian" allowed.
The function simulates n individuals and p SNPs, with linkage disequilibrium (LD) given by the LD-parameter
simulate_gendata(n = 100, p = 1000, LD = 0.9, n.chrom = 1)simulate_gendata(n = 100, p = 1000, LD = 0.9, n.chrom = 1)
n |
Number of individuals. |
p |
Number of SNPs. |
LD |
An LD-parameter. LD=1 gives complete LD and LD=0 no LD. |
n.chrom |
The size of a simulated SNP.effect. |
Returns a gwaa.data2 object.
Lars Ronnegard
set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200)set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200)
The function takes a GenABEL-like object (class gwaa.data2) as input and generates simulated phenotypic values for related individuals having repeated obserevations.
simulate_PhenData( formula.FixedEffects = y ~ 1, genabel.data, n.obs, SNP.eff = NULL, SNP.nr = NULL, beta = NULL, VC = c(1, 1, 1), GRM = NULL, sim.gamma = FALSE )simulate_PhenData( formula.FixedEffects = y ~ 1, genabel.data, n.obs, SNP.eff = NULL, SNP.nr = NULL, beta = NULL, VC = c(1, 1, 1), GRM = NULL, sim.gamma = FALSE )
formula.FixedEffects |
A formula including the name of the simulated variable as response, and cofactors as fixed effects. |
genabel.data |
A GenABEL-like object of class gwaa.data2. |
n.obs |
A vector including the number of observations per individual. The length of n.obs must be equal to the number if individuals in genabel.data. |
SNP.eff |
The size of a simulated SNP.effect. |
SNP.nr |
The SNP genotype that the SNP effect is simulated on. SNP.nr=i is the i:th SNP. |
beta |
The simulated fixed effects. Must be equal to the number of cofactors simulated (including the intercept term). |
VC |
A vector of length 3 including the simulated variances of the polygenic effect, permanent environmental effect and residuals, respectively. |
GRM |
An optional input where the Genetic Relationship Matrix can be given. Otherwise it is computed using the GenABEL package. |
sim.gamma |
A logical parameter specifying whether the residuals shuld be simulated from a gamma distribution or not. If specified as TRUE then residuals are drawn from a gamma distribution with variance equal to the residual variance specified in |
Returns a data frame including the simulated phenotypic values, cofactors and IDs.
Lars Ronnegard
#Simulate 4 observations per individual set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200) Phen.Data <- simulate_PhenData(y ~ 1, genabel.data=Gen.Data, n.obs=rep(4, nids(Gen.Data)), SNP.eff=2, SNP.nr=100, VC=c(1,1,1)) GWAS1 <- rGLS(y ~ 1, genabel.data = Gen.Data, phenotype.data = Phen.Data) plot(GWAS1, main="Simulated Data Results")#Simulate 4 observations per individual set.seed(1234) Gen.Data <- simulate_gendata(n=100, p=200) Phen.Data <- simulate_PhenData(y ~ 1, genabel.data=Gen.Data, n.obs=rep(4, nids(Gen.Data)), SNP.eff=2, SNP.nr=100, VC=c(1,1,1)) GWAS1 <- rGLS(y ~ 1, genabel.data = Gen.Data, phenotype.data = Phen.Data) plot(GWAS1, main="Simulated Data Results")
Imputes column means to missing genotypes.
SmoothSNPmatrix(SNP)SmoothSNPmatrix(SNP)
SNP |
A matrix including SNP coding. |
Lars Ronnegard
An S4 class to represent SNP data
nidsThe number of ids as numeric
idnamesThe idnames as character
nspsThe number of SNPs as numeric
snpnamesThe SNP names as character
mapThe order of the SNPS as numeric
chromosomeThe chromosome names for each SNP as numeric
gtpsThe matrix with SNP coding
Gets the SNP names.
snpnames(genabel.data)snpnames(genabel.data)
genabel.data |
A GenABEL-like data of class gwaa.data2. |
Lars Ronnegard
Creates a Manhattan plot using a slimmed version of the summary.scan.gwaa() function in the GenABEL package
## S3 method for class 'scan.gwaa2' summary(object, ...)## S3 method for class 'scan.gwaa2' summary(object, ...)
object |
A scan.gwaa2 object created by the rGLS function |
... |
Possible additional parameters (not used in the current version) |
Returns a data frame with estimated SNP effects, standard errors, test-statistic values, p-values, and corrected p-values.
Lars Ronnegard