Under construction
- About
- Genetic relationship matrices
- Command line interface
- Installation and requirements
.grmfile format- Contributing
- A.I. Acknowledgement
- References
The genetic relationship matrix (GRM) describes the genetic relationship
between pairs of samples. Its computation is dependent on the random effects
defined by the linear mixed model mapping genetic features to phenotype. For
example, suppose that we are interested in accounting for polygenic SNP effects
using measured genotypes. Let the number of samples be
with the fixed effect at locus
with
Under this model the sample phenotype covariance matrix decomposes into genetic and environmental terms
where the genetic component of the phenotype covariance tells us how
to compute the GRM, i.e.
The alt allele count polygenic random effects are one example of genetic effects. We do not need to limit ourselves to this model, and instead account for any measurable genetic signals. This program uses several signals to compute a GRM:
- genotypes i.e. the alternative allele count,
- the expected alt allele count under a probabilistic model, useful for imputed genetic signals,
- ancestral haplotypes, i.e. a K dimensional vector of expected haplotype counts,
- or some combination of the aforementioned signals.
This program provides an means to compute the GRM of genetic signals in general.
The genetic relationship matrices that this program computes are as follows: imputed SNP genotypes considered above, the expected alternative allele counts under a probabilistic model, the expected ancestral haplotype counts, and the combined expected alternative allele and expected haplotype counts. The subsections the follow define the model and the calculation for the aforementioned GRMs.
The SNP GRM is presented in the about section. Let
with
In many cases, as is the case in the Palmer Lab, SNPs are imputed. If the imputation method estimates the genotype probabilities at each locus of each sample, as does our method of choice STITCH [2], then it may be more appropriate consider the expected alternative allele counts (EAC) under the imputation model rather than the imputed genotype calls.
Let
The expected haplotype count GRM
An important question when working under the haplotype model is what
type of random genetic effects do we want to account for. If we
only care about the polygenic SNP effects, then we should make use of
GRMs
Here, the difference between the polygenic SNP and haplotype effects
are explicit. Instead of a single design matrix
the sum of the similarity matrices of each haplotype.
In a genome wide association study (GWAS) polygenic effects are often accounted for from all loci except those of the chromosome that fixed effect sizes are being estimated. This approach is referred to as "leave-one-chromosome-out", or loco for short, for which we will refer the resulting GRM as the loco GRM. This matrix can be computed easily from the set of all chromosome GRMs.
Let
The grm program consists of two subprograms:
grm contig: the computation of the GRM of a named contiggrm loco: the aggregation of contig GRMs into a "leave-one-chromosome-out" matrix (denoted the "loco" matrix).
to read documentation on the respective subprogram simply
grm [contig | loco] --help
The GRM calculation requires tha the genetic information is in the
the bcf family of file formats, i.e. vcf, vcf.gz, or bcf. While
the loco subprogram requires all chromosome matrices to be in the
.grm binary file format defined below.
By default, the GRM is computed using the expected haplotype counts with FORMAT ID = "HD".
grm chrm <chrm_id> <path/to/my/snps.bcf>
will produce a binary .mat file that stores the GRM and relavent meta data.
Other options include
The program is only available as source from this repository and requires
GNU makehtslibhttps://github.com/samtools/htslibargparsehttps://github.com/robert-vogel/argparseclangorgccC++17 compiler
The .grm file format is a binary data format consisting of meta data
and a payload.
Assume 64-bit machine, little-endian, e.g. ARM and x86-64.
| offset | type | size | description |
| (bytes) | (bytes) | ||
|---|---|---|---|
| 0 | uint32_t | 4 | File signature (0x47524D00 = "GRM\0") |
| 4 | uint32_t | 4 | File version, utils::Version |
| 8 | uint32_t | 4 | Program version, utils::Version |
| 12 | varies | Genomic coordinates, grm::Coordinates | |
|
|
varies | Sample names, grm::Samples | |
| Total |
Genomic coordinates
| offset | type | size | description |
| (bytes) | (bytes) | ||
|---|---|---|---|
| 0 | uint32_t | 4 |
|
| 4 | char[] | Contig name chars, sizeof(char) = 1 byte | |
| uint32_t | 4 | Number of positions ( |
|
| uint32_t | loci positions on contig | ||
| Total |
Sample names
| offset | type | size | description |
| (bytes) | (bytes) |
|---|
Given float32 an
acceptable choice for all GRM types.
I am using GoogleTest framework
for organizing tests. If you contribute, please make tests for your
contributions. To run tests, build directory and build the project
make check
The problem statement and overall design of the code base was by Robert Vogel. He has made use of Claude for review and Claude Code, the AI assistant by Anthropic, to implement sum features.
[1] Yang et al. Nature Genetics 42, 565-569 (2010) [2] Davies et al. Nature Genetics 48, 965-969 (2016)