Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactore/use project #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions pyglotaran_examples/ex_two_datasets/ex_two_datasets2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from datetime import datetime

import matplotlib.pyplot as plt # 3.3 or higher
from glotaran.project.project import Project
from pyglotaran_extras.plotting.plot_overview import plot_overview
from pyglotaran_extras.plotting.style import PlotStyle


project = Project.open(".")
print(project.markdown())


project.optimize(
"model_ex_two_datasets",
"parameters_ex_two_datasets",
name="result_ex_two_datasets",
maximum_number_function_evaluations=15,
)

result = project.load_result("result_ex_two_datasets")
print(result.markdown(True))

# recreation
# result_recreated = result.recreate()

# %% Plot and save as PDF
# This set subsequent plots to the glotaran style
plot_style = PlotStyle()
plt.rc("axes", prop_cycle=plot_style.cycler)

results_folder = project.get_result_path("result_ex_two_datasets")
fig1 = plot_overview(result.data["data1"], linlog=True)
timestamp = datetime.today().strftime("%y%m%d_%H%M")
fig1.savefig(results_folder.joinpath(f"plot_overview_1of2_{timestamp}.pdf"), bbox_inches="tight")

fig2 = plot_overview(result.data["data2"], linlog=True)
timestamp = datetime.today().strftime("%y%m%d_%H%M")
fig2.savefig(results_folder.joinpath(f"plot_overview_2of2_{timestamp}.pdf"), bbox_inches="tight")

plt.show()
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
type: kinetic-spectrum

dataset:
dataset1:
data1:
megacomplex: [complex1]
initial_concentration: input1
irf: irf1
scale: scale.1
dataset2:
data2:
megacomplex: [complex1]
initial_concentration: input2
irf: irf1
Expand Down
1 change: 1 addition & 0 deletions pyglotaran_examples/ex_two_datasets/project.gta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: 0.6.0.dev0
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
label,value,expression,minimum,maximum,non-negative,vary,standard-error
inputs.1,0.5,None,-inf,inf,True,False,None
inputs.2,0.251,None,-inf,inf,True,True,None
inputs.3,0.252,None,-inf,inf,True,True,None
inputs.7,0.21,None,-inf,inf,True,True,None
inputs.8,0.22,None,-inf,inf,True,True,None
scale.1,1.0,None,-inf,inf,False,False,None
scale.2,1.2,None,-inf,inf,False,True,None
rates.k1,0.199,None,-inf,inf,True,True,None
rates.k2,0.5,None,-inf,inf,True,True,None
rates.k3,1.1,None,-inf,inf,True,True,None
irf.center,0.5,None,-inf,inf,False,True,None
irf.width,0.1,None,-inf,inf,False,True,None
area.1,1.0,None,-inf,inf,False,False,None
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
default_megacomplex: decay
dataset_groups:
default:
residual_function: variable_projection
link_clp: null
clp_area_penalties:
- source: s1
source_intervals: [[300, 3000]]
target: s2
target_intervals: [[300, 3000]]
parameter: area.1
weight: 0.1
- source: s1
source_intervals: [[300, 3000]]
target: s3
target_intervals: [[300, 3000]]
parameter: area.1
weight: 0.1
k_matrix:
km1:
matrix:
(s1, s1): rates.k1
(s2, s2): rates.k2
(s3, s3): rates.k3
initial_concentration:
input1:
compartments: [s1, s2, s3]
parameters:
- inputs.1
- inputs.2
- inputs.3
exclude_from_normalize: &id001 []
input2:
compartments: [s1, s2, s3]
parameters:
- inputs.1
- inputs.7
- inputs.8
exclude_from_normalize: *id001
irf:
irf1:
type: spectral-multi-gaussian
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use spectral-XXX irf when no dispersion is used to avoid the unused dispersion. just use gaussian here.

center:
- irf.center
width:
- irf.width
normalize: true
backsweep: false
center_dispersion_coefficients: []
width_dispersion_coefficients: []
model_dispersion_with_wavenumber: false
irf1_no_dispersion:
type: spectral-multi-gaussian
center:
- irf.center
width:
- irf.width
normalize: true
backsweep: false
center_dispersion_coefficients: []
width_dispersion_coefficients: []
model_dispersion_with_wavenumber: false
megacomplex:
complex1:
dimension: time
k_matrix: [km1]
dataset:
data1:
group: default
megacomplex: [complex1]
scale: scale.1
initial_concentration: input1
irf: irf1
data2:
group: default
megacomplex: [complex1]
scale: scale.2
initial_concentration: input2
irf: irf1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
label,value,expression,minimum,maximum,non-negative,vary,standard-error
inputs.1,0.5,None,-inf,inf,True,False,None
inputs.2,0.3241735606305694,None,-inf,inf,True,True,0.006016512068269458
inputs.3,0.6637030039362178,None,-inf,inf,True,True,0.0019604282258593145
inputs.7,0.07199305634408268,None,-inf,inf,True,True,0.007473183032103718
inputs.8,0.28038519367032166,None,-inf,inf,True,True,0.001703415408630161
scale.1,1.0,None,-inf,inf,False,False,None
scale.2,1.0988429227695649,None,-inf,inf,False,True,5.0687678682918585e-05
rates.k1,0.2609087519506281,None,-inf,inf,True,True,0.0003594210205855631
rates.k2,1.1764960957874322,None,-inf,inf,True,True,0.0018332582913621488
rates.k3,0.6161191387338244,None,-inf,inf,True,True,0.001294924541886501
irf.center,0.3999993625795483,None,-inf,inf,False,True,5.5115045961994905e-06
irf.width,0.0599642034148812,None,-inf,inf,False,True,7.46734564090631e-06
area.1,1.0,None,-inf,inf,False,False,None
Loading