efficient functions for variant analyses over TINYINT[] genotype representations
This is a work-in-progress to develop functions for efficiently computing summary variant information over an array of genotypes stored in TINYINT[]
. At the moment, it is little more than a collection of a couple of functions that I have used for this purpose and not the development of a function library per se.
Currently included are:
alternate_allele_frequency( TINYINT[], INTEGER[] )
- a function over an array of genotypes and a corresponding array of indices into that array we should usesummarize_variant( TINYINT[], INTEGER[], INTEGER[] )
a function over an array of genotypes and two corresponding array of indices into that array we should use, both of which can be null
The output format for summarize_variant is as a variant_summary
user-defined type, which has fields:
- whole genotype array call rate
- whole genotype array minor allele frequency
- first subset call rate if first subset index array is not
NULL
, otherwiseNULL
- first subset minor allele frequency if first subset index array is not
NULL
, otherwiseNULL
- second sbuset call rate if second subset index array is not
NULL
, otherwiseNULL
- second subset minor allele frequency if second subset index array is not
NULL
, otherwiseNULL
The interfaces beg for improvement with these functions. The summarize_variant function should be variadic on the number of subsets to accept. This I will perhaps do if there is not a large penalty to variadic argument construction with large arrays. It would be ideal for both functions to operate modularly with array_multi_index, but this requires additional scans of potentially very large arrays and sacrifices too much computational effort. Finally, returning an array would be more flexible than returning a tuple as a custom data type, which is particularly necessary if I develop a variadic function.
curl -s -S -L https://github.com/rlichtenwalter/pg_variant_functions/archive/master.zip > pg_variant_functions.zip unzip pg_variant_functions.zip (cd pg_variant_functions-master && make PG_CONFIG=<optional custom pg_config path>) (cd pg_variant_functions-master && make PG_CONFIG=<optional custom pg_config path> install) (cd ~postgres && sudo -u postgres psql -c 'CREATE EXTENSION pg_variant_functions;')