snipar.ibd module

snipar.ibd.find_segments(path, map, snps, pos)[source]
snipar.ibd.infer_ibd(sibpairs, gts, freqs, map, weights, error_probs)[source]
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:

g1array

integer vector of first sibling’s genotypes

g2array

integer vector of first sibling’s genotypes

freqsarray

floating point vector of allele frequencies

maparray

floating point vector of genetic positions in cM

weightsarray

floating point vector of SNP weights (usually inverse LD-scores)

p:class:’float’

genotyping error probability

Returns:
state_matrixarray

matrix where each column gives the prob of max prob path to that state, where each row is IBD 0,1,2

pointersarray

integer vector giving the pointer to which state from previous position lead to max at this position

snipar.ibd.p_ibd_0(f)[source]

Compute Joint-PMF for sibling pair genotypes given IBD0. Args:

ffloat

allele frequency

Returns:
Parray

matrix of probabilities

snipar.ibd.p_ibd_1(f)[source]

Compute Joint-PMF for sibling pair genotypes given IBD1. Args:

ffloat

allele frequency

Returns:
Parray

matrix of probabilities

snipar.ibd.p_ibd_2(f)[source]

Compute Joint-PMF for sibling pair genotypes given IBD2. Args:

ffloat

allele frequency

Returns:
Parray

matrix of probabilities

snipar.ibd.p_obs_given_IBD(g1_obs, g2_obs, f, p)[source]

Compute Joint-PMF for sibling pair genotypes given IBD0. Args:

g1_obsinteger

observed genotype for sibling 1

g2_obsinteger

observed genotype for sibling 2

ffloat

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

class snipar.ibd.segment(start_index, end_index, start_bp, end_bp, start_snp, end_snp, length, state)[source]

Bases: object

to_text(id1, id2, chr, end=False)[source]
snipar.ibd.smooth_ibd(ibd, map, snps, pos, min_length)[source]
snipar.ibd.smooth_segments(path, map, snps, pos, min_length)[source]
snipar.ibd.transition_matrix(cM)[source]

Compute probabilities of transitioning between IBD states as a function of genetic distance. Args:

cMfloat

genetic distance in centiMorgans (cM)

Returns:
log(P)array

the natural logarithm (element-wise) of the matrix of transition probabilities

snipar.ibd.viterbi(state_matrix, pointers)[source]

Get viterbi path from state_matrix and pointers output of make_dynamic Args:

state_matrixarray

matrix where each column gives the prob of max prob path to that state, where each row is IBD 0,1,2

pointersarray

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

snipar.ibd.write_segs(sibpairs, allsegs, chr, outfile)[source]
snipar.ibd.write_segs_from_matrix(ibd, sibpairs, snps, pos, map, chrom, outfile)[source]