|
3 | 3 | # %% |
4 | 4 | from pathlib import Path |
5 | 5 |
|
| 6 | +import numpy as np |
| 7 | +import proplot as pplt |
| 8 | +import yaml |
| 9 | + |
6 | 10 | from pyhdx.datasets import HDXDataSet |
7 | | -from pyhdx.models import HDXMeasurement |
8 | | -from pyhdx.fitting import fit_gibbs_global, fit_rates_weighted_average |
9 | 11 | from pyhdx.fileIO import csv_to_dataframe, save_fitresult |
| 12 | +from pyhdx.fitting import fit_gibbs_global, fit_rates_weighted_average |
10 | 13 | from pyhdx.local_cluster import default_client |
11 | | -import yaml |
| 14 | +from pyhdx.models import HDXMeasurement |
12 | 15 |
|
13 | 16 | # %% |
14 | 17 |
|
15 | 18 | guess = False # Set to True to redo initial guesses |
16 | | -fit_kwargs = {"epochs": 10000, "lr": 1e4, "stop_loss": 1e-6} |
| 19 | +fit_kwargs = {"epochs": 200000, "lr": 1e4, "stop_loss": 1e-6} |
17 | 20 |
|
18 | 21 | # %% |
19 | 22 | current_dir = Path(__file__).parent |
|
55 | 58 | fr_torch.to_file(output_dir / "SecB_fit_result.csv", fmt="csv") |
56 | 59 |
|
57 | 60 | save_fitresult(output_dir / "SecB_fit", fr_torch) |
| 61 | + |
| 62 | +# %% |
| 63 | +# evaluate the fit, plot measured and fitted D-uptake for a few peptides |
| 64 | +NUM_EVAL_POINTS = 100 |
| 65 | +all_timepoints = np.concatenate([hdxm.timepoints for hdxm in fr_torch.hdxm_set]) |
| 66 | + |
| 67 | +elem = all_timepoints[np.nonzero(all_timepoints)] |
| 68 | +start = np.log10(elem.min()) |
| 69 | +end = np.log10(elem.max()) |
| 70 | +pad = (end - start) * 0.1 |
| 71 | +time = np.logspace(start - pad, end + pad, num=NUM_EVAL_POINTS, endpoint=True) |
| 72 | + |
| 73 | + |
| 74 | +# %% |
| 75 | +# evaluate the fitted model at timepoints |
| 76 | +d_calc = fr_torch(time) # Ns x Np x Nt |
| 77 | +d_calc |
| 78 | +# %% |
| 79 | +# choose which sample to plot |
| 80 | +# here we plot the first one (= SecB tetramer) |
| 81 | +sample_idx = 0 |
| 82 | +hdxm = fr_torch.hdxm_set.hdxm_list[sample_idx] |
| 83 | +d_calc_s = d_calc[sample_idx] |
| 84 | + |
| 85 | +# %% |
| 86 | +# make a subplot grid to plot the first 24 peptides |
| 87 | +fig, axes = pplt.subplots(ncols=4, nrows=6) |
| 88 | +for i, ax in enumerate(axes): |
| 89 | + ax.plot(time, d_calc_s[i], color="r") |
| 90 | + ax.scatter(hdxm.timepoints, hdxm.d_exp.iloc[i], color="k") |
| 91 | + |
| 92 | +axes.format(xscale="log", xlabel="Time (s)", ylabel="Corrected D-uptake", ylim=(0, None)) |
| 93 | +# %% |
0 commit comments