Statistical testing of experimental data¶
-
fret_tester.
batch_test
(*args, **kwargs)[source]¶ Call batch_test with TwoStateExpTruth and simulate_dataset
This calls the
BatchTester.batch_test()
method for aBatchTester
instance which usestime_trace.TwoStateExpTruth
for state change trajectory simulation andtime_trace.simulate_dataset()
for FRET simulation.For details about parameters, return values, etc. see
BatchTester.batch_test()
.
-
class
fret_tester.
BatchTester
(truth_generator, sim_func)[source]¶ Parameters: - truth_generator (type) – Class to be initialized with lifetimes and FRET efficiencies.
Instances should be callable with one parameter, the minimum
time trace length and return a ground truth time trace.
TwoStateExpTruth
would be an example. - sim_func (callable) – Function to simulate a dataset. See
simulate_dataset()
for an example and the call signature.
-
batch_test
(test_times, efficiencies, exposure_time, data_points, photons, experiment_data, donor_brightness, acceptor_brightness, nprocs=1, nchunks=None)[source]¶ Test experiment data against many simulated data sets
For each set of (test) life times, simulate smFRET events and compare to the experiment data using a two-sample KS test. The difference is expressed in terms of the p-value.
Parameters: - test_times (array_like) – Lifetimes to test experiment data against. Run simulations for
each set of test lifes.
test_times[i]
has to be an array of test times for the i-th state. - efficiencies (array_like) – Array of FRET efficiencies
- exposure_time (float) – Exposure time as used in the experiment
- data_points (int) – Number of smFRET data points to simulate
- photons (int) – Mean number of photons emitted per exposure
- experiment_data (array_like) – smFRET efficiency values from the experiment
- donor_brightness, acceptor_brightness (callable) – Takes one argument, an array of mean brightness values. For each entry m it returns a random value drawn from the brightness distribution with mean m.
- nprocs (int, optional) – Number of processes to use for parallel simulation. Defaults to 1,
i.e. no multiprocessing, since multiprocessing requires additional
measures, such as proper
if __name__ == "__main__"
blocks. - nchunks (int or None, optional) – Number of chunks into which to split the data for parallel
simulation. If None (default), use
nprocs * 2
.
Returns: p-values returned by KS tests. The array has the same shape as the test_times minus the first dimension.
Return type: numpy.ndarray
- test_times (array_like) – Lifetimes to test experiment data against. Run simulations for
each set of test lifes.
- truth_generator (type) – Class to be initialized with lifetimes and FRET efficiencies.
Instances should be callable with one parameter, the minimum
time trace length and return a ground truth time trace.
-
fret_tester.
combine_test_results
(results)[source]¶ Given multiple test results, calculate p-values for global consistency
Multiple tests at e.g. different exposure times will lead to multiple areas of consistency. Since lifetimes should not depend on exposure times, one would only consider those lifetime combinations consistent which yield high p-values for all exposure times. This is done by calculating
\[\hat{p}(\tau_1, \tau_2) = 1 - (1 - p_\text{min}(\tau_1, \tau_2))^{|T_\text{ex}|},\]where \(T_\text{ex}\) is the set of test results.
Parameters: results (list of array-like, shape(m, n)) – Test results Returns: Array of \(\hat{p}\) values Return type: numpy.ndarray, shape(m, n)