Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FÖT - Matlab kódok
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Schleier Anna Réka
FÖT - Matlab kódok
Commits
59211a47
Commit
59211a47
authored
1 month ago
by
Schleier Anna Réka
Browse files
Options
Downloads
Patches
Plain Diff
Add new file
parent
016f032b
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lotka_volterra_kiterjesztett.m
+233
-0
233 additions, 0 deletions
lotka_volterra_kiterjesztett.m
with
233 additions
and
0 deletions
lotka_volterra_kiterjesztett.m
0 → 100644
+
233
−
0
View file @
59211a47
% --- Kiterjesztett Lotka-Volterra modell implementációja ---
% Paraméterek
r
=
[
0.8
,
0.4
,
0.5
,
0.3
,
0.2
,
0.25
]
'
;
K
=
[
120
,
80
,
70
,
60
,
50
,
40
]
'
;
x0
=
[
50
,
30
,
20
,
25
,
15
,
12
]
'
;
A
=
[
1
,
-
0.2
,
-
0.4
,
+
0.2
,
-
0.1
,
-
0.2
;
-
0.1
,
1
,
0.0
,
0.0
,
0.0
,
0.0
;
-
0.5
,
0.0
,
1
,
-
0.1
,
0.0
,
0.0
;
+
0.2
,
0.0
,
-
0.2
,
1
,
+
0.1
,
0.0
;
-
0.1
,
0.0
,
0.0
,
+
0.1
,
1
,
+
0.1
;
-
0.2
,
0.0
,
0.0
,
0.0
,
+
0.1
,
1
];
antibiotics
=
{
'Tobramycin'
};
dose_times
=
20
:
24
:
212
;
D
=
repmat
(
10.0
,
size
(
dose_times
));
k_elim
=
0.1
;
% Eliminációs ráta (1/idő)
% Antibiotikum-rezisztencia mátrix (6 baktérium × 6 antibiotikum példa)
R_ij
=
zeros
(
6
,
6
);
% kezdő rezisztenciaszintek (pl. mind nulla)
cf0
=
0.1
;
% Kezdeti fitnesz-költség
alpha
=
0.3
;
% Rezisztenciafüggő költségnövekedés
% Antagonizmus mátrix (értékek 0 és 1 között, ahol 1 = teljes gátlás)
Antag
=
zeros
(
6
,
6
);
Antag
(
6
,
5
)
=
0.3
;
% Penicillin (idx=6) csökkenti Tetracycline (idx=5) hatását 30%-kal
Antag
(
5
,
6
)
=
0.5
;
% Tetracycline (idx=5) csökkenti Penicillin (idx=6) hatását 50%-kal
x0_R
=
reshape
(
R_ij
,
[],
1
);
x0_all
=
[
x0
;
x0_R
];
[
t
,
X
]
=
ode45
(
@
(
t
,
x
)
extended_lv_antibiotic_model
(
t
,
x
,
r
,
K
,
A
,
antibiotics
,
dose_times
,
D
,
k_elim
,
cf0
,
alpha
,
Antag
),
[
0
200
],
x0_all
);
% Ábrázolás
figure
;
hold
on
;
colors
=
lines
(
6
);
for
i
=
1
:
6
plot
(
t
,
X
(:,
i
),
'LineWidth'
,
2
,
'Color'
,
colors
(
i
,
:));
end
legend
({
'Pseudomonas'
,
'Staphylococcus'
,
'Burkholderia'
,
...
'Stenotrophomonas'
,
'Prevotella'
,
'Streptococcus'
},
'Location'
,
'best'
);
xlabel
(
'Idő'
);
ylabel
(
'Populációméret'
);
title
([
'Lotka-Volterra modell antibiotikum hatással: '
antibiotics
],
'FontSize'
,
14
);
grid
on
;
figure
;
colors
=
lines
(
6
);
% Színek definiálása
epsilon
=
1e-9
;
% Alap skála és biztonsági érték
scale_factor
=
1e7
;
% Biológiailag értelmezett CFU/mL
% --- 1. Alap log skálázott (biológiai valóság) ábra ---
subplot
(
1
,
2
,
1
);
hold
on
;
for
i
=
1
:
6
CFU
=
X
(:,
i
)
*
scale_factor
;
CFU
(
CFU
<
epsilon
)
=
epsilon
;
logCFU
=
log10
(
CFU
);
plot
(
t
,
logCFU
,
'LineWidth'
,
2
,
'Color'
,
colors
(
i
,
:));
end
title
(
'log_{10}(CFU/mL) – Teljes biológiai tartomány (Lotka-Volterra modell)'
);
xlabel
(
'Idő (óra)'
);
ylabel
(
'log_{10}(CFU/mL)'
);
legend
({
'Pseudomonas'
,
'Staphylococcus'
,
'Burkholderia'
,
...
'Stenotrophomonas'
,
'Prevotella'
,
'Streptococcus'
},
'Location'
,
'best'
);
ylim
([
0
10
]);
grid
on
;
subplot
(
1
,
2
,
2
);
hold
on
;
for
i
=
1
:
6
CFU
=
X
(:,
i
)
*
scale_factor
;
CFU
(
CFU
<
epsilon
)
=
epsilon
;
logCFU
=
log10
(
CFU
);
plot
(
t
,
logCFU
,
'LineWidth'
,
2
,
'Color'
,
colors
(
i
,
:));
end
title
(
'log_{10}(CFU/mL) – Releváns klinikai tartomány kiemelve'
);
xlabel
(
'Idő (óra)'
);
ylabel
(
'log_{10}(CFU/mL)'
);
legend
({
'Pseudomonas'
,
'Staphylococcus'
,
'Burkholderia'
,
...
'Stenotrophomonas'
,
'Prevotella'
,
'Streptococcus'
},
'Location'
,
'best'
);
ylim
([
6
10
]);
grid
on
;
% Modellfüggvény
function
dxdt
=
extended_lv_antibiotic_model
(
t
,
x
,
r
,
K
,
A
,
antibiotics
,
dose_times
,
D
,
k_elim
,
cf0
,
alpha
,
Antag
)
ab_map
=
containers
.
Map
({
'Ampicillin'
,
'Tobramycin'
,
'Ceftazidime'
,
'Azithromycin'
,
'Tetracycline'
,
'Penicillin'
},
1
:
6
);
n_species
=
length
(
r
);
x_species
=
x
(
1
:
n_species
);
R_vec
=
x
(
n_species
+
1
:
end
);
R_ij
=
reshape
(
R_vec
,
n_species
,
[]);
r_mod
=
r
;
K_mod
=
K
;
%% Farmakokinetika
C_total
=
zeros
(
length
(
antibiotics
),
1
);
for
j
=
1
:
length
(
antibiotics
)
Cj
=
0
;
for
k
=
1
:
length
(
dose_times
)
if
t
>=
dose_times
(
k
)
Cj
=
Cj
+
D
(
k
)
*
exp
(
-
k_elim
*
(
t
-
dose_times
(
k
)));
end
end
C_total
(
j
)
=
Cj
;
end
%% Rezisztencia növekedés
res_increase
=
0.002
;
res_decrease
=
0.0005
;
mutation_rate
=
1e-4
;
% Spontán mutáció
HGT_rate
=
5e-6
/
sum
(
x_species
+
1
);
% Plazmid-átadás valószínűsége
dR_dt
=
zeros
(
size
(
R_ij
));
for
i
=
1
:
n_species
for
j
=
1
:
length
(
antibiotics
)
idx_ab
=
ab_map
(
antibiotics
{
j
});
if
C_total
(
j
)
>
0.1
dR_dt
(
i
,
idx_ab
)
=
res_increase
;
else
dR_dt
(
i
,
idx_ab
)
=
-
res_decrease
;
end
% Mutáció – csak ha nincs teljes rezisztencia
if
R_ij
(
i
,
idx_ab
)
<
1.0
dR_dt
(
i
,
idx_ab
)
=
dR_dt
(
i
,
idx_ab
)
+
mutation_rate
*
(
1
-
R_ij
(
i
,
idx_ab
));
end
% Horizontális géntranszfer (plazmidból)
for
donor
=
1
:
n_species
if
donor
~=
i
dR_dt
(
i
,
idx_ab
)
=
dR_dt
(
i
,
idx_ab
)
+
HGT_rate
*
R_ij
(
donor
,
idx_ab
)
*
x_species
(
donor
);
end
end
end
end
%% Fitnesz-költség
for
i
=
1
:
n_species
for
j
=
1
:
length
(
antibiotics
)
cf
=
cf0
+
alpha
*
R_ij
(
i
,
j
);
r_mod
(
i
)
=
r_mod
(
i
)
*
(
1
-
cf
);
end
end
% K-fitnesz költség integrálása
for
i
=
1
:
n_species
for
j
=
1
:
length
(
antibiotics
)
cost
=
cf0
+
alpha
*
R_ij
(
i
,
j
);
K_mod
(
i
)
=
K_mod
(
i
)
*
(
1
-
0.5
*
cost
);
% vagy saját súlyozással
end
end
% Stabilitási korlát
r_mod
=
max
(
r_mod
,
1e-6
);
K_mod
=
max
(
K_mod
,
1e-6
);
%% Antibiotikum hatás és antagonizmus
for
j
=
1
:
length
(
antibiotics
)
name
=
antibiotics
{
j
};
idx_j
=
ab_map
(
name
);
Cj
=
C_total
(
j
);
E_j
=
(
Cj
^
2
)
/
(
Cj
^
2
+
1
);
for
k
=
1
:
length
(
antibiotics
)
if
j
~=
k
idx_k
=
ab_map
(
antibiotics
{
k
});
E_j
=
E_j
*
(
1
-
Antag
(
idx_j
,
idx_k
));
end
end
switch
name
case
'Ampicillin'
sensitivity2
=
exp
(
-
5
*
R_ij
(
2
,
idx_j
));
sensitivity6
=
exp
(
-
5
*
R_ij
(
6
,
idx_j
));
r_mod
(
2
)
=
r_mod
(
2
)
*
(
1
-
1.2
*
E_j
*
sensitivity2
);
K_mod
(
2
)
=
K_mod
(
2
)
*
(
1
-
1.2
*
E_j
*
sensitivity2
);
r_mod
(
6
)
=
r_mod
(
6
)
*
(
1
-
1.6
*
E_j
*
sensitivity6
);
K_mod
(
6
)
=
K_mod
(
6
)
*
(
1
-
1.6
*
E_j
*
sensitivity6
);
case
'Tobramycin'
sensitivity1
=
exp
(
-
5
*
R_ij
(
1
,
idx_j
));
r_mod
(
1
)
=
r_mod
(
1
)
*
(
1
-
1.2
*
E_j
*
sensitivity1
);
K_mod
(
1
)
=
K_mod
(
1
)
*
(
1
-
1.2
*
E_j
*
sensitivity1
);
case
'Ceftazidime'
sensitivity1
=
exp
(
-
5
*
R_ij
(
1
,
idx_j
));
sensitivity5
=
exp
(
-
5
*
R_ij
(
5
,
idx_j
));
r_mod
(
1
)
=
r_mod
(
1
)
*
(
1
-
0.8
*
E_j
*
sensitivity1
);
K_mod
(
1
)
=
K_mod
(
1
)
*
(
1
-
0.99
*
E_j
*
sensitivity1
);
r_mod
(
5
)
=
r_mod
(
5
)
*
(
1
-
0.4
*
E_j
*
sensitivity5
);
case
'Azithromycin'
sensitivity2
=
exp
(
-
5
*
R_ij
(
2
,
idx_j
));
sensitivity6
=
exp
(
-
5
*
R_ij
(
6
,
idx_j
));
r_mod
(
2
)
=
r_mod
(
2
)
*
(
1
-
0.7
*
E_j
*
sensitivity2
);
K_mod
(
2
)
=
K_mod
(
2
)
*
(
1
-
0.5
*
E_j
*
sensitivity2
);
r_mod
(
6
)
=
r_mod
(
6
)
*
(
1
-
0.8
*
E_j
*
sensitivity6
);
K_mod
(
6
)
=
K_mod
(
6
)
*
(
1
-
0.2
*
E_j
*
sensitivity6
);
case
'Tetracycline'
sensitivity3
=
exp
(
-
5
*
R_ij
(
3
,
idx_j
));
r_mod
(
3
)
=
r_mod
(
3
)
*
(
1
-
0.5
*
E_j
*
sensitivity3
);
K_mod
(
3
)
=
K_mod
(
3
)
*
(
1
-
0.5
*
E_j
*
sensitivity3
);
case
'Penicillin'
sensitivity2
=
exp
(
-
5
*
R_ij
(
2
,
idx_j
));
r_mod
(
2
)
=
r_mod
(
2
)
*
(
1
-
0.3
*
E_j
*
sensitivity2
);
K_mod
(
2
)
=
K_mod
(
2
)
*
(
1
-
0.2
*
E_j
*
sensitivity2
);
end
end
%% 5. Növekedési ráták és kompetíció
dx_species
=
r_mod
.*
x_species
.*
(
1
-
(
A
*
x_species
)
.
/
K_mod
);
death_threshold
=
1
;
% halálozási küszöb
for
i
=
1
:
n_species
if
x_species
(
i
)
<
death_threshold
dx_species
(
i
)
=
0
;
r_mod
(
i
)
=
0
;
end
end
%% Immunválasz
I
=
0.01
;
% erőssége (állandó)
immune_clearance
=
I
*
x_species
;
% csökkentjük a populációkat ezzel is:
dx_species
=
dx_species
-
immune_clearance
;
dR_vec
=
reshape
(
dR_dt
,
[],
1
);
dxdt
=
[
dx_species
;
dR_vec
];
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment