Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from NTUMitoLab/update20211018
Browse files Browse the repository at this point in the history
update
  • Loading branch information
stevengogogo authored Oct 18, 2021
2 parents 93cdf81 + 3ee744e commit 2be3ecf
Show file tree
Hide file tree
Showing 148 changed files with 481 additions and 1,886 deletions.
2 changes: 1 addition & 1 deletion ExpressionLevel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.6.1",
"display_name": "Julia 1.6.2",
"language": "julia",
"name": "julia-1.6"
},
Expand Down
211 changes: 211 additions & 0 deletions ExpressionLevelEffect.ipynb
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ authors = ["stevengogogo <stevengogogo4321@gmail.com>"]
version = "0.1.0"

[deps]
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
FrequencyResponse = "23be90ff-b906-42a4-9508-8c19908ecbef"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
LabelledArrays = "2ee39098-c373-598a-b85f-a56591580800"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Expand Down
File renamed without changes.
Binary file not shown.
Binary file added ExpressionLevelEffect/result/Thrshold_Bmh.pdf
Binary file not shown.
Binary file added ExpressionLevelEffect/result/analytical_sol.pdf
Binary file not shown.
59 changes: 59 additions & 0 deletions ExpressionLevelEffect/script/analytic_Rtg2.jl
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), ss
(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)
Loading

0 comments on commit 2be3ecf

Please sign in to comment.