snipar.pgs module
- snipar.pgs.compute(pgs, bedfile=None, bgenfile=None, par_gts_f=None, ped=None, sib=False, compute_controls=False, verbose=True)[source]
Compute a polygenic score (PGS) for the individuals with observed genotypes and observed/imputed parental genotypes.
- Args:
- par_gts_f
str path to HDF5 file with imputed parental genotypes
- gts_f
str path to bed file with observed genotypes
- pgs
snipar.pgs the PGS, defined by the weights for a set of SNPs and the alleles of those SNPs
- sib
bool Compute the PGS for genotyped individuals with at least one genotyped sibling and observed/imputed parental genotypes. Default False.
- compute_controls
bool Compute polygenic scores for control families (families with observed parental genotypes set to missing). Default False.
- par_gts_f
- Returns:
- pg
snipar.gtarray Return the polygenic score as a genotype array with columns: individual’s PGS, mean of their siblings’ PGS, observed/imputed paternal PGS, observed/imputed maternal PGS
- pg
- class snipar.pgs.pgs(snp_ids, weights, alleles)[source]
Bases:
objectDefine a polygenic score based on a set of SNPs with weights and ref/alt allele pairs.
- Args:
- snp_ids
array [L] vector of SNP ids
- weights
array [L] vector of weights of equal length to snp_ids
- alleles
array [L x 2] matrix of ref and alt alleles for the SNPs. L must match size of snp_ids
- snp_ids
- Returns:
pgs :
snipar.pgs
- compute(garray, cols=None)[source]
Compute polygenic score values from a given genotype array. Finds the SNPs in the genotype array that have weights in the pgs and matching alleles, and computes the PGS based on these SNPs and the weights after allele-matching.
- Args:
- garray
sbreg.gtarray genotype array to compute PGS values for
- cols
numpy:numpy.array names to give the columns in the output gtarray
- garray
- Returns:
- pg
snipar.gtarray 2d gtarray with PGS values. If a 3d gtarray is input, then each column corresponds to the second dimension on the input gtarray (for example, individual, paternal, maternal PGS). If a 2d gtarray is input, then there will be only one column in the output gtarray. The names given in ‘cols’ are stored in ‘sid’ attribute of the output.
- pg