Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .Rproj.user/C3EAF566/cpp-definition-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
5 changes: 5 additions & 0 deletions .Rproj.user/C3EAF566/pcs/debug-breakpoints.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"debugBreakpointsState": {
"breakpoints": []
}
}
9 changes: 9 additions & 0 deletions .Rproj.user/C3EAF566/pcs/files-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"sortOrder": [
{
"columnIndex": 2,
"ascending": true
}
],
"path": "~/Documents/BSC/Fundings/MSCA/Development/Analysis/epidesc"
}
7 changes: 7 additions & 0 deletions .Rproj.user/C3EAF566/pcs/packages-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"installOptions": {
"installFromRepository": true,
"libraryPath": "/home/rmartins/R/x86_64-pc-linux-gnu-library/4.6",
"installDependencies": true
}
}
3 changes: 3 additions & 0 deletions .Rproj.user/C3EAF566/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"activeTab": 1
}
14 changes: 14 additions & 0 deletions .Rproj.user/C3EAF566/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"left": {
"splitterpos": 198,
"topwindowstate": "NORMAL",
"panelheight": 596,
"windowheight": 634
},
"right": {
"splitterpos": 380,
"topwindowstate": "NORMAL",
"panelheight": 596,
"windowheight": 634
}
}
5 changes: 5 additions & 0 deletions .Rproj.user/C3EAF566/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"TabSet1": 4,
"TabSet2": 0,
"TabZoom": {}
}
8 changes: 8 additions & 0 deletions .Rproj.user/C3EAF566/persistent-state
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build-last-errors="[]"
build-last-errors-base-dir="~/Documents/BSC/Fundings/MSCA/Development/Analysis/epidesc/"
build-last-outputs="[{\"type\":0,\"output\":\"==> R CMD INSTALL --preclean --no-multiarch --with-keep.source epidesc\\n\\n\"},{\"type\":1,\"output\":\"* installing to library ‘/home/rmartins/R/x86_64-pc-linux-gnu-library/4.6/_build’\\n\"},{\"type\":1,\"output\":\"* installing *source* package ‘epidesc’ ...\\n\"},{\"type\":1,\"output\":\"** this is package ‘epidesc’ version ‘0.1.0’\\n\"},{\"type\":1,\"output\":\"** using staged installation\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** R\\n\"},{\"type\":1,\"output\":\"** data\\n\"},{\"type\":1,\"output\":\"*** moving datasets to lazyload DB\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** inst\\n\"},{\"type\":1,\"output\":\"** byte-compile and prepare package for lazy loading\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** help\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** installing help indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** building package indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** installing vignettes\\n\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from temporary location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from final location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\"},{\"type\":1,\"output\":\"* DONE (epidesc)\\n\"},{\"type\":1,\"output\":\"\"}]"
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
imageDirtyState="1"
saveActionState="0"
5 changes: 5 additions & 0 deletions .Rproj.user/C3EAF566/rmd-outputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@





1 change: 1 addition & 0 deletions .Rproj.user/C3EAF566/saved_source_markers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"active_set":"","sets":[]}
8 changes: 8 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/1BE58D88
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"source_window_id": "",
"Source": "Source",
"last_setup_crc32": "9f14958afd5dcac3",
"cursorPosition": "104,0",
"scrollLine": "0",
"chunk_output_type": "console"
}
4 changes: 4 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/1DBC1031
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"source_window_id": "",
"Source": "Source"
}
4 changes: 4 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/51583C41
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"source_window_id": "",
"Source": "Source"
}
4 changes: 4 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/66776074
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"source_window_id": "",
"Source": "Source"
}
6 changes: 6 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/784AC70C
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "70,26",
"scrollLine": "56"
}
11 changes: 11 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/90C6E5A4
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"source_window_id": "",
"Source": "Source",
"rmdVisualMode": "true",
"rmdVisualCollapsedChunks": "",
"rmdVisualModeLocation": "1693:729.1428833007812",
"rmdVisualWrapConfigured": "true",
"docOutlineVisible": "0",
"cursorPosition": "0,0",
"scrollLine": "0"
}
4 changes: 4 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/A656A517
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"source_window_id": "",
"Source": "Source"
}
6 changes: 6 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/D2D3A6FF
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "23,15",
"scrollLine": "17"
}
6 changes: 6 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/FB2C4294
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"source_window_id": "",
"Source": "Source",
"cursorPosition": "8,25",
"scrollLine": "1"
}
9 changes: 9 additions & 0 deletions .Rproj.user/C3EAF566/sources/prop/INDEX
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2FLICENSE.md="784AC70C"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2FNEWS.md="A656A517"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2FR%2Fdesc-cases.R="FB2C4294"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2FR%2Fdesc-peak.R="66776074"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2FR%2Fdesc_list.R="D2D3A6FF"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2FREADME.md="90C6E5A4"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2Fman%2Fdesc_Cmed.Rd="51583C41"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2Ftests%2Ftestthat.R="1DBC1031"
~%2FDocuments%2FBSC%2FFundings%2FMSCA%2FDevelopment%2FAnalysis%2Fepidesc%2Fvignettes%2Fepidesc.Rmd="1BE58D88"
20 changes: 20 additions & 0 deletions .Rproj.user/C3EAF566/sources/session-9f14958a/073730A4-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/desc-cases.R
\name{desc_Cmed}
\alias{desc_Cmed}
\title{Cmed}
\usage{
desc_Cmed(df, x)
}
\arguments{
\item{df}{A data.frame consisting of 52 rows (1 year) for a single spatial
unit with columns 'time' (epiyearweek), 'cases', 'epiweek' and 'epiyear'.}

\item{x}{Number of cases.}
}
\value{
The computed Cmed epidescriptor.
}
\description{
Median duration in consecutive weeks with at least 'x' cases.
}
83 changes: 83 additions & 0 deletions .Rproj.user/C3EAF566/sources/session-9f14958a/59A30531-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# epidesc <img src="inst/figures/logo_BSC.png" align="right" width="16%"/>

