This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from NTUMitoLab/update20211018
update
- Loading branch information
Showing
148 changed files
with
481 additions
and
1,886 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0db6e64e-de69-4738-89a6-a987e3749be8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"using Pkg" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3dc2fbee-8dc0-4ffe-a17a-43d87578507a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"Pkg.activate(\"ExpressionLevelEffect\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b69ddf39-bdf0-44cb-922e-734a44f23dc8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"@time Pkg.instantiate()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0137d189-11ce-4172-903f-4aa446c78171", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"using Revise, FrequencyResponse, DifferentialEquations, LabelledArrays, Plots, ProgressMeter, Distributed\n", | ||
"import RetroSignalModel as rs" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fb35f107-6c3c-4913-ba68-506a66e07eea", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"include(\"ExpressionLevelEffect/script/utils.jl\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2acf00dc-b69f-49b9-836b-cbf542382d1a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Load librarys to workers\n", | ||
"#addprocs(length(Sys.cpu_info()) - nprocs() - 1, exeflags=\"--project=$(Base.active_project())\")\n", | ||
"#@everywhere begin \n", | ||
" using Revise, FrequencyResponse, DifferentialEquations, LabelledArrays, Plots, ProgressMeter\n", | ||
" import RetroSignalModel as rs\n", | ||
"#end\n", | ||
"\n", | ||
"#@everywhere begin \n", | ||
"\n", | ||
"\n", | ||
" # Load Model \n", | ||
" i_sol_PLACE_HOLDER=1\n", | ||
" RTGm = rs.rtgM4(i_sol_PLACE_HOLDER)\n", | ||
" param= (; u=RTGm.u, p=RTGm.p);\n", | ||
"\n", | ||
" # Dynamical Signal\n", | ||
" dynmodel = DynModel(\n", | ||
" model = RTGm.model,\n", | ||
" u = param.u,\n", | ||
" p = param.p,\n", | ||
" solver= Rosenbrock23(),\n", | ||
" signal_func = PosSine(ω=0.05,θ=(3/2)*π, amp=1),\n", | ||
" input_i = 1,\n", | ||
" tspan=(0.,500.),\n", | ||
" init_ss = true # Get steady state\n", | ||
" );\n", | ||
"\n", | ||
" sol = solve(dynmodel;tmax=1.);\n", | ||
"\n", | ||
"\n", | ||
" function sim_square(RTGm, levels)\n", | ||
" dynmodel = DynModel(\n", | ||
" model = RTGm.model,\n", | ||
" u = rs.init_u(RTGm; expLevels=levels),\n", | ||
" p = RTGm.p,\n", | ||
" solver= Rosenbrock23(),\n", | ||
" signal_func= SquarePulse(\n", | ||
" t_str = 125.,\n", | ||
" t_end = 375,\n", | ||
" amp_l =0.,\n", | ||
" amp_h = 1.),\n", | ||
" input_i = 1,\n", | ||
" tspan=(0.,500.),\n", | ||
" init_ss = true # Get steady state\n", | ||
" );\n", | ||
" sol = solve(dynmodel;tmax=1.);\n", | ||
" return sol\n", | ||
" end\n", | ||
"\n", | ||
" function mut_tuple(tup, i, mul)\n", | ||
" vs = NamedTuple{tuple(i)}(tuple(tup[i]*mul))\n", | ||
" return LVector(merge(tup, vs))\n", | ||
" end\n", | ||
"\n", | ||
" \"\"\"\n", | ||
" pr: protein to change\n", | ||
" ch: change fold\n", | ||
" obs: observe protein\n", | ||
" \"\"\"\n", | ||
" function ch_cmp(pr, ch, obs;i = i_sol_PLACE_HOLDER)\n", | ||
" RTGm = rs.rtgM4(i)\n", | ||
" levels =rs.getExpLevels(;condition=rs.DefaultCondition)\n", | ||
"\n", | ||
" #simulation\n", | ||
" sol = sim_square(RTGm, levels)\n", | ||
" sol2 = sim_square(RTGm, mut_tuple(levels, pr, ch)) \n", | ||
"\n", | ||
"\n", | ||
" p = Plots.plot(sol.t,total_conc(sol, RTGm, obs), label=\"Control\")\n", | ||
" Plots.plot!(p, sol2.t,total_conc(sol2, RTGm, obs), label=string(pr,\":\",ch,\"x\"))\n", | ||
"\n", | ||
" Plots.xlabel!(p, \"time\")\n", | ||
" Plots.ylabel!(p, \"Concentration ($(obs))\")\n", | ||
" return p\n", | ||
" end\n", | ||
"\n", | ||
" function ch_cmp!(p, pr, ch, obs;i = i_sol_PLACE_HOLDER, plot_control=false)\n", | ||
" RTGm = rs.rtgM4(i)\n", | ||
" levels =rs.getExpLevels(;condition=rs.DefaultCondition)\n", | ||
"\n", | ||
" #simulation\n", | ||
" sol2 = sim_square(RTGm, mut_tuple(levels, pr, ch)) \n", | ||
"\n", | ||
"\n", | ||
" if plot_control \n", | ||
" sol = sim_square(RTGm, levels)\n", | ||
" Plots.plot!(p, sol.t,total_conc(sol, RTGm, obs), label=\"Control\") \n", | ||
" end\n", | ||
"\n", | ||
" Plots.plot!(p, sol2.t,total_conc(sol2, RTGm, obs), label=string(pr,\":\",ch,\"x\"))\n", | ||
"\n", | ||
" Plots.xlabel!(p, \"time\")\n", | ||
" Plots.ylabel!(p, \"Concentration ($(obs))\")\n", | ||
" return p\n", | ||
" end\n", | ||
"\n", | ||
" \"\"\"\n", | ||
" ob: name of observe protein; chs: list of changes\n", | ||
" \"\"\"\n", | ||
" function simulation(ob, pr, chs)\n", | ||
" plot_control = false\n", | ||
" p_ = Plots.plot()\n", | ||
" for c in chs \n", | ||
" if plot_control == false \n", | ||
" ch_cmp!(p_, pr, c, ob;plot_control=true)\n", | ||
" plot_control = true\n", | ||
" end\n", | ||
" ch_cmp!(p_, pr, c, ob;plot_control=false) \n", | ||
" end\n", | ||
" name = string(pr,\"_\",\"foldChange\" ,\"_\",\"obs_\",ob)\n", | ||
" @show name\n", | ||
" Plots.savefig(p_, joinpath(dirname(@__DIR__),\"result\",\"$(name).pdf\"))\n", | ||
" p_ = nothing\n", | ||
" end\n", | ||
"#end \n", | ||
"\n", | ||
"levels =rs.getExpLevels(;condition=rs.DefaultCondition)\n", | ||
"prs = keys(levels)\n", | ||
"obs = [:Rtg1_n, :Rtg3_n]\n", | ||
"chs = [0.001,0.01,0.1,0.2,0.5,1.,2.,4. ,8., 16.,50.,100.]\n", | ||
"\n", | ||
"sims = [(b,pr,chs) for b in obs for pr in prs]\n", | ||
"\n", | ||
"#@showprogress map(x->simulation(x...), sims)\n", | ||
"@showprogress for sim in sims \n", | ||
" simulation(sim...)\n", | ||
"end" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1164fbba-b9a8-4f92-a5fa-b481962f885f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Julia 1.6.2", | ||
"language": "julia", | ||
"name": "julia-1.6" | ||
}, | ||
"language_info": { | ||
"name": "" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
using Pkg | ||
Pkg.activate(dirname(@__DIR__)) | ||
Pkg.instantiate() | ||
|
||
using Catalyst | ||
import RetroSignalModel as rs | ||
|
||
function get_total_conc(concs, feature) | ||
Is = [ i for i in keys(RTGm.u) if occursin(feature,string(i))] | ||
return sum(concs[Is]) | ||
end | ||
|
||
rtg2m = @reaction_network begin | ||
(1), s→s | ||
(hill(s, ksV, ksD, n_s), k2I), Rtg2_ina_c ↔ Rtg2_act_c #[1] | ||
(k2M, kn2M), Rtg2_act_c + Mks ↔ Rtg2Mks_c | ||
(kBM, knBM), Bmh + Mks ↔ BmhMks | ||
end n_s ksV ksD k2I k2M kn2M kBM knBM | ||
|
||
|
||
RTGm = rs.rtgM4(1) | ||
Catalyst.params(RTGm.model) | ||
Catalyst.params(rtg2m) | ||
|
||
ps = NamedTuple{tuple(Symbol.(params(RTGm.model))...)}(RTGm.p) | ||
psR = NamedTuple{tuple(Symbol.(params(rtg2m))...)}(tuple([getindex(ps, Symbol(i)) for i in Catalyst.params(rtg2m)]...)) | ||
|
||
|
||
|
||
|
||
Kr = psR.kn2M/psR.k2M | ||
Kb = psR.knBM/psR.kBM | ||
Kt(s) = psR.k2I/ (psR.ksV * s^psR.n_s / (psR.ksD^psR.n_s + s^psR.n_s)) | ||
Kr_(s) = Kr*(1+1/Kt(s)) | ||
|
||
|
||
Rtg2₀ = get_total_conc(RTGm.u, "Rtg2") | ||
Bmh₀ = get_total_conc(RTGm.u, "Bmh") | ||
Mks₀ = get_total_conc(RTGm.u, "Mks") | ||
|
||
a(s) = Kr_(s) + Kb + Rtg2₀ + Bmh₀ - Mks₀ | ||
b(s) = Kb*(Rtg2₀ - Mks₀) + Kr_(s)*(Bmh₀ - Mks₀)+Kr_(s)*Kb | ||
c(s) = -Kr_(s)*Kb*Mks₀ | ||
|
||
θ(s) = acos( (-2*a(s)^3 + 9*a(s)*b(s) - 27*c(s)) / (2*sqrt((a(s)^2-3*b(s))^3))) | ||
|
||
Mks(s) = -a(s)/3 + 2/3*sqrt(a(s)^2 - 3*b(s)) * cos(θ(s)/3) | ||
|
||
function auxB(s) | ||
2*sqrt(a(s)^2-3*b(s))*cos(θ(s)/3) - a(s) | ||
end | ||
function BmhMks(s) | ||
return Bmh₀*aux(s) / (3*Kb + aux(s)) | ||
end | ||
|
||
Mks(1) | ||
BmhMks(0.) | ||
BmhMks(0.01) |
Oops, something went wrong.