Package 'vGWAS'

Title: Variance Heterogeneity Genome-wide Association Study - Reimplementation
Description: The package reimplementation provides models and tests for variance heterogeneity genome-wide association study (vGWAS).
Authors: Xia Shen
Maintainer: Kristian Ullrich <[email protected]>
License: GPL
Version: 2025.05.18
Built: 2026-05-13 06:41:11 UTC
Source: https://github.com/kullrich/vgwas

Help Index


Brown-Forsythe's Test of Equality of Variances

Description

The function performs the robust Brown-Forsythe test using the group medians.

Usage

bfmedian.test(formula, data, alpha = 0.05, na.rm = TRUE,
verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds. Default us set to TRUE.

verbose

a logical for printing output to R console.

Details

Levene (1960) proposed a test for homogeneity of variances in k groups which is based on the ANOVA statistic applied to absolute deviations of observations from the corresponding group mean. The robust Brown-Forsythe version of the Levene-type test substitutes the group mean by the group median in the classical Levene statistic.

Value

A list with class "owt" containing the following components:

statistic

the Brown-Forsythe test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Brown-Forsythe-Median Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Note

Modified from the onewaytests package and vGWAS.

Author(s)

Kristian Ullrich

References

Brown, M. B. and Forsythe, A.B. (1974). Robust tests for equality of variances. Journal of the American Statistical Association, 69, 364-367.

Levene, H. (1960). Robust Tests for Equality of Variances, in Contributions to Probability and Statistics, ed. I. Olkin, Palo Alto, CA: Stanford Univ. Press.

Examples

data(pheno)
data(geno)
df <- data.frame(phenotype = pheno, genotype = as.factor(geno[, 911]))
bfmedian.test(phenotype ~ genotype, data = df)

Brown-Forsythe's Test of Equality of Variances

Description

The function performs the robust Brown-Forsythe test using the group medians. Instead of the ANOVA statistic, the Kruskal-Wallis ANOVA may also be applied using this function.

Usage

brown.forsythe.test(y, group, kruskal.test=FALSE)

Arguments

y

a numeric vector of data values.

group

factor of the data.

kruskal.test

a logical value specifying whether to use Kruskal-Wallis statistic. The default option is FALSE, i.e., the usual ANOVA statistic is used in place of Kruskal-Wallis statistic.

Details

Levene (1960) proposed a test for homogeneity of variances in k groups which is based on the ANOVA statistic applied to absolute deviations of observations from the corresponding group mean. The robust Brown-Forsythe version of the Levene-type test substites the group mean by the group median in the classical Levene statistic.

Value

A list with the following numeric components.

statistic

the value of the test statistic.

p.value

the p-value of the test.

method

type of test performed.

data.name

a character string giving the name of the data.

Note

Modified from the lawstat package.

Author(s)

Xia Shen

References

Brown, M. B. and Forsythe, A.B. (1974). Robust tests for equality of variances. Journal of the American Statistical Association, 69, 364-367.

Levene, H. (1960). Robust Tests for Equality of Variances, in Contributions to Probability and Statistics, ed. I. Olkin, Palo Alto, CA: Stanford Univ. Press.

Examples

data(pheno)
data(geno)
brown.forsythe.test(pheno, geno[,911])

Chromosome Indices for The Markers of The Simulated Data

Description

Chromosome indices for the markers of the simulated data

Usage

data(chr)

Format

A numeric vector of chromosome indices for the 20K simulated markers.

Examples

data("chr", package="vGWAS")
table(chr)

The Marker Genotypes of The Simulated Data

Description

The marker genotypes of the simulated data

Usage

data(geno)

Format

A character matrix of size (number of individuals) times (number of markers in the genome).

Details

Note that there is only one column for each marker.

Examples

data("geno", package="vGWAS")

The Marker Genotypes of The Simulated Data (as data.frame)

Description

The marker genotypes of the simulated data

Usage

data(geno.df)

Format

A data.frame of size (number of markers in the genome) times (number of individuals).

Details

Note that there is only one column for each marker.

Examples

data("geno.df", package="vGWAS")

The Marker Genotypes of The Simulated Data (as matrix)

Description

The marker genotypes of the simulated data

Usage

data(geno.num)

Format

A matrix of size (number of individuals) times (number of markers in the genome).

Details

Note that there is only one column for each marker.

Examples

data("geno.num", package="vGWAS")

The Marker Genotypes of The Simulated Data (as sparse matrix)

Description

The marker genotypes of the simulated data

Usage

data(geno.sparse)

Format

A sparse matrix of size (number of markers in the genome) times (number of individuals).

Details

Note that there is only one column for each marker.

Examples

data("geno.sparse", package="vGWAS")

Get minor-allele-frequency

Description

Calculates minor-allele-frequency (MAF)

Usage

getMAF(geno.matrix, geno.snp = "row", include.het = FALSE)

Arguments

geno.matrix

a matrix or data.frame or sparseMatrix with individuals as columns and markers as rows (geno.snp = "row") or individuals as rows and markers as columns (geno.snp = "col").

geno.snp

if individuals at columns and markers at rows use "row" else if individuals at rows and markers at columns use "col"

include.het

specify if heterozygous calls should be split and added equally to homozygous ref and alt counts (default = FALSE)

Value

a vector containing minor-allele-frequency values

Author(s)

Kristian Ullrich

Examples

data(geno)
maf <- getMAF(geno.matrix = geno, geno.snp = "col")
data(geno.num)
maf.num <- getMAF(geno.matrix = geno.num, geno.snp = "col")
data(geno.df)
maf.df <- getMAF(geno.matrix = geno.df, geno.snp = "row")
data(geno.sparse)
maf.sparse <- getMAF(geno.matrix = geno.sparse, geno.snp = "row")

Map Positions for The Markers of The Simulated Data

Description

Map positions for the markers of the simulated data

Usage

data(map)

Format

A numeric vector of chromosomal map positions of the 20K simulated markers.

Examples

data("map", package="vGWAS")

Variance Heterogeneity Genome-wide Association Study

Description

The package provides models and tests for variance heterogeneity genome-wide association study (vGWAS). "_PACKAGE"

Author(s)

Xia Shen

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

Ronnegard, L., Shen, X. and Alam, M. (2011): hglm: A Package for Fitting Hierarchical Generalized Linear Models. The R Journal, 2(2), 20-28.

Brown, M. B. and Forsythe, A.B. (1974). Robust tests for equality of variances. Journal of the American Statistical Association, 69, 364-367.

Levene, H. (1960). Robust Tests for Equality of Variances, in Contributions to Probability and Statistics, ed. I. Olkin, Palo Alto, CA: Stanford Univ. Press.

See Also

R package lawstat for other types of nonparametric variance tests and onewaystats.


Phenotypic Values for The Markers of The Simulated Data

Description

Phenotypic values for the markers of the simulated data

Usage

data(pheno)

Format

A numeric vector of the phenotypic values of 93 simulated individuals.

Details

Note that there is only one column for each marker.

Examples

data("pheno", package="vGWAS")
hist(pheno, breaks = 30)

Variance GWA Manhattan Plot

Description

The function plots the variance GWA result for the given scan object.

Usage

## S3 method for class 'vGWAS'
plot(x, sig.threshold = NULL, low.log.p = 0,
pch = 16, cex = 0.6, col.manhattan = c("slateblue4", "olivedrab"),
col.sig.threshold = "darkgoldenrod", ...)

Arguments

x

a result object from vGWAS scan. It can be any list or data.frame that contains chromosome, marker.map, and p.value, with class = 'vGWAS'. See vGWAS.

sig.threshold

a numeric value giving the significance threshold for -log(pvalues, 10). If NULL, Bonferroni correction will be used.

low.log.p

a numeric value giving the lower limit of the -log(pvalues, 10) to plot.

pch

point character. See par.

cex

size of points. See par.

col.manhattan

two colors as a vector for the Manhattan plot.

col.sig.threshold

one color for the significance threshold

...

not in use

Value

a plot for viewing vGWAS result.

Author(s)

Xia Shen

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

See Also

package-vGWAS, vGWAS

Examples

# ----- load data ----- #
data(pheno)
data(geno)
data(chr)
data(map)
# ----- variance GWA scan ----- #
vgwa <- vGWAS(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr, pB = FALSE)
# ----- visualize the scan ----- #
plot(vgwa)
summary(vgwa)
# ----- calculate the variance explained by the strongest marker ----- #
vGWAS.variance(phenotype = pheno,
marker.genotype = geno[, vgwa[["p.value"]] == min(vgwa[["p.value"]])])
# ----- genomic control ----- #
vgwa2 <- vGWAS.gc(vgwa)
plot(vgwa2)
summary(vgwa2)

Variance GWA Summary

Description

The function summarized the variance GWA result for the given scan object.

Usage

## S3 method for class 'vGWAS'
summary(object, nrMarkers = 10, ...)

Arguments

object

a result object from vGWAS scan. It can be any list or data.frame that contains chromosome, marker.map, and p.value, with class = 'vGWAS'. See vGWAS.

nrMarkers

a numeric value giving the number of top markers to be summarized.

...

not in use

Value

a summary for viewing vGWAS result.

Author(s)

Xia Shen

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

Ronnegard, L., Shen, X. and Alam, M. (2010): hglm: A Package for Fitting Hierarchical Generalized Linear Models. The R Journal, 2(2), 20-28.

See Also

package-vGWAS, vGWAS

Examples

# ----- load data ----- #
data(pheno)
data(geno)
data(chr)
data(map)
# ----- variance GWA scan ----- #
vgwa <- vGWAS(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr, pB = FALSE)
# ----- visualize the scan ----- #
plot(vgwa)
summary(vgwa)
# ----- calculate the variance explained by the strongest marker ----- #
vGWAS.variance(phenotype = pheno,
marker.genotype = geno[, vgwa[["p.value"]] == min(vgwa[["p.value"]])])
# ----- genomic control ----- #
vgwa2 <- vGWAS.gc(vgwa)
plot(vgwa2)
summary(vgwa2)

Variance Genome-wide Association

Description

Variance Genome-wide association for using nonparametric variance test

Usage

vGWAS(phenotype, geno.matrix, kruskal.test = FALSE,
marker.map = NULL, chr.index = NULL, pB = TRUE)

Arguments

phenotype

a numeric or logical vector of the phenotyic values. See Examples.

geno.matrix

a matrix or data.frame with individuals as rows and markers as columns. The marker genotypes for each marker are coded as one column. See Examples.

kruskal.test

a logical value specifying whether to use Kruskal-Wallis statistic. The default option is FALSE, i.e., the usual ANOVA statistic is used in place of Kruskal-Wallis statistic.

marker.map

a numeric vector giving the marker map positions for each chromosome. See Examples.

chr.index

a numeric vector giving the chromosome index for each marker. See Examples.

pB

show progress bar

Value

a data.frame containing columns of marker names, chromosome indices, marker.map positions, test statistic values, and p.value for each position.

Author(s)

Xia Shen

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

Ronnegard, L., Shen, X. and Alam, M. (2010): hglm: A Package for Fitting Hierarchical Generalized Linear Models. The R Journal, 2(2), 20-28.

See Also

package-vGWAS

Examples

# ----- load data ----- #
data(pheno)
data(geno)
data(chr)
data(map)
# ----- variance GWA scan ----- #
vgwa <- vGWAS(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr, pB = FALSE)
# ----- visualize the scan ----- #
plot(vgwa)
summary(vgwa)
# ----- calculate the variance explained by the strongest marker ----- #
vGWAS.variance(phenotype = pheno,
marker.genotype = geno[, vgwa[["p.value"]] == min(vgwa[["p.value"]])])
# ----- genomic control ----- #
vgwa2 <- vGWAS.gc(vgwa)
plot(vgwa2)
summary(vgwa2)

Genomic Control for vGWAS

Description

The function does genomic control for the variance GWA result object.

Usage

vGWAS.gc(object, plot = TRUE, proportion = 1, ...)

Arguments

object

a result object from vGWAS scan. It can be any list or data.frame that contains chromosome, marker.map, and p.value, with class = 'vGWAS'. See vGWAS.

plot

a logical value turning on/off the QQ plot for genomic control.

proportion

a numeric value between 0 and 1 giving the proportion of obtained p-values to be used for genomic control.

...

not in use

Value

lambda

estimated inflation ratio.

lambda.se

standard error of the estimated inflation ratio.

gc.p.value

p-values after genomic control.

Author(s)

Xia Shen

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

See Also

package-vGWAS, vGWAS

Examples

# ----- load data ----- #
data(pheno)
data(geno)
data(chr)
data(map)
# ----- variance GWA scan ----- #
vgwa <- vGWAS(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr, pB = FALSE)
# ----- visualize the scan ----- #
plot(vgwa)
summary(vgwa)
# ----- calculate the variance explained by the strongest marker ----- #
vGWAS.variance(phenotype = pheno,
marker.genotype = geno[, vgwa[["p.value"]] == min(vgwa[["p.value"]])])
# ----- genomic control ----- #
vgwa2 <- vGWAS.gc(vgwa)
plot(vgwa2)
summary(vgwa2)

Calculating Variance Explained by A Single Marker

Description

The function calculates and reports the variance explained for a single marker by fitting a double generalized linear model. It gives both the variance explained by the mean and variance parts of model.

Usage

vGWAS.variance(phenotype, marker.genotype, print = TRUE)

Arguments

phenotype

a numeric vector of the phenotyic values. See Examples.

marker.genotype

a numeric or character or factor vector of the genotypes of a single marker. See Examples.

print

a logical value. If FALSE, the heritability values will be returned for storage.

Details

The Value will only be available if only.print = FALSE.

Value

variance.mean

the variance explained by the mean part of model.

variance.disp

the variance explained by the variance part of model.

Author(s)

Xia Shen

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

See Also

package-vGWAS, vGWAS, plot.vGWAS

Examples

# ----- load data ----- #
data(pheno)
data(geno)
data(chr)
data(map)
# ----- variance GWA scan ----- #
vgwa <- vGWAS(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr, pB = FALSE)
# ----- visualize the scan ----- #
plot(vgwa)
summary(vgwa)
# ----- calculate the variance explained by the strongest marker ----- #
vGWAS.variance(phenotype = pheno,
marker.genotype = geno[, vgwa[["p.value"]] == min(vgwa[["p.value"]])])

Variance Genome-wide Association (parallel)

Description

Variance Genome-wide association for using nonparametric variance test and other

Usage

vGWASparallel(phenotype, geno.matrix, marker.map = NULL,
chr.index = NULL, geno.snp = "row", method = "bfmedian", test.alpha = 0.05,
test.na.rm = TRUE, p.adjust.method = "none", include.het = FALSE, pB = TRUE,
ncores = 1)

Arguments

phenotype

a numeric or logical vector of the phenotyic values.

geno.matrix

a matrix or data.frame or sparseMatrix with individuals as columns and markers as rows (geno.snp = "row") or individuals as rows and markers as columns (geno.snp = "col").

marker.map

a numeric vector giving the marker map positions for each chromosome.

chr.index

a numeric vector giving the chromosome index for each marker.

geno.snp

if individuals at columns and markers at rows use "row" else if individuals at rows and markers at columns use "col"

method

the test method to use (default = bfmedian). Default is set to the Brown-Forsythe's Test of Equality of Variances using group medians. There are 31 other tests available via the onewaytests package: Alvandi's F test ("af"), Alexander-Govern test ("ag"), Alvandi's generalized p-value ("agp"), One-way analysis of variance ("aov"), Approximate F test ("ap"), Adjusted Welch's heteroscedastic F test ("aw"), B square test ("b2"), Brown-Forsythe test ("bf"), Box F test ("box"), Cochran test ("cochran"), Generalized tests equivalent to Parametric Bootstrap ("gtb"), Generalized tests equivalent to Fiducial tests ("gtf"), Variance homogeneity tests ("homog"), James second order test ("james"), Johansen F test ("johansen"), Kruskal-Wallis test ("kw"), Modified Brown-Forsythe test ("mbf"), Mann-Whitney U test ("mw"), Anderson-Darling normility test ("nor_ad"), Cramer-vin Mises normility test ("nor_cvm"), Kolmogorov-Smirnov normility test ("nor_ks"), Pearson Chi-square normility test ("nor_pct"), Shapiro-Wilk normility test ("nor_sw"), Shapiro-Francia normility test ("nor_sf"), Permutation F test ("pf"), Scott-Smith test ("ss"), Student's t-test ("st"), Welch-Aspin test ("wa"), Welch's heteroscedastic F test with trimmed means and Winsorized variances ("welch"), Weerahandi's generalized F test ("wgf"), Welch's t-test ("wt").

test.alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

test.na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds. Default us set to TRUE.

p.adjust.method

correction method (default = "none"). There are 8 p-value correction methods available via the p.adjust function: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"

include.het

specify if heterozygous calls should be split and added equally to homozygous ref and alt counts (default = FALSE)

pB

show progress bar

ncores

number of cores to parallelize (default = 1)

Value

a data.frame containing columns of marker names, chromosome indices, marker.map positions, test statistic values, and p.value for each position.

Author(s)

Xia Shen

Kristian Ullrich

References

Shen, X., Pettersson, M., Ronnegard, L. and Carlborg, O. (2011): Inheritance beyond plain heritability: variance-controlling genes in Arabidopsis thaliana. PLoS Genetics, 8, e1002839.

Ronnegard, L., Shen, X. and Alam, M. (2010): hglm: A Package for Fitting Hierarchical Generalized Linear Models. The R Journal, 2(2), 20-28.

See Also

package-vGWAS onewaytests

Examples

# ----- load data ----- #
data(pheno)
data(geno)
data(chr)
data(map)
# ----- variance GWA scan ----- #
vgwa <- vGWASparallel(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr,
geno.snp = "col", pB = FALSE)
# ----- other test GWA scan ----- #
vgwa.mw <- vGWASparallel(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr,
geno.snp = "col", method = "mw", pB = FALSE)
# ----- multiple cores ----- #
vgwa.st <- vGWASparallel(phenotype = pheno, geno.matrix = geno,
marker.map = map, chr.index = chr,
geno.snp = "col", method = "st", ncores = 2, pB = FALSE)