Skip to content

Commit

Permalink
Fixed merge conflicts after pull from main
Browse files Browse the repository at this point in the history
Merge commit '61343b054d2a190eb1e20de6bcb1265c10d2ac34'

#Conflicts:
#	.Rbuildignore
#	DESCRIPTION
  • Loading branch information
Anders Aasted Isaksen authored and Anders Aasted Isaksen committed Feb 17, 2024
2 parents 3222af8 + 61343b0 commit 387454a
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 91 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
^\.Rproj\.user$
^LICENSE\.md$
^data-raw$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
29 changes: 29 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
79 changes: 79 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
issue_comment:
types: [created]

name: Commands

jobs:
document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: pr-document

- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

style:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
name: style
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v2

- name: Install dependencies
run: install.packages("styler")
shell: Rscript {0}

- name: Style
run: styler::style_pkg()
shell: Rscript {0}

- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.Rhistory
.RData
.Ruserdata
inst/doc
14 changes: 9 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ BugReports: https://github.com/steno-aarhus/osdc/issues
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Imports:
data.table,
fs,
haven,
here,
lifecycle,
lubridate,
purrr
Suggests:
codeCollection,
DiagrammeR
furrr
Suggests:
codeCollection
furrr,
DiagrammeR,
knitr,
rmarkdown
VignetteBuilder: knitr
81 changes: 0 additions & 81 deletions R/master.R
Original file line number Diff line number Diff line change
@@ -1,81 +0,0 @@

# 0: Master Script for Creating Diabetes Population --------------------------

# Load dependencies:
library(haven)
library(data.table)
library(lubridate)
library(here)
library(fs)

# 1: Run Import Script to Convert Raw Files from SAS Format --------

# Set path to root of raw files folder, e.g.:
foreign_folder = 'E:/ProjektDB/ALMAU/Rawdata/707517/'

# Set names of files to be imported. Can be split across multiple virtual machines for saving time.
# Executing everything on one machine works fine too.

# To run in 3 simultaneous chuncks on 3 virtual machines, run each of the following sections of 3 lines on a different machine:
sas_files_1 <- "^bef|^lpr_diag|^uaf_diag|^lpr_adm|^uaf_adm|.*sksube201[4-8]"
sas_file_list <- list.files(path = foreign_folder, pattern = sas_files_1, recursive = T)
source(here("R/import.R"))

#
sas_files_2 <- "^sysi|^sssy200[6-9]|^sssy20[1-9]"
sas_file_list <- list.files(path = foreign_folder, pattern = sas_files_2, recursive = T)
source(here("R/import.R"))

#
sas_files_3 <- "^lab|^lmdb"

sas_files_3 <- "^udda|^akm|^faik"
sas_file_list <- list.files(path = foreign_folder, pattern = sas_files_3, recursive = T)
source(here("R/import.R"))

# Set path to root of secondary raw files folder, e.g.:
foreign_folder = 'E:/ProjektDB/ALMAU/Rawdata/707517/Eksterne data/2021-06-09 fra SDS/'
sas_files_3 <- "^lab_forsker"
sas_file_list <- list.files(path = foreign_folder, pattern = sas_files_3, recursive = T)
source(here("R/import.R"))


# Note exclusion of either of sssy and sysi in 2005, where they potentially overlap.
# Note also that we import medication prescriptions from all years, even though we only filter and use those from 1997 onwards.


# 2: Run Filter Script to Create Source Data ---------------------------------

source(here("R/filter.R"))



# 3: Run Population Script to Generate Diabetes Population -------------------
source(here("R/population.R"))


# 4: Draw a Live Sample of the Diabetes Population at a Point in Time--------------------
source(here("R/draw_dm_sample.R"))

# Import the entire diabetes population through time:
dm_population <- readRDS(here('data/output/dm_population.rds'))
# Select which year to draw the population:

dm_2019 <- draw_dm_sample(sample_year = 2019)
saveRDS(dm_2019, here("data/output/dm_population_2019.rds"))

rm(dm_population, dm_2018)

# And draw the corresponding diagrams:
source(here("R/flowcharts.R"))
load(here("data", "source", "flowchart_counts.Rdata"))
draw_inclusion()
draw_type(sample_year = 2019)


# 5: Compress Imported Raw Data to Save Space -----------------------------

compress = TRUE
# Can be set to FALSE if wanting to uncompress the raw data at a later point

source(here("R/compress.R"))
7 changes: 7 additions & 0 deletions R/osdc-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom lifecycle deprecated
## usethis namespace: end
NULL
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

<!-- badges: start -->

[![R-CMD-check](https://github.com/steno-aarhus/osdc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/steno-aarhus/osdc/actions/workflows/R-CMD-check.yaml)

<!-- badges: end -->

The goal of *osdc* is to provide an algorithm for classifying diabetes
within the Danish registers that is flexible and convenient to use, and validated in terms of accuracy.
While there are a few algorithms used throughout Denmark for Danish register research, they are usually textual
descriptions of how to do it, rather than code-based descriptions (e.g. the [Register of Selected Chronic Diseases](https://www.esundhed.dk/-/media/Files/Publikationer/Emner/Operationer-og-diagnoser/Udvalgte-kroniske-sygdomme-svaere-psykiske-lidelser/Algoritmer-for-Udvalgte-Kroniske-Sygdomme-og-svre-psykiske-lidelser-RUKS-2022.ashx). In this project, we aim to make it easier and more explicit how to classify type 1 and type 2 diabetes within
a Danish register context.
The original implementation of the algorithm is validated in a peer-reviewed publication [here](https://doi.org/10.2147/clep.s407019), but we expect to make tweaks to the algorithm over time. Any changes will be transparent in the *osdc* repository.
within the Danish registers that is flexible and convenient to use, and
validated in terms of accuracy. While there are a few algorithms used
throughout Denmark for Danish register research, they are usually
textual descriptions of how to do it, rather than code-based
descriptions (e.g. the [Register of Selected Chronic
Diseases](https://www.esundhed.dk/-/media/Files/Publikationer/Emner/Operationer-og-diagnoser/Udvalgte-kroniske-sygdomme-svaere-psykiske-lidelser/Algoritmer-for-Udvalgte-Kroniske-Sygdomme-og-svre-psykiske-lidelser-RUKS-2022.ashx).
In this project, we aim to make it easier and more explicit how to
classify type 1 and type 2 diabetes within a Danish register context.
The original implementation of the algorithm is validated in a
peer-reviewed publication [here](https://doi.org/10.2147/clep.s407019),
but we expect to make tweaks to the algorithm over time. Any changes
will be transparent in the *osdc* repository.

## Installation

Expand All @@ -20,3 +29,4 @@ You can install the development version of osdc from
# install.packages("pak")
pak::pak("steno-aarhus/osdc")
```

2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
Loading

0 comments on commit 387454a

Please sign in to comment.