Module: fio

Methods for loading score statistics and covariance matrices from local files. This is primarily used by the CLI.

License:
  • MIT
Source:

Classes

GenotypeCovarianceMatrix
ScoreStatTable
VariantMask

Members

(inner, constant) STATS_FORMAT :Object

An enum denoting score/covariance statistics file format.

Type:
  • Object
Source:

Methods

(inner) detectFormat(fpath) → {number}

Determine whether the file is in rvtest or raremetal format.

Parameters:
Name Type Description
fpath string

Path to file (can be covariance or score stats).

Source:
Returns:

STATS_FORMAT.RAREMETAL or STATS_FORMAT.RVTEST.

Type
number

(async, inner) extractCovariance(fpath, region, variants, scoreStats) → {Promise.<GenotypeCovarianceMatrix>}

Extract covariance matrix from a file. If variants are provided, only extract a matrix for the given variants. This only requires a single pass of the file. If no variants are provided, a double pass is done - one to figure out the size of the matrix, the next to read it.

This function assumes you have tabix installed, and it exists on your PATH. You can download tabix by visiting htslib.org.

We assume that the file being loaded is a covariance matrix file produced by either RAREMETAL or rvtests. We specifically assume that, per these file formats, scores and covariances are oriented towards the alternate allele when reading. However, when storing, covariances are stored flipped towards the minor allele, as this is typically the convention used in aggregation tests. The covariance matrix is also multiplied by the sample size, since per convention, RAREMETAL and rvtests both divide each element by the sample size before writing out.

Parameters:
Name Type Description
fpath string

Path to covariance matrix file.

region string

Region string, e.g. 1:1-40000.

variants Array.<string>

Array of variants to extract in this order. Variants should be EPACTS format, e.g. 1:4_A/G.

scoreStats ScoreStatTable

Object containing score statistics and other required information. This is needed because rvtest and raremetalworker both normalize the covariance matrix by the sample size.

Source:
Returns:

A genotype covariance matrix.

Type
Promise.<GenotypeCovarianceMatrix>

(async, inner) extractScoreStats(fpath, region, variants) → {module:stats~ScoreStatTable}

Extract score statistics from a file (either rvtest or raremetal format).

Parameters:
Name Type Description
fpath string

The path to the bgzipped score statistics file (one variant per line).

region string

Region containing the variants. Should be formatted in the typical "1:1-4000".

variants Array.<string>

A list of variants to specifically extract, in this order. If a list of variants is not provided, all variants will be extracted in the region.

Source:
Returns:

An object containing statistics per variant, including:

  • Chromosome and position
  • Score statistic
  • Variance of the score statistic
  • Reference allele
  • Alternate allele and frequency
  • Effect allele and frequency
  • Number of genotyped samples present in the analysis when the score statistics were calculated
Type
module:stats~ScoreStatTable

(inner) getNumberOfVariantsFromCovarianceFile(covarFile, region) → {number}

Find the number of variants in a region of a covariance matrix file.

Parameters:
Name Type Description
covarFile string

Path to covariance matrix file

region string

Region string, e.g. 1:1-4000

Source:
Returns:

Number of variants in the region

Type
number

(inner) readMaskFileSync(fpath) → {VariantMask}

Read groups from a mask file.

Parameters:
Name Type Description
fpath string

Path to mask file.

Source:
Returns:

A VariantMask object that stores a mapping of groups to lists of variants.

Type
VariantMask