simplicity.tuning package
Submodules
simplicity.tuning.diagnosis_rate module
Created on Fri Jul 29 13:26:33 2022
@author: pi
- simplicity.tuning.diagnosis_rate.diagnosis_rate_table(diagnosis_rates, tau_1, tau_2, tau_3, tau_4)[source]
- simplicity.tuning.diagnosis_rate.get_B(tau_1, tau_2, tau_3, tau_4, k_d)[source]
Generate the matrix that defines the intra-host model of SARS-CoV-2 pathogenesis with diagnosis
- simplicity.tuning.diagnosis_rate.get_diagnosis_rate_in_percent(tau_1, tau_2, tau_3, tau_4, k_d)[source]
refer to method paper to read the math behind this.
- simplicity.tuning.diagnosis_rate.get_diagnosis_rates(simulation_output_dir, individual_type)[source]
get theoretical and effective diagnosis rates
- simplicity.tuning.diagnosis_rate.get_effective_diagnosis_rate(simulation_output_dir, individual_type=None)[source]
- simplicity.tuning.diagnosis_rate.get_k_d_from_diagnosis_rate(target_diagnosis_rate_in_percent, tau_1, tau_2, tau_3, tau_4)[source]
linear search to find k_d value that correspond to desired diagnosis rate in percent (0.00-1)
- Parameters:
diagnosis_rate_percent – Target value
- Returns:
value of k_d corresponding to diagnosis_rate_in_percent
simplicity.tuning.evolutionary_rate module
In this file we perform the TempEst linear regression to estimate the observed evolutionary rate u from the simulated data of a SIMPLICITY run. There are also the functions to plot E (model nucleotide substitution rate) vs u (observed substitution rate) or vs any other simulation parameter.
- simplicity.tuning.evolutionary_rate.compute_calibrated_parameter(model_type, fit_result, target_osr)[source]
The unified bridge function. Dispatches the calculation to the correct inverse function.
- Parameters:
model_type (str) – ‘lin’, ‘log’, ‘exp’, ‘tan’.
fit_result (lmfit.model.ModelResult) – The result object from fitting.
target_osr (float) – The target Observed Substitution Rate.
- Returns:
The calibrated parameter value (NSR or Factor).
- Return type:
float
- simplicity.tuning.evolutionary_rate.fit_observed_substitution_rate_regressor(experiment_name, df, model_type, weights=None, parameter_name='nucleotide_substitution_rate')[source]
Fits a model to the observed substitution rate against a varying parameter.
- Parameters:
experiment_name (str) – Name of the experiment
df (pd.DataFrame) – Data containing the parameter column and ‘observed_substitution_rate’
model_type (str) – Type of model to fit (‘lin’, ‘log’, etc.)
weights – Optional weights for fitting
parameter_name (str) – The column name of the independent variable (x-axis). Defaults to ‘nucleotide_substitution_rate’.
- simplicity.tuning.evolutionary_rate.inverse_exp_regressor(OSR, params)[source]
Computes inverse of: y = A * x**B Returns: x = ((y) / A) ** (1/B)
- simplicity.tuning.evolutionary_rate.inverse_linear_regressor(OSR, params)[source]
Computes inverse of: y = A * x + B Returns: x = (y - B) / A
- simplicity.tuning.evolutionary_rate.inverse_log_regressor(OSR, params)[source]
Computes inverse of: y = A * log(B * x) Returns: x = (exp(y / A)) / B
- simplicity.tuning.evolutionary_rate.inverse_tan_regressor(OSR, params)[source]
Computes inverse of: y = A * tan(B * x - C) Returns: x = (arctan((y) / A) + C) / B
- simplicity.tuning.evolutionary_rate.tempest_regression(sequencing_data_df)[source]
perform TempEst regression on dataframe of sequencing data
- Parameters:
df (pandas df) – output of create_joint_sequencing_df.
- Returns:
u (TYPE) – observed substitution rate (OSR)
model (func) – fitted model (sklearn linear regression).