You need to be inside the python directory (this directory) for this to work, as all output paths are relative to it.
Running any of the scripts without arguments will display a list of their required and optional command line arguments.
The likelihood (noise model) is chosen with the --capped-data flag. See Noise model in the main README for what it does, and why we recommend ../data/modified_crumb_data.csv with --capped-data for the Crumb data.
The MCMC script is
PyHillFit.py
which is called from the command line.
Two arguments are always required:
--data-file: an input data csv file, in the same format as the provided../data/crumb_data.csv(see below).-m/--model: which dose-response model to use:1: fix Hill = 1, and only vary pIC50 and sigma in the MCMC;2: allow Hill to vary as well.
The default is to run the single-level MCMC algorithm.
For the Crumb data we recommend using the capped data file ../data/modified_crumb_data.csv together with the --capped-data flag, which uses a censored likelihood for responses recorded as exactly 0 or 100% inhibition (see Noise model in the main README for why).
To do this, allowing Hill to vary, run
python PyHillFit.py --data-file ../data/modified_crumb_data.csv --capped-data -m 2
or to fix Hill = 1:
python PyHillFit.py --data-file ../data/modified_crumb_data.csv --capped-data -m 1
You will then be asked to select drug(s) and channel(s) from a menu (enter one or more numbers separated by spaces).
Alternatively, add -a / --all to run every drug and channel combination in the data file.
To run the hierarchical MCMC, include the --hierarchical argument:
python PyHillFit.py --data-file ../data/modified_crumb_data.csv --capped-data -m 2 --hierarchical
The hierarchical model always lets Hill vary, so the -m value is ignored, but it is still required and must be 1 or 2.
To use the uncapped (plain Gaussian noise) likelihood instead, leave out --capped-data. This also accepts data outside [0,100], e.g. the original ../data/crumb_data.csv.
Other useful optional arguments include:
-i/--iterations: number of MCMC iterations (default 500000);-t/--thinning: save every t-th iteration (default 5);-b/--burn-in-fraction: discard the first 1/b of saved iterations as burn-in (default 4);-c/--num-cores: number of cores to use when running several drug/channel combinations in parallel;-Ne/--num-expts: (hierarchical only) only fit to the first Ne experiments (default 0 = all);-bfo/--best-fit-only: (single-level only) do the CMA-ES best fit, then quit;-ppp/--plot-parameter-paths: (hierarchical only) plot the path of each parameter through the MCMC.
The examples below follow on from the recommended runs above, using ../data/modified_crumb_data.csv with --capped-data.
The post-processing and plotting scripts must be given the same --data-file and the same --capped-data setting as the MCMC runs, so that they read the results from the right output directories (see Input data files): if you ran the MCMC without --capped-data, leave it out here too.
After running the hierarchical MCMC, you should run:
python construct_hierarchical_cdfs.py --data-file ../data/modified_crumb_data.csv --capped-data
and select from the drug/channel menu, which will compute the posterior predictive distributions for pIC50_i and Hill_i.
After you have run the hierarchical MCMC, construct_hierarchical_cdfs.py, and the single-level MCMC with -m 2, you can plot a comparison of predicted dose-response curves:
python plot_all_predicted_curves.py --data-file ../data/modified_crumb_data.csv --capped-data -c 0.05 2
where -c 0.05 2 means "plot predictions for % block at concentrations of 0.05 and 2 uM". You can give more or fewer than two, but the plots will get messy. Again, you'll have to choose drug and channel from the list provided.
To compare against single-level results with Hill fixed (i.e. from -m 1), add --fix-hill.
The figures for all drugs and channels are saved together in output/<name>/all_prediction_curves/.
After only hierarchical (as in, you don't need non-hierarchical for this), you can plot superimposed marginal distributions and predicted dose-response curves using the mid-level parameters:
python plot_hierarchical_superimposed.py --data-file ../data/modified_crumb_data.csv --capped-data
and again select from the menu.
After running the single-level MCMC with both -m 1 and -m 2, you can plot the dose-response curves from both models side by side:
python plot_nonhierarchical_curves.py --data-file ../data/modified_crumb_data.csv --capped-data
The figures for all drugs and channels are saved together in output/<name>/single-level/_model_comparison_curves/.
Everything will be saved in python/output/... plus a very verbose and hopefully-easy-to-follow chain of subdirectories.
The prior distributions are the same for every drug and channel, so they are plotted just once per run, in output/<name>/single-level/_prior_figures/model_<m>/ or output/<name>/hierarchical/_prior_figures/ (see below for <name>).
Input data should be a csv file in the same format as data/crumb_data.csv, with one header line: "Compound,Channel,Experiment,Dose(uM),Response(%inhibition)". Each data file can have as many compounds and channels as required. Note that doses should be given in microMolar, as the conversion to pIC50 is hard-coded to these units.
Output is saved under output/<name>/, where <name> is the data file name without .csv, plus a _capped suffix when --capped-data is used: e.g. output/crumb_data/ or output/modified_crumb_data_capped/.
So the same data file can be fitted both with and without --capped-data without one run overwriting the other, but the post-processing and plotting scripts must be given the same --capped-data setting as the MCMC runs to find the right results.
PyHillTemp runs the same MCMC code as (non-hierarchical) PyHillFit, except at different temperatures, i.e. the likelihood is raised to the power t (the temperature) where 0 <= t <= 1.
t = 1 is the full likelihood and therefore "normal" MCMC.
These different temperatures are for approximating Bayes factors (model 1 vs model 2) using thermodynamic integration.
"Temp" = "Temperature", not "Temporary"!
Unlike PyHillFit.py, there is no menu: the drug and channel are given by (zero-based) index with -d / --drug and -c / --channel, in the order they first appear in the data file.
Use -nc / --num-cores to run the different temperatures in parallel.
A bash script like this, run from this directory, runs for a range of compounds and channels:
for channel in 0 1 2 3 <...>
do
for drug in 0 1 2 3 <...>
do
for model in 1 2
do
python PyHillTemp.py --data-file ../data/modified_crumb_data.csv --capped-data -m ${model} -nc 16 -d ${drug} -c ${channel}
done
python compute_bayes_factors.py --data-file ../data/modified_crumb_data.csv --capped-data -d ${drug} -c ${channel}
done
done
As above, this uses the recommended capped Crumb data with --capped-data (see Noise model). If you leave --capped-data out, leave it out of both PyHillTemp.py and compute_bayes_factors.py, since the Bayes factor calculation re-evaluates the likelihood on the saved chains.
compute_bayes_factors.py saves each Bayes factor (model 1 vs model 2) in a text file output/<name>/bayes_factors/<drug>_<channel>_B12.txt (with <name> as for the other output, e.g. crumb_data or modified_crumb_data_capped).
The first line is B12; the next two (# comments, so np.loadtxt still reads just the number) say which model is more likely, and how strongly on Jeffreys' scale: Bayes factor 1-3 "barely worth mentioning", 3-10 "substantial", 10-100 "strong", over 100 "decisive" (the same thresholds that assemble_BFs.py counts), e.g.
4.260494509126957485e-01
# Model 2 (Hill varies) is more likely than model 1 (Hill fixed at 1): B21 = 2.35
# Evidence is "barely worth mentioning" on Jeffreys' scale
``` `assemble_BFs.py` reads them from there, and also needs `--capped-data` if it was used.