Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sirplus
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
Model registry
Operate
Environments
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
BioCellGen-public
sirplus
Commits
8e877450
Commit
8e877450
authored
4 years ago
by
Christina Azodi
Browse files
Options
Downloads
Plain Diff
fixed merge errors in plot function
parents
e1e1da6c
a8c57298
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/FIN_plot.R
+16
-16
16 additions, 16 deletions
R/FIN_plot.R
man/get_weekly_local.Rd
+12
-2
12 additions, 2 deletions
man/get_weekly_local.Rd
vignettes/sirplus_intro_v2.Rmd
+3
-3
3 additions, 3 deletions
vignettes/sirplus_intro_v2.Rmd
with
31 additions
and
21 deletions
R/FIN_plot.R
+
16
−
16
View file @
8e877450
...
...
@@ -7,7 +7,7 @@
#' @param return_df In effect only when method == "weekly", if TRUE returns
#' also the dataframe used for plotting as well as the ggplot object.
#' @param comp_remove Compartments to remove. Suggest c(s.num, r.num)
#' @param time_lim Number of steps (days) to plot.
#' @param time_lim
it
Number of steps (days) to plot.
#' @param ci T/F to include 95\% confidence intervals in sirplus plot.
#' @param sep_compartments T/F use faceting to show each compartment in a
#' separate plot, only works if plotting a single simulation.
...
...
@@ -38,7 +38,7 @@
#' @export
plot.seiqhrf
<-
function
(
x
,
method
=
NULL
,
comp_remove
=
"none"
,
time_lim
=
90
,
time_lim
it
=
90
,
ci
=
TRUE
,
sep_compartments
=
FALSE
,
trans
=
FALSE
,
...
...
@@ -54,7 +54,7 @@ plot.seiqhrf <- function(x, method = NULL,
if
(
is.null
(
method
)){
plot_sirplus
(
x
,
comp_remove
=
comp_remove
,
time_lim
=
time_lim
,
time_lim
it
=
time_lim
it
,
ci
=
ci
,
sep_compartments
=
sep_compartments
,
trans
=
trans
,
...
...
@@ -75,7 +75,7 @@ plot.seiqhrf <- function(x, method = NULL,
icu_percent
=
icu_percent
,
start_date
=
start_date
,
show_start_date
=
show_start_date
,
time_lim
=
time_lim
,
time_lim
it
=
time_lim
it
,
total_population
=
total_population
)
if
(
return_df
){
return
(
ret
)
...
...
@@ -89,7 +89,7 @@ plot.seiqhrf <- function(x, method = NULL,
#'
#' @param x A list of seiqhrf objects returned from \code{\link{seiqhrf}}.
#' @param comp_remove Compartments to remove. Suggest c(s.num, r.num)
#' @param time_lim Number of steps (days) to plot.
#' @param time_lim
it
Number of steps (days) to plot.
#' @param ci T/F to include 95\% confidence intervals in sirplus plot.
#' @param sep_compartments T/F use faceting to show each compartment in a
#' separate plot, only works if plotting a single simulation.
...
...
@@ -110,7 +110,7 @@ plot.seiqhrf <- function(x, method = NULL,
#' @import ggplot2
#' @export
plot.list
<-
function
(
x
,
comp_remove
=
"none"
,
time_lim
=
90
,
time_lim
it
=
90
,
ci
=
TRUE
,
sep_compartments
=
FALSE
,
trans
=
FALSE
,
...
...
@@ -120,7 +120,7 @@ plot.list <- function(x, comp_remove = "none",
plot_title
=
'SEIQHRF'
,
...
){
plot_sirplus
(
x
,
comp_remove
=
comp_remove
,
time_lim
=
time_lim
,
time_lim
it
=
time_lim
it
,
ci
=
ci
,
sep_compartments
=
sep_compartments
,
trans
=
trans
,
...
...
@@ -143,7 +143,7 @@ plot.list <- function(x, comp_remove = "none",
#' @param x A seiqhrf object (or list of multiple seiqhrf objects) returned
#' from \code{\link{seiqhrf}}.
#' @param comp_remove Compartments to remove. Suggest c(s.num, r.num)
#' @param time_lim Number of steps (days) to plot.
#' @param time_lim
it
Number of steps (days) to plot.
#' @param ci T/F to include 95\% confidence intervals in sirplus plot.
#' @param sep_compartments T/F use faceting to show each compartment in a
#' separate plot, only works if plotting a single simulation.
...
...
@@ -165,7 +165,7 @@ plot.list <- function(x, comp_remove = "none",
#' @import ggplot2
#' @export
plot_sirplus
<-
function
(
x
,
comp_remove
,
time_lim
,
time_lim
it
,
ci
,
sep_compartments
,
trans
,
...
...
@@ -175,7 +175,7 @@ plot_sirplus <- function(x, comp_remove,
plot_title
,
...
){
# Convert from seiqhrf object to dataframe
plot_df
<-
format_sims
(
x
,
time_lim
=
time_lim
,
start_date
=
start_date
)
plot_df
<-
format_sims
(
x
,
time_lim
it
=
time_lim
it
,
start_date
=
start_date
)
reo_exp
<-
function
(
x
)
{
factor
(
x
,
levels
=
unique
(
plot_df
$
experiment
))}
# Get Confidence Intervals
...
...
@@ -201,7 +201,7 @@ plot_sirplus <- function(x, comp_remove,
# Filter compartments
comp_plot
<-
setdiff
(
comps
,
comp_remove
)
plot_df
<-
plot_df
%>%
filter
(
compartment
%in%
c
(
comp_plot
))
%>%
filter
(
time
<=
time_lim
)
filter
(
time
<=
time_lim
it
)
# Plot with options
p
<-
ggplot
(
plot_df
,
aes
(
x
=
Date
,
y
=
count
,
colour
=
compartment
,
...
...
@@ -335,7 +335,7 @@ get_weekly_local <- function(sim,
icu_percent
=
icu_percent
,
start_date
=
start_date
,
show_start_date
=
show_start_date
,
time_lim
=
time_lim
,
time_lim
it
=
time_lim
it
,
total_population
=
total_population
){
# Get h.num and 95% quantile CIs
...
...
@@ -344,7 +344,7 @@ get_weekly_local <- function(sim,
hosp
<-
data.frame
(
'h.num'
=
sim_mean
$
h.num
,
'ci5'
=
ci_info
$
qntCI.1
,
'ci95'
=
ci_info
$
qntCI.2
)
hosp
[
is.na
(
hosp
)]
<-
0
hosp
<-
hosp
[
1
:
time_lim
,
]
hosp
<-
hosp
[
1
:
time_lim
it
,
]
hosp
$
date
<-
start_date
+
as.numeric
(
row.names
(
hosp
))
if
(
class
(
show_start_date
)
==
"Date"
){
...
...
@@ -395,13 +395,13 @@ get_weekly_local <- function(sim,
#' Format seiqhrf objects into dataframe for ggplot
#'
#' @param x An seiqhrf object returned from function \code{\link{seiqhrf}}.
#' @param time_lim Number of steps (days) to plot.
#' @param time_lim
it
Number of steps (days) to plot.
#' @param start_date Date for day 0. Default: ymd("2020-03-21"),
#'
#' @return dataframe
#'
#' @export
format_sims
<-
function
(
x
,
time_lim
,
start_date
){
format_sims
<-
function
(
x
,
time_lim
it
,
start_date
){
# Merge models to plot together
if
(
class
(
x
)
==
"seiqhrf"
){
...
...
@@ -424,7 +424,7 @@ format_sims <- function(x, time_lim, start_date){
}
}
plot_df
<-
plot_df
%>%
filter
(
time
<=
time_lim
)
%>%
plot_df
<-
plot_df
%>%
filter
(
time
<=
time_lim
it
)
%>%
pivot_longer
(
-
c
(
time
,
experiment
),
names_to
=
"compartment"
,
values_to
=
"count"
)
%>%
...
...
This diff is collapsed.
Click to expand it.
man/get_weekly_local.Rd
+
12
−
2
View file @
8e877450
...
...
@@ -6,12 +6,20 @@
\usage{
get_weekly_local(
sim,
<<<<<<< HEAD
market.share = market.share,
icu_percent = icu_percent,
start_date = start_date,
show_start_date = show_start_date,
time_lim = time_lim,
total_population = total_population
=======
market.share,
icu_percent,
start_date,
time_lim,
total_population
>>>>>>> a8c57298caf1bdc80ae8ae8f15fc65d70d4b2b86
)
}
\arguments{
...
...
@@ -27,14 +35,16 @@ ICU among the ones that need hospitalization}
plot week numbers, if provided will plot the first day (Sunday) of the
week.}
<<<<<<< HEAD
\item{show_start_date}{First date to show in plots. Use ymd format. If FALSE,
shows from step 1. Default: FALSE}
=======
\item{time_lim}{Number of days to include. Default = 90.}
>>>>>>> a8c57298caf1bdc80ae8ae8f15fc65d70d4b2b86
\item{total_population}{True population size, needed only if simulation size
is smaller than the true population size due to computational cost
etc.}
\item{time_limit}{Number of days to include. Default = 90.}
}
\value{
\itemize{
...
...
This diff is collapsed.
Click to expand it.
vignettes/sirplus_intro_v2.Rmd
+
3
−
3
View file @
8e877450
...
...
@@ -41,12 +41,12 @@ See Tim Churches's [blog post](https://timchurches.github.io/blog/posts/2020-03-

| trasitions | Description | Parameters (with default values) |
| tras
n
itions | Description | Parameters (with default values) |
|-------------|----------------| ------------------------------------------------------------------|
| **inf** | Infection due to contact | `act.rate.*` and `inf.prob.*`, where `*` = `i`, `e`, `q` |
| **prog** | Progress from asymptomatic to symptomatic | `prog.rand = FALSE`, `prog.rate`, `prog.dist.scale = 5`, `prog.dist.shape = 1.5` |
| **quar** | From infectious to quar
i
tine | `quar.rand = TRUE`, `quar.rate = 1/30` |
| **hosp** | From infected (both before and during quar
i
ntine) to require hospitalisation | `quar.rand = TRUE`, `quar.rate = 1/30` |
| **quar** | From infectious to quar
an
tine | `quar.rand = TRUE`, `quar.rate = 1/30` |
| **hosp** | From infected (both before and during quar
a
ntine) to require hospitalisation | `quar.rand = TRUE`, `quar.rate = 1/30` |
| **rec** | From infected to recovered without hospitalization | `rec.rand = FALSE`, `prog.dist.scale = 35`, `prog.dist.shape = 1.5` |
| **arec** | Exposed individuals recovered before symptomatic | `arec.rand = TRUE`, `arec.rate = 0.05` |
| **disch** | recovery after hospitalization | `disch.rand = TRUE`, `disch.rate = 1/15` |
...
...
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