snipar.ibd module
- snipar.ibd.infer_ibd_chr(sibpairs, error_prob, error_probs, outprefix, bedfile=None, bgenfile=None, chrom=None, min_length=0.01, mapfile=None, ibdmatrix=False, ld_out=False, min_maf=0.01, max_missing=5, max_error=0.01)[source]
- snipar.ibd.make_dynamic(g1, g2, freqs, map, weights, error_probs)[source]
Make state-matrix and pointer matrix for a sibling pair by dynamic programming Args:
- g1
array
integer vector of first sibling’s genotypes
- g2
array
integer vector of first sibling’s genotypes
- freqs
array
floating point vector of allele frequencies
- map
array
floating point vector of genetic positions in cM
- weights
array
floating point vector of SNP weights (usually inverse LD-scores)
- p:class:’float’
genotyping error probability
- Returns:
- state_matrix
array
matrix where each column gives the prob of max prob path to that state, where each row is IBD 0,1,2
- pointers
array
integer vector giving the pointer to which state from previous position lead to max at this position
- state_matrix
- g1
- snipar.ibd.p_ibd_0(f)[source]
Compute Joint-PMF for sibling pair genotypes given IBD0. Args:
- f
float
allele frequency
- Returns:
- P
array
matrix of probabilities
- P
- f
- snipar.ibd.p_ibd_1(f)[source]
Compute Joint-PMF for sibling pair genotypes given IBD1. Args:
- f
float
allele frequency
- Returns:
- P
array
matrix of probabilities
- P
- f
- snipar.ibd.p_ibd_2(f)[source]
Compute Joint-PMF for sibling pair genotypes given IBD2. Args:
- f
float
allele frequency
- Returns:
- P
array
matrix of probabilities
- P
- f
- snipar.ibd.p_obs_given_IBD(g1_obs, g2_obs, f, p)[source]
Compute Joint-PMF for sibling pair genotypes given IBD0. Args:
- g1_obs
integer
observed genotype for sibling 1
- g2_obs
integer
observed genotype for sibling 2
- f
float
allele frequency
- p:class:’float’
genotyping error probability
- Returns:
- log(P)
array
vector giving log-probabilities of observing g1_obs,g2_obs give IBD 0,1,2
- log(P)
- g1_obs
- class snipar.ibd.segment(start_index, end_index, start_bp, end_bp, start_snp, end_snp, length, state)[source]
Bases:
object
- snipar.ibd.transition_matrix(cM)[source]
Compute probabilities of transitioning between IBD states as a function of genetic distance. Args:
- cM
float
genetic distance in centiMorgans (cM)
- Returns:
- log(P)
array
the natural logarithm (element-wise) of the matrix of transition probabilities
- log(P)
- cM
- snipar.ibd.viterbi(state_matrix, pointers)[source]
Get viterbi path from state_matrix and pointers output of make_dynamic Args:
- state_matrix
array
matrix where each column gives the prob of max prob path to that state, where each row is IBD 0,1,2
- pointers
array
integer vector giving the pointer to which state from previous position lead to max at this position
- Returns:
path :
array
integer vector giving the Viterbi path through the IBD states
- state_matrix