<!-- badges: start -->

[![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) <!-- [![R-CMD-check](https://github.com/BSC-ES/epidesc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/BSC-ES/epidesc/actions/workflows/R-CMD-check.yaml) -->

<!-- badges: end -->

## Overview

<img src="inst/figures/epidesc.png" align="right" width="20%"/>

The R package **epidesc** provides the tools to easily compute a series of epidemiological indicators to characterise different transmission profiles of infectious diseases. The work is based on the publication How heterogeneous is the dengue transmission profile in Brazil? A study in six Brazilian states (<https://doi.org/10.1371/journal.pntd.0010746>) published in PLoS Neglected Tropical Diseases by Iasmim Ferreira de Almeida, Raquel Martins Lana and Cláudia Torres Codeço in 2022.

The **epidesc** pipeline to compute the indicators is the following: \* Formatting dates in *epiyearweek* format. \* Choosing descriptors and its parameters from the catalogue. \* Compute descriptors.

In order to work, the data used to compute the descriptors needs to have a few simple requirements: \* The input data has to be a data.frame with the cases and spatiotemporal identifiers. \* The data needs to be weekly with dates in Date format. \* If an incidence descriptor is required, the population at risk also needs to be provided.

To find out more, please have a look at the package vignette.

## Included descriptors

The current version of the package includes the following descriptors:

``` r
library("epidesc")
knitr::kable(desc_list())
```

| class | fun | description | param1 | param2 |
|:---|:---|:---|:---|:---|
| Peak | Ap | Maximum cases peak | | |
| Peak | Tp | Week where the maximum peak occurred | | |
| Period with cases | Cnf | Frequency of periods of consecutive 'n' weeks or longer with at least 'x' cases | n | x |
| Period with cases | Cmax | Maximum duration in consecutive weeks with at least 'x' cases | x | |
| Period with cases | Cmed | Median duration in consecutive weeks with at least 'x' cases | x | |
| Period with cases | Isof | Number of weeks with isolated cases | | |
| Period with cases | p | Proportion of weeks with at least 'x' cases | x | |
| Period without cases | Cwf | Frequency of periods of consecutive weeks with at least 'n' weeks without cases. | n | |
| Period without cases | Cwmax | Maximum duration in consecutive weeks without cases | | |
| Period without cases | Cwmed | Median duration in consecutive weeks without cases | | |
| Incidence | Inc | Annual incidence per 'p' persons | p | |

## Contributions

We are very interested in keep expanding **epidesc** with new descriptors and we are open to contributions. If would like to contribute, please open an issue with your idea or get in touch with Raquel Martins Lana ([raquel.lana\@bsc.es](mailto:raquel.lana@bsc.es){.email}, [raquelmlana\@gmail.com](mailto:raquelmlana@gmail.com){.email}) or Carles Milà ([carles.milagarcia\@bsc.es](mailto:carles.milagarcia@bsc.es){.email}) to discuss its inclusion.

## Installation

`epidesc` is still in development and not on CRAN. You can install the development version of epidesc as follows:

``` r
pak::pak("https://github.com/BSC-ES/epidesc.git")
```

## Package authors

[**Raquel Martins Lana, PhD**](https://www.bsc.es/martins-lana-raquel) <a href="https://orcid.org/0000-0002-7573-1364" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Barcelona Supercomputing Center

[**Carles Milà, PhD**](https://www.bsc.es/mila-garcia-carles) <a href="https://orcid.org/0000-0003-0470-0760" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Barcelona Supercomputing Center

**Iasmin Ferreira de Almeida, PhD** <a href="https://orcid.org/0000-0002-9334-4093" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Getulio Vargas Foundation (FGV)

**Claudia Torres Codeço, PhD** <a href="https://orcid.org/0000-0003-1174-178X" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Oswaldo Cruz Foundation (Fiocruz)

[**Daniela Lührsen, MSc**](https://www.bsc.es/luhrsen-daniela-sofie) <a href="https://orcid.org/0009-0002-6340-5964" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Barcelona Supercomputing Center

**Diego Ricardo Xavier Silva, PhD** <a href="https://orcid.org/0000-0001-5259-7732" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Oswaldo Cruz Foundation (Fiocruz)

**Christovam Barcellos, PhD** <a href="https://orcid.org/0000-0002-1161-2753" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Oswaldo Cruz Foundation (Fiocruz)

**Raphael Saldanha, PhD** <a href="https://orcid.org/0000-0003-0652-8466" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Oswaldo Cruz Foundation (Fiocruz)

[**Rachel Lowe, PhD**](https://www.bsc.es/lowe-rachel) <a href="https://orcid.org/0000-0003-3939-7343" style="margin-left: 15px;"><img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" alt="ORCID" style="width: 16px; height: 16px;"/></a>\
Barcelona Supercomputing Center
99 changes: 99 additions & 0 deletions .Rproj.user/C3EAF566/sources/session-9f14958a/64442212-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#' Cnf
#'
#' @description Frequency of periods of consecutive 'n' weeks or longer with at
#' least 'x' cases.
#'
#' @param df A data.frame consisting of 52 rows (1 year) for a single spatial
#' unit with columns 'time' (epiyearweek), 'cases', 'epiweek' and 'epiyear'.
#' @param n Number of consecutive weeks.
#' @param x Number of cases.
#'
#' @returns The computed Cnf epidescriptor.
#' @export
desc_Cnf <- function(df, n, x) {
res <- nseq::trle_cond(df$cases, a_op = "gte", a = n, b_op = "gte", b = x)

return(res)
}

#' Cmax
#'
#' @description Maximum duration in consecutive weeks with at least 'x' cases.
#'
#' @param df A data.frame consisting of 52 rows (1 year) for a single spatial
#' unit with columns 'time' (epiyearweek), 'cases', 'epiweek' and 'epiyear'.
#' @param x Number of cases.
#'
#' @returns The computed Cmax epidescriptor.
#' @export
desc_Cmax <- function(df, x) {
res <- nseq::trle_cond_stat(df$cases, b_op = "gte", b = x, stat = "max")

# If no sequences are found
if (is.na(res)) {
res <- 0
}

return(res)
}

#' Cmed
#'
#' @description Median duration in consecutive weeks with at least 'x' cases.
#'
#' @param df A data.frame consisting of 52 rows (1 year) for a single spatial
#' unit with columns 'time' (epiyearweek), 'cases', 'epiweek' and 'epiyear'.
#' @param x Number of cases.
#'
#' @returns The computed Cmed epidescriptor.
#' @export
desc_Cmed <- function(df, x) {
res <- nseq::trle_cond_stat(df$cases, b_op = "gte", b = x, stat = "median")

# If no sequences are found
if (is.na(res)) {
res <- 0
}

return(res)
}

#' Isof
#'
#' @description Number of weeks with isolated cases, i.e. weeks with 0 cases
#' both in the previous and following week.
#'
#' @param df A data.frame consisting of 52 rows (1 year) for a single spatial
#' unit with columns 'time' (epiyearweek), 'cases', 'epiweek' and 'epiyear'.
#'
#' @returns The computed Isof epidescriptor.
#' @export
desc_Isof <- function(df) {
res <- nseq::trle_cond(
df$cases,
a_op = "e",
a = 1,
b_op = "gt",
b = 0,
isolated = TRUE
)

return(res)
}

#' p
#'
#' @description Proportion fo weeks with at least 'x' cases.
#'
#' @param df A data.frame consisting of 52 rows (1 year) for a single spatial
#' unit with columns 'time' (epiyearweek), 'cases', 'epiweek' and 'epiyear'.
#' @param x Number of cases.
#'
#' @returns The computed p epidescriptor.
#' @export
desc_p <- function(df, x) {
res <- df$cases >= x
res <- sum(res) / length(res)

return(res)
}
28 changes: 28 additions & 0 deletions .Rproj.user/C3EAF566/sources/session-9f14958a/9476C86A
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"id": "9476C86A",
"path": "~/Documents/BSC/Fundings/MSCA/Development/Analysis/epidesc/vignettes/epidesc.Rmd",
"project_path": "vignettes/epidesc.Rmd",
"type": "r_markdown",
"hash": "0",
"contents": "",
"dirty": false,
"created": 1784745328559.0,
"source_on_save": false,
"relative_order": 2,
"properties": {
"source_window_id": "",
"Source": "Source",
"last_setup_crc32": "9f14958afd5dcac3",
"cursorPosition": "104,0",
"scrollLine": "0",
"chunk_output_type": "console"
},
"folds": "",
"lastKnownWriteTime": 1784745372,
"encoding": "UTF-8",
"collab_server": "",
"source_window": "",
"last_content_update": 1784745372,
"read_only": false,
"read_only_alternatives": []
}
Loading