lpnguyen commited on
Commit
1f2c355
1 Parent(s): 96b2a51

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from dynamical_system import invasion_fitness, invasion_fitness2
3
+ import numpy as np
4
+ from tools import plot_3D_invfitness, plot_invasionfitness, make_interactive_video, plot_PIP
5
+
6
+ st.set_page_config(layout="wide")
7
+ st.title("Adaptive dynamics")
8
+
9
+ st.subheader("When there is no cost on reproduction")
10
+
11
+
12
+ zlist = np.linspace(0, 2, 100)
13
+ alpha = 0.4
14
+
15
+ X, Y = np.meshgrid(zlist, zlist)
16
+ inv_fitness3D = invasion_fitness(X, Y, pars=alpha)
17
+
18
+
19
+ col1, col2 = st.columns(2, gap="large")
20
+ with col1:
21
+ st.plotly_chart(make_interactive_video(
22
+ 0.01, zlist[-1], 0.03, zlist, invasion_fitness, alpha, [-2, 2]))
23
+
24
+
25
+ with col2:
26
+ zm = st.slider("Mutant trait value", 0.0, 2.0, value=0.2, step=0.01)
27
+ st.plotly_chart(plot_invasionfitness(
28
+ zm, zlist, invasion_fitness, alpha, [-2, 2]))
29
+
30
+ col3, col4 = st.columns(2, gap="large")
31
+ with col3:
32
+ st.plotly_chart(plot_3D_invfitness(zlist, inv_fitness3D, zm, (-2.9, 2.9)))
33
+ with col4:
34
+ st.plotly_chart(plot_PIP(zlist, invasion_fitness, alpha))
35
+
36
+ st.header("When there is cost in reproduction")
37
+
38
+ zlist = np.linspace(0, 1, 100)
39
+
40
+ beta = st.slider(r"Value of $\beta$", 0.1, 2.0, value=1.2, step=0.2)
41
+ col5, col6 = st.columns(2, gap="large")
42
+ with col5:
43
+ st.plotly_chart(
44
+ make_interactive_video(
45
+ 0.1, zlist[-1], 0.01, zlist, invasion_fitness2, (alpha, beta), [-0.2, 0.2])
46
+ )
47
+ with col6:
48
+ zm2 = st.slider("Mutant trait value ", 0.0, 1.0, value=0.1, step=0.01)
49
+ st.plotly_chart(plot_invasionfitness(
50
+ zm2, zlist, invasion_fitness2, (alpha, beta), [-0.2, 0.2]))
51
+
52
+ X, Y = np.meshgrid(zlist, zlist)
53
+ inv_fitness3D2 = invasion_fitness2(X, Y, pars=(alpha, beta))
54
+
55
+ col7, col8 = st.columns(2, gap="large")
56
+ with col7:
57
+ st.plotly_chart(plot_3D_invfitness(zlist, inv_fitness3D2, zm, (-0.2, 0.2)))
58
+ with col8:
59
+ st.plotly_chart(plot_PIP(zlist, invasion_fitness2, (alpha, beta)))