gwas

package
v0.0.0-...-a7a5a58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPMatMult1Parallel

func CPMatMult1Parallel(cryptoParams *crypto.CryptoParams, A crypto.PlainMatrix, B crypto.CipherMatrix) crypto.CipherMatrix

func CPMatMult4V2CachedB

func CPMatMult4V2CachedB(cryptoParams *crypto.CryptoParams, A crypto.CipherMatrix, maxLevel int, CachedB PlainMatrixDiagCache) crypto.CipherMatrix

Generalized to levels >= 2

func CPMatMult5Parallel

func CPMatMult5Parallel(cryptoParams *crypto.CryptoParams, A crypto.PlainMatrix, B crypto.CipherMatrix) crypto.CipherMatrix

func CPMultAccWithoutMRedV1

func CPMultAccWithoutMRedV1(cryptoParams *crypto.CryptoParams, X crypto.CipherVector, Y crypto.PlainVector, Acc CipherVectorAccV1)

Multiply X and Y to add to Acc without modular reduction

func CPMultAccWithoutMRedV2

func CPMultAccWithoutMRedV2(X crypto.CipherVector, Y crypto.PlainVector, Acc CipherVectorAccV2)

func EncodeDiag

func EncodeDiag(cryptoParams *crypto.CryptoParams, X BlockVector, index int, nrot int, level int) (crypto.PlainVector, bool)

index specifies which diagonal to extract applies right-rotation by nrot positions before encoding

func EncodeDiagBool

func EncodeDiagBool(X BlockVector, index int, slots int) bool

Return if a diagonal vector exists without extracting/encoding the vectors

func EncodeDiagWithEncoder

func EncodeDiagWithEncoder(cryptoParams *crypto.CryptoParams, X BlockVector, index int, nrot int, level int, enc ckks.Encoder) (crypto.PlainVector, bool)

func GenerateFName

func GenerateFName(fname string, p, k, b int) string

func GetDiag

func GetDiag(dst []float64, X Block, dim int, index int) bool

index 0 is the main diagonal max size of Block is dim by dim and index ranges from 0 to dim-1 (mod dim) If given diagonal does not overlap with X (matrix might be smaller), returns false

func GetDiagBool

func GetDiagBool(X Block, dim int, index int) bool

Return if a diagonal vector exists without extracting elements

func LoadCacheFromFile

func LoadCacheFromFile(cps *crypto.CryptoParams, filename string) crypto.CipherMatrix

func LoadMatDenseCacheFromFile

func LoadMatDenseCacheFromFile(filename string) *mat.Dense

func LoadMatrixFromFile

func LoadMatrixFromFile(filename string, delim rune) *mat.Dense

func LoadSNPPositionFile

func LoadSNPPositionFile(filename string, delim rune) []uint64

func MForm

func MForm(a, q uint64, u []uint64) (r uint64)

func MFormLvl

func MFormLvl(r *ring.Ring, level int, p1, p2 *ring.Poly)

func MatMult4StreamNProc

func MatMult4StreamNProc(cryptoParams *crypto.CryptoParams, A crypto.CipherMatrix, gfs *GenoFileStream, maxLevel int, computeSquaredSum bool, nproc int) (crypto.CipherMatrix, []float64)

func MatSATASClear

func MatSATASClear(gfs *GenoFileStream, invStdDev []float64) *mat.Dense

func MatTClear

func MatTClear(gfs *GenoFileStream, B *mat.Dense) *mat.Dense

func MatTSClearSimple

func MatTSClearSimple(gfs *GenoFileStream, B *mat.Dense, invStdDev []float64) *mat.Dense

func Min

func Min(a int, b int) int

func Mod

func Mod(n int, modulus int) int

func ModularReduceV1

func ModularReduceV1(cryptoParams *crypto.CryptoParams, cva CipherVectorAccV1, outScale float64) crypto.CipherVector

func ModularReduceV2

func ModularReduceV2(cryptoParams *crypto.CryptoParams, cva CipherVectorAccV2, outScale float64) crypto.CipherVector

func MulCoeffsAndAdd128

func MulCoeffsAndAdd128(a, b []uint64, c []uint128)

func ReadGenoStatsFromFile

func ReadGenoStatsFromFile(filename string, m int) (ac, gc [][]uint32, miss []uint32)

Reads in a binary file containing 6 vectors of length m (# of SNPs): ref allele count (AC), alt AC, hom-ref genotype count (GC), het GC, hom-alt GC, missing sample count. Each value is encoded as uint32 in little endian format

func ReduceAndAddUint128

func ReduceAndAddUint128(in []uint128, out []uint64, qInv, q uint64)

func SaveFloatVectorToFile

func SaveFloatVectorToFile(filename string, x []float64)

func SaveMatDenseToFile

func SaveMatDenseToFile(mpcObj *mpc.MPC, sourcePid int, x *mat.Dense, filename string)

func SaveMatrixToFile

func SaveMatrixToFile(cps *crypto.CryptoParams, mpcObj *mpc.MPC, cm crypto.CipherMatrix, nElemCol int, sourcePid int, filename string)

func ToMontgomeryForm

func ToMontgomeryForm(cryptoParams *crypto.CryptoParams, pt crypto.PlainVector)

func TransposeMatrixFile

func TransposeMatrixFile(inputFile string, nrows, ncols int, outputFile string)

Types

type Block

type Block interface {
	At(int, int) float64
	Dims() (int, int)
}

type BlockF64

type BlockF64 mat.Dense

func (BlockF64) At

func (b BlockF64) At(i, j int) float64

type BlockI8

type BlockI8 struct {
	// contains filtered or unexported fields
}

func NewBlockI8

func NewBlockI8(r, c int) BlockI8

func (BlockI8) At

func (b BlockI8) At(i, j int) float64

func (BlockI8) Dims

func (b BlockI8) Dims() (int, int)

type BlockMatrix

type BlockMatrix []BlockVector

func ToBlockMatrix

func ToBlockMatrix(A *mat.Dense, d int) BlockMatrix

type BlockPlainF64

type BlockPlainF64 struct {
	// contains filtered or unexported fields
}

func NewBlockPlainF64

func NewBlockPlainF64(r, c int) BlockPlainF64

func (BlockPlainF64) At

func (b BlockPlainF64) At(i, j int) float64

func (BlockPlainF64) Dims

func (b BlockPlainF64) Dims() (int, int)

type BlockVector

type BlockVector []Block

type CipherAccV1

type CipherAccV1 struct {
	// contains filtered or unexported fields
}

type CipherAccV2

type CipherAccV2 struct {
	// contains filtered or unexported fields
}

type CipherVectorAccV1

type CipherVectorAccV1 []CipherAccV1

func NewCipherVectorAccV1

func NewCipherVectorAccV1(cryptoParams *crypto.CryptoParams, n int) CipherVectorAccV1

type CipherVectorAccV2

type CipherVectorAccV2 struct {
	// contains filtered or unexported fields
}

func NewCipherVectorAccV2

func NewCipherVectorAccV2(cryptoParams *crypto.CryptoParams, n int, level int) CipherVectorAccV2

func (*CipherVectorAccV2) InitCipherVectorAccV2

func (acc *CipherVectorAccV2) InitCipherVectorAccV2(cryptoParams *crypto.CryptoParams, n int, level int)

type Config

type Config struct {
	NumMainParties int `toml:"num_main_parties"`
	HubPartyId     int `toml:"hub_party_id"`

	CkksParams string `toml:"ckks_params"`

	NumInds []int `toml:"num_inds"`
	NumSnps int   `toml:"num_snps"`
	NumCovs int   `toml:"num_covs"`

	ItersPerEval  int `toml:"iter_per_eigenval"`
	NumPCs        int `toml:"num_pcs_to_remove"`
	NumOversample int `toml:"num_oversampling"`
	NumPowerIters int `toml:"num_power_iters"`

	SkipQC       bool `toml:"skip_qc"`
	SkipPCA      bool `toml:"skip_pca"`
	UseCachedQC  bool `toml:"use_cached_qc"`
	UseCachedPCA bool `toml:"use_cached_pca"`

	IndMissUB    float64 `toml:"imiss_ub"`
	HetLB        float64 `toml:"het_lb"`
	HetUB        float64 `toml:"het_ub"`
	SnpMissUB    float64 `toml:"gmiss"`
	MafLB        float64 `toml:"maf_lb"`
	HweUB        float64 `toml:"hwe_ub"`
	SnpDistThres int     `toml:"snp_dist_thres"`

	Servers map[string]mpc.Server

	GenoBinFilePrefix    string `toml:"geno_binary_file_prefix"`
	GenoNumFolds         int    `toml:"geno_num_folds"`
	GenoNumBlocks        int    `toml:"geno_num_blocks"`
	GenoFoldSizeFile     string `toml:"geno_fold_size_file"`
	GenoBlockSizeFile    string `toml:"geno_block_size_file"`
	GenoBlockToChromFile string `toml:"geno_block_to_chrom_file"`
	GenoCountFile        string `toml:"geno_count_file"`
	PhenoFile            string `toml:"pheno_file"`
	CovFile              string `toml:"covar_file"`
	SnpPosFile           string `toml:"snp_position_file"`

	Step2NumSnps       int `toml:"step_2_num_snps"`
	Step2GenoNumBlocks int `toml:"step_2_geno_num_blocks"`

	Step2GenoBinFilePrefix    string `toml:"step_2_geno_binary_file_prefix"`
	Step2GenoBlockSizeFile    string `toml:"step_2_geno_block_size_file"`
	Step2GenoBlockToChromFile string `toml:"step_2_geno_block_to_chrom_file"`
	Step2GenoCountFile        string `toml:"step_2_geno_count_file"`
	Step2SnpPosFile           string `toml:"step_2_snp_position_file"`

	OutDir   string `toml:"output_dir"`
	CacheDir string `toml:"cache_dir"`

	MpcFieldSize    int    `toml:"mpc_field_size"`
	MpcDataBits     int    `toml:"mpc_data_bits"`
	MpcFracBits     int    `toml:"mpc_frac_bits"`
	MpcNumThreads   int    `toml:"mpc_num_threads"`
	MpcObjsPerBlock int    `toml:"mpc_objs_per_block"`
	MpcMainThreads  int    `toml:"mpc_num_main_threads"`
	LocalNumThreads int    `toml:"local_num_threads"`
	CalcGCapacity   int    `toml:"calc_g_capacity"`
	MemoryLimit     uint64 `toml:"memory_limit"`

	Debug bool `toml:"debug"`
	// contains filtered or unexported fields
}

type FilterParams

type FilterParams struct {
	MafLowerBound float64
	HweUpperBound float64
	GenoMissBound float64
	IndMissBound  float64
	HetLowerBound float64
	HetUpperBound float64
}

type GWASParams

type GWASParams struct {
	// contains filtered or unexported fields
}

func InitGWASParams

func InitGWASParams(numInds []int, numSnps, numCovs, numPCs, minSnpDist int) *GWASParams

type GenoFileStream

type GenoFileStream struct {
	// contains filtered or unexported fields
}

func NewGenoFileStream

func NewGenoFileStream(filename string, numRow, numCol uint64, replaceMissing bool) *GenoFileStream

func (*GenoFileStream) CheckEOF

func (gfs *GenoFileStream) CheckEOF() bool

func (*GenoFileStream) ClearRowFilt

func (gfs *GenoFileStream) ClearRowFilt()

func (*GenoFileStream) ColFilt

func (gfs *GenoFileStream) ColFilt() []bool

func (*GenoFileStream) ColMissingReplace

func (gfs *GenoFileStream) ColMissingReplace() []float64

func (*GenoFileStream) LineCount

func (gfs *GenoFileStream) LineCount() uint64

func (*GenoFileStream) NextRow

func (gfs *GenoFileStream) NextRow() []float64

func (*GenoFileStream) NumCols

func (gfs *GenoFileStream) NumCols() uint64

func (*GenoFileStream) NumColsToKeep

func (gfs *GenoFileStream) NumColsToKeep() uint64

func (*GenoFileStream) NumRows

func (gfs *GenoFileStream) NumRows() uint64

func (*GenoFileStream) NumRowsToKeep

func (gfs *GenoFileStream) NumRowsToKeep() uint64

func (*GenoFileStream) Reset

func (gfs *GenoFileStream) Reset()

func (*GenoFileStream) RowFilt

func (gfs *GenoFileStream) RowFilt() []bool

func (*GenoFileStream) RowMissingReplace

func (gfs *GenoFileStream) RowMissingReplace() []float64

func (*GenoFileStream) SetColMissingReplace

func (gfs *GenoFileStream) SetColMissingReplace(a []float64)

func (*GenoFileStream) SetRowMissingReplace

func (gfs *GenoFileStream) SetRowMissingReplace(a []float64)

func (*GenoFileStream) ToMatDense

func (gfs *GenoFileStream) ToMatDense() *mat.Dense

func (*GenoFileStream) UpdateColFilt

func (gfs *GenoFileStream) UpdateColFilt(a []bool) int

func (*GenoFileStream) UpdateRowFilt

func (gfs *GenoFileStream) UpdateRowFilt(a []bool) int

type PlainMatrixDiagCache

type PlainMatrixDiagCache [][]crypto.PlainVector

Cache structure for MatMult4 First index corresponds to row index of blocks of size slots-by-slots Second index of indexMap corresponds to index of diagonals (0..slots-1), The table maps a diag index to the encoded PlainVector If a given index has empty data, stored element is nil

func MatMult4TransformB

func MatMult4TransformB(cryptoParams *crypto.CryptoParams, B *mat.Dense) PlainMatrixDiagCache

type ProtocolInfoLMM

type ProtocolInfoLMM struct {
	// contains filtered or unexported fields
}

func InitializeLMMProtocol

func InitializeLMMProtocol(config *Config, pid int) (lmmProt *ProtocolInfoLMM)

func (*ProtocolInfoLMM) CacheExists

func (g *ProtocolInfoLMM) CacheExists(filename string) bool

func (*ProtocolInfoLMM) CacheFile

func (g *ProtocolInfoLMM) CacheFile(filename string) string

func (*ProtocolInfoLMM) Exists

func (g *ProtocolInfoLMM) Exists(filename string) bool

func (*ProtocolInfoLMM) FileExistsForAll

func (g *ProtocolInfoLMM) FileExistsForAll(mpcObj *mpc.MPC, filename string) bool

func (*ProtocolInfoLMM) GetCPS

func (g *ProtocolInfoLMM) GetCPS() *crypto.CryptoParams

func (*ProtocolInfoLMM) GetCalcGCapacity

func (g *ProtocolInfoLMM) GetCalcGCapacity() int

func (*ProtocolInfoLMM) GetConfig

func (g *ProtocolInfoLMM) GetConfig() *Config

func (*ProtocolInfoLMM) GetCov

func (g *ProtocolInfoLMM) GetCov() *mat.Dense

func (*ProtocolInfoLMM) GetGWASParams

func (g *ProtocolInfoLMM) GetGWASParams() *GWASParams

func (*ProtocolInfoLMM) GetGeno

func (g *ProtocolInfoLMM) GetGeno() [][]*GenoFileStream

func (*ProtocolInfoLMM) GetGenoBlockSizes

func (g *ProtocolInfoLMM) GetGenoBlockSizes() []int

func (*ProtocolInfoLMM) GetGenoBlockToChr

func (g *ProtocolInfoLMM) GetGenoBlockToChr() []int

func (*ProtocolInfoLMM) GetGenoFoldSizes

func (g *ProtocolInfoLMM) GetGenoFoldSizes() []int

func (*ProtocolInfoLMM) GetGenoT

func (g *ProtocolInfoLMM) GetGenoT() [][]*GenoFileStream

func (*ProtocolInfoLMM) GetLocalThreads

func (g *ProtocolInfoLMM) GetLocalThreads() int

func (*ProtocolInfoLMM) GetMPC

func (g *ProtocolInfoLMM) GetMPC() *mpc.MPC

func (*ProtocolInfoLMM) GetMpcAllThreads

func (g *ProtocolInfoLMM) GetMpcAllThreads() int

func (*ProtocolInfoLMM) GetMpcMainThreads

func (g *ProtocolInfoLMM) GetMpcMainThreads() int

func (*ProtocolInfoLMM) GetMpcPerBlock

func (g *ProtocolInfoLMM) GetMpcPerBlock() int

func (*ProtocolInfoLMM) GetNetwork

func (g *ProtocolInfoLMM) GetNetwork() *mpc.Network

func (*ProtocolInfoLMM) GetNumChrs

func (g *ProtocolInfoLMM) GetNumChrs() int

func (*ProtocolInfoLMM) GetParallelMPC

func (g *ProtocolInfoLMM) GetParallelMPC() mpc.ParallelMPC

func (*ProtocolInfoLMM) GetParallelNetwork

func (g *ProtocolInfoLMM) GetParallelNetwork() mpc.ParallelNetworks

func (*ProtocolInfoLMM) GetPheno

func (g *ProtocolInfoLMM) GetPheno() *mat.Dense

func (*ProtocolInfoLMM) GetPos

func (g *ProtocolInfoLMM) GetPos() []uint64

func (*ProtocolInfoLMM) OutExists

func (g *ProtocolInfoLMM) OutExists(filename string) bool

func (*ProtocolInfoLMM) OutFile

func (g *ProtocolInfoLMM) OutFile(filename string) string

func (*ProtocolInfoLMM) SetGWASParams

func (g *ProtocolInfoLMM) SetGWASParams(x *GWASParams)

func (*ProtocolInfoLMM) SetGenoBlockSizes

func (g *ProtocolInfoLMM) SetGenoBlockSizes(x []int)

func (*ProtocolInfoLMM) SetGenoBlockToChr

func (g *ProtocolInfoLMM) SetGenoBlockToChr(x []int)

func (*ProtocolInfoLMM) SetGenoBlocks

func (g *ProtocolInfoLMM) SetGenoBlocks(geno [][]*GenoFileStream)

func (*ProtocolInfoLMM) SetGenoFoldSizes

func (g *ProtocolInfoLMM) SetGenoFoldSizes(x []int)

func (*ProtocolInfoLMM) SetGenoTBlocks

func (g *ProtocolInfoLMM) SetGenoTBlocks(genoT [][]*GenoFileStream)

func (*ProtocolInfoLMM) SetNumChrs

func (g *ProtocolInfoLMM) SetNumChrs(x int)

func (*ProtocolInfoLMM) SetPos

func (g *ProtocolInfoLMM) SetPos(x []uint64)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL