stats submodule#
This sub-module contains functions compute the posterior probability that a nucleotide is footprinted.
- footprint_tools.stats.posterior.compute_delta_prior(obs, exp, fdr, beta_prior, cutoff=0.05)#
Returns a point estimate of exepected cleavage depletion with a footprint at each nucleotide
- Parameters
- obsndarray
Array with observed cleavages counts (2D - nucleotides x samples)
- expndarray
Array with expectd cleavages counts (2D - nucleotides x samples)
- fdrndarray
Array with adjusted p-values (2D - nucleotides x samples)
- beta_priorndarray
Description
- cutofffloat, optional
FDR cutoff value to label a nucleotide as occupied when building prior
- Returns
- delta: ndarray
Per-nucleotide priors of expected nucleotide protection at footprinted sites (values explicitly in [0, 1]). Arrays is 1-D corresponding to DHS
- footprint_tools.stats.posterior.compute_prior_weighted(fdr, w, cutoff=0.05, pseudocount=0.5)#
Returns prior of whether a nucleotide is footprinted
- Parameters
- fdrndarray
FDR values for each datset and position
- wndarray
Binary array whether nucleotide is within a DHS
- cutofffloat, optional
FPR cutoff value to label as occupied when building prior
- pseudocountfloat, optional
Psuedocount to add as prior to Beta distribution
- Returns
np.arrayPer-nucleotide occupancy prior
- footprint_tools.stats.posterior.log_likelihood(obs, exp, dm, delta=1, w=3)#
Likelihood function of observed counts given the bias corrected data and an expected protection
- Parameters
- obsndarray
Observed cleavage counts
- expndarray
Expected cleavage counts
- dm
dispersion_model Dispersional model to compute cleavage statistics
- deltaarray_like, optional
Values to scale exp counts
- wint, optional
Half window width to compute log-likelihood. Default 3bp (combined 7bp window)
- Returns
- log_likelihood: ndarray
Array of log-likelihoods for each nucloetides and samples
- footprint_tools.stats.posterior.posterior(prior, ll_on, ll_off)#
Compute the posterior probability of a nucleotide
- Parameters
- priorndarray
Per-nucleotide prior that a site is footprinted
- ll_onndarray
Log-likelihood that a nucleotide is occupied
- ll_offndarray
Log-likelihood that a nucleotide is unoccupied
- Returns
- posteriorsndarray
log posterior that a nucleotde is footprinted in sample. Array is 2-D corresponding to nucleotides and samples.
- footprint_tools.stats.differential.compute_log_prior_t(ndarray obs_over_exp, data_type_t nu_0, data_type_t sig2_0, data_type_t lo, data_type_t hi, int nslices) -> ndarray Computes the log posterior distribution of the hyperparameters (normal * inv chi2 = students t)#
Computes the log posterior distribution of the hyperparameters (normal * inv chi2 = students t)
- Parameters
- Returns
- footprint_tools.stats.differential.compute_logpmf_values(dm, ndarray obs, ndarray exp, data_type_t lo, data_type_t hi, int nslices) ndarray#
Compute log pmf
This sub-module contains functions for performing sliding window functions written in native C.
- footprint_tools.stats.windowing.fishers_combined()#
Compute p-values for a window using Fisher’s combined method
- Returns
- out
numpy.ndarray Array of combined p-values
- out
- footprint_tools.stats.windowing.product()#
Sum of values in sliding local window across array
- Returns
- out
numpy.ndarray Array of windowed product values
- out
- footprint_tools.stats.windowing.stouffers_z()#
Compute p-values for a window using Stouffer’s Z-score method
- Returns
- out
numpy.ndarray Array of combined p-values
- out
- footprint_tools.stats.windowing.sum()#
Sum of values in sliding local window across array
- Returns
- outndarray
Array of windowed summed values
- footprint_tools.stats.windowing.weighted_stouffers_z()#
Compute p-value for a window using weighted Stouffer’s method
- Parameters
- x
numpy.ndarray P-values to perform Stouffer’s Z-score method. Array must be memory contiguous (i.e., np.ascontiguousarray(x))
- w: ndarray
Weights for each elements in x
- hw: int
Half window with to combined p-values
- x
- Returns
- out
numpy.ndarray Array of combined p-values
- out
This sub-module contains utility functions for stats module
- footprint_tools.stats.utils.bisect()#
Bisect arrays
- Parameters
- aarray_like
- barray_like
- Returns
- outndarray
Bisected list
- footprint_tools.stats.utils.segment()#
Segment an array into continuous elements passing a threshold
- Parameters
- xarray_like
Array of values to segment
- thresholdfloat
Threshold for grouping elements
- wint
Window size
- decreasingbool
- Returns
- outlist
List of tuples which specific the start and end index of contiguous intervals that pass threshold