snipar.gtarray module
- class snipar.gtarray.gtarray(garray, ids, sid=None, alleles=None, pos=None, chrom=None, map=None, error_probs=None, fams=None, par_status=None, num_obs_par_al=None, ped=None, standard_f=None)[source]
Bases:
objectDefine a genotype or PGS array that stores individual IDs, family IDs, and SNP information.
- Args:
- garray
array 2 or 3 dimensional numpy array of genotypes/PGS values. First dimension is individuals. For a 2 dimensional array, the second dimension is SNPs or PGS values. For a 3 dimensional array, the second dimension indexes the individual and his/her relatives’ genotypes (for example: proband, paternal, and maternal); and the third dimension is the SNPs.
- ids
array vector of individual IDs of same length as first dimension of garray
- sid
array vector of SNP ids, equal in length, L, to last dimension of array
- alleles
array [L x 2] matrix of ref and alt alleles for the SNPs. L must match size of sid
- pos
array vector of SNP positions; must match size of sid
- chrom
array vector of SNP chromosomes; must match size of sid
- map
array vector of SNP chromosomes; must match size of sid
- fams
array vector of family IDs; must match size of ids
- par_status:class:`~numpy:numpy.array’
[N x 2] numpy matrix that records whether parents have observed or imputed genotypes/PGS, where N matches size of ids. The first column is for the father of that individual; the second column is for the mother of that individual. If the parent is neither observed nor imputed, the value is -1; if observed, 0; and if imputed, 1.
- num_obs_par_al:class:`~numpy:numpy.array’
2 dimensioanal numpy arrray, with each entry holding the number of observed parental alleles for each individual on each locus.
- garray
- Returns:
G :
snipar.gtarray
- add(garray)[source]
Adds another gtarray of the same dimension to this array and returns the sum. It matches IDs before summing.
- diagonalise(inv_root)[source]
This will transform the genotype array based on the inverse square root of the phenotypic covariance matrix from the family based linear mixed model.
- fill_NAs()[source]
This normalises the SNP columns to have mean-zero, then fills in NA values with zero.
- snipar.gtarray.impute_missing(G: gtarray) gtarray[source]
Imputing missing entries of the genotype design matrix.
- Args:
G (gtarray): genotype design matrix.
- Returns:
gtarray: genotype design matrix with NAs imputed.
- snipar.gtarray.impute_unrel_par_gts(G: gtarray, sib: bool = False, parsum: bool = False, ped: ndarray | None = None, grm: Tuple[ndarray, ndarray, ndarray] | None = None, unrelated_inds: ndarray | None = None, true_par=None, par_ids=None) gtarray[source]
Impute parental genotypes of unrelated individuals.
- Args:
G (gtarray): gtarray object holding genetic data. sib (bool, optional): Whether sib effect is modelled. Defaults to False. parsum (bool, optional): Whether sum of parental genotypes is modelled. Defaults to False.
- Returns:
gtarray: gtarray object with imputed parental genotypes.