Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handbook v2.5 es #191

Open
wants to merge 83 commits into
base: deploy-preview
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
0be7113
Testing
arranhamlet Jul 25, 2024
e64605a
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Jul 25, 2024
093f435
Numerous edits to the editorial_style and data_used pages, fixed link…
arranhamlet Aug 1, 2024
6236817
Working through the basics chapter, numerous links that need to be up…
arranhamlet Aug 1, 2024
856b84b
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Aug 1, 2024
4a25f73
Continuing to work through the basics chapter
arranhamlet Aug 21, 2024
77b4ab4
Fixing the table on object class
arranhamlet Aug 21, 2024
076e264
Completed the basics chapter
arranhamlet Aug 23, 2024
54702e1
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Aug 23, 2024
272c4a7
Upd to basics
arranhamlet Aug 23, 2024
e50caaf
General updates
arranhamlet Sep 4, 2024
410659b
Importing chapter, minor updates
arranhamlet Sep 4, 2024
c300e6f
Worked through cleaning and dates
arranhamlet Sep 4, 2024
3752295
Worked through factors
arranhamlet Sep 8, 2024
022a076
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 8, 2024
c5f136a
Updated the iteration chapter
arranhamlet Sep 9, 2024
7aa5079
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 9, 2024
4d4d472
Updated descriptive tables
arranhamlet Sep 9, 2024
2fb3fcd
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 9, 2024
1f2bc63
Updates to regression, standardization, moving averages, data links@
arranhamlet Sep 10, 2024
7a4e68c
Epidemic and survey analysis done
arranhamlet Sep 11, 2024
6c9bf82
Worked through survival analysis
arranhamlet Sep 11, 2024
7e4b80a
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 11, 2024
9e5697b
update list of the lead translator
ntluong95 Sep 11, 2024
5c49e11
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 11, 2024
744ef8b
gis chapter updated
arranhamlet Sep 11, 2024
1e6ac5a
updates to various pages
arranhamlet Sep 12, 2024
5744ff2
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
arranhamlet Sep 12, 2024
8e06add
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 12, 2024
224d203
Epicurve section done
arranhamlet Sep 12, 2024
5f6e29e
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 12, 2024
ebfa021
Large scale updates to numerous chapters filling in issues raised on …
arranhamlet Sep 18, 2024
e1dfe2e
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 18, 2024
c286b45
Further changes to chapters
arranhamlet Sep 19, 2024
617a460
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 19, 2024
05f7a6b
Upates to rmarkdown chapter
arranhamlet Sep 23, 2024
0cdc8d5
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 23, 2024
02d3990
Report factor and collaboration chapters reviewed
arranhamlet Sep 24, 2024
ca573fc
Flexdashboard chapter finished
arranhamlet Sep 24, 2024
14f0bff
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 24, 2024
e3dbfbe
updated epicurve chapter with incidence2 and completed diagram chapter
arranhamlet Sep 26, 2024
e548cba
Updates to epicurve chapter
arranhamlet Sep 26, 2024
60db63c
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 26, 2024
573cf62
Shiny and time series updated
arranhamlet Sep 27, 2024
68f7f4a
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 27, 2024
61d38be
All pages compiling
arranhamlet Sep 27, 2024
5578643
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 27, 2024
2703d23
Initial Quarto page created
arranhamlet Sep 29, 2024
da812e8
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 29, 2024
b19b092
Quarto updates and full rendering
arranhamlet Sep 30, 2024
99ea727
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Sep 30, 2024
29fb695
Final edits up to GIS
arranhamlet Oct 1, 2024
e3895aa
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 1, 2024
ddcd5e9
Reviewing chapters for last minute changes
arranhamlet Oct 1, 2024
e50c917
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 1, 2024
3eb5e8e
small edits after first review of Arran's edits
nsbatra Oct 14, 2024
4f4fbea
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 14, 2024
a53d14a
quarto page small edits
nsbatra Oct 14, 2024
e15520f
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 14, 2024
0db3e99
Updates to GIS chapter and Quarto
arranhamlet Oct 14, 2024
fca5341
Final update to GIS
arranhamlet Oct 14, 2024
187978e
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 14, 2024
259560d
Updates to make sure github issues have been addressed
arranhamlet Oct 15, 2024
a72b757
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 15, 2024
e6a4aa9
Initial updates following Neale's review
arranhamlet Oct 18, 2024
13def29
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 18, 2024
013d232
update Github Action to show changes in .qmd files only
ntluong95 Oct 29, 2024
0670a27
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
c260d6f
Merge branch 'deploy-preview' into handbook_v2.5_es
ntluong95 Oct 29, 2024
c45a3a6
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
69e2f38
Update a brand new PR
ntluong95 Oct 29, 2024
46cb70f
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
3427f6c
compare with master branch instead of main
ntluong95 Oct 29, 2024
8a3c8f7
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
be147a8
correctly retrieve only changed .qmd files
ntluong95 Oct 29, 2024
88be295
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
6d2c05c
Don't retrieve files with language extension
ntluong95 Oct 29, 2024
10b959d
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
93084d2
Reformat the PR
ntluong95 Oct 29, 2024
09ec001
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 29, 2024
136a8a8
Final edits flagged
arranhamlet Oct 30, 2024
4f0d72c
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
arranhamlet Oct 30, 2024
8489b44
Merge branch 'handbook_v2.5_en' of https://github.com/appliedepi/epiR…
ntluong95 Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .Rhistory
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
############
learnr, # interactive tutorials in RStudio Tutorial pane
swirl, # interactive tutorials in R console
# project and file management
Expand Down Expand Up @@ -510,3 +509,4 @@ bookdown::render_book(
output_format = 'bookdown::bs4_book',
config_file = "_bookdown.yml")
renv::status()
here("data", "linelists", "linelist_raw.xlsx")
102 changes: 53 additions & 49 deletions .github/workflows/create_pr_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Git

- name: Set up Git and Github CLI
run: |
git config --global user.name 'ntluong95'
git config --global user.email 'ph.ntluong95@gmail.com'

- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install -y gh

Expand All @@ -35,97 +33,103 @@ jobs:

for lang in "${LANGS[@]}"; do
TRANSLATION_BRANCH="handbook_${VERSION_SUFFIX/_en/_$lang}"
git fetch --prune

# Check if the translation branch exists
# Ensure we have all history
git fetch --all

#! Check if the translation branch exists
if git ls-remote --exit-code --heads origin "${TRANSLATION_BRANCH}"; then
echo "Branch ${TRANSLATION_BRANCH} exists. Checking out and rebasing with ${EN_BRANCH}"
git fetch --prune
git checkout "${TRANSLATION_BRANCH}"

echo "${EN_BRANCH#refs/heads/}"
echo "${TRANSLATION_BRANCH}"

git status
git pull -s recursive -X theirs --no-rebase --no-edit origin "${EN_BRANCH#refs/heads/}" --allow-unrelated-histories
git push origin "${TRANSLATION_BRANCH}"

else
echo "Branch ${TRANSLATION_BRANCH} does not exist. Creating new branch from ${EN_BRANCH}."
git checkout -b "${TRANSLATION_BRANCH}"
git pull origin "${EN_BRANCH#refs/heads/}"
fi

# Force push the changes to the remote repository
#! Force push the changes to the remote repository
git push origin "${TRANSLATION_BRANCH}" --force

#! Get the list of changed .qmd files: COMPARED WITH main branch
changed_files=$(git diff --name-only origin/main "${TRANSLATION_BRANCH}" | grep -E '\.qmd$' | grep -Ev '\.[a-z]{2}\.qmd$')

if [ -z "$changed_files" ]; then
echo "No .qmd file changes to include in PR for ${TRANSLATION_BRANCH}"
continue
fi

echo "Changed files: $changed_files"


# Get the date of the latest commit on the english branch
#! Get the date of the latest commit on the english branch
latest_commit_date=$(git show -s --format=%ci ${EN_BRANCH})

echo "Commits on the English branch that were made after the latest commit on the translation branch at $latest_commit_date"
latest_commit_en_branch=$(git show --format=%H -s ${EN_BRANCH})
latest_commit_info=$(git log ${EN_BRANCH} --since="$latest_commit_date" --format="%H %s" --reverse)
commit_messages=$(echo "$latest_commit_info" | cut -d' ' -f2-)
latest_commit_master=$(git show --format=%H -s origin/master)
latest_commit_main=$(git show --format=%H -s origin/master)

echo $latest_commit_en_branch
echo $latest_commit_master
echo $latest_commit_main
echo $latest_commit_info

# Check if there are new commits
if [ "$latest_commit_en_branch" == "$latest_commit_master" ]; then
#! Check if there are new commits
if [ "$latest_commit_en_branch" == "$latest_commit_main" ]; then
echo "No new commits to include in PR for ${TRANSLATION_BRANCH}"
continue
fi

# Check if a PR already exists for this branch
#! Check if a PR already exists for this branch
PR_EXISTS=$(gh pr list --head "${TRANSLATION_BRANCH}" --state open --json number --jq length)
if [ "$PR_EXISTS" -eq 0 ]; then
echo "Creating new PR for ${TRANSLATION_BRANCH}"
PR_URL=$(gh pr create --base deploy-preview --head "$TRANSLATION_BRANCH" --title "Handbook ${VERSION_SUFFIX/_en/} $lang" --body "Automated pull request for $lang handbook version ${VERSION_SUFFIX/_en/}")
PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$')
else
# Get the PR number for the translation branch
#! Get the PR number for the translation branch
echo "PR already exists for ${TRANSLATION_BRANCH}"
PR_NUMBER=$(gh pr list --head "${TRANSLATION_BRANCH}" --state open --json number --jq ".[0].number")
fi

echo "Pull Request Number: $PR_NUMBER"

#! Initialize new PR body
new_pr_body="# Automated pull request for $lang handbook version ${VERSION_SUFFIX/_en/}"$'\n\n'

#! Mention a user in the PR description
case "$lang" in
"vn") new_pr_body+="@ntluong95, please review changes and check the box when you finish"$'\n' ;;
"fr") new_pr_body+="@oliviabboyd, please review changes and check the box when you finish"$'\n' ;;
"es") new_pr_body+="@amateo250, please review changes and check the box when you finish"$'\n' ;;
"jp") new_pr_body+="@hitomik723, please review changes and check the box when you finish"$'\n' ;;
"tr") new_pr_body+="@ntluong95, please review changes and check the box when you finish"$'\n' ;;
"pt") new_pr_body+="@Luccan97, please review changes and check the box when you finish"$'\n' ;;
"ru") new_pr_body+="@ntluong95, please review changes and check the box when you finish"$'\n' ;;
esac

# Add new commits as checkboxes to the PR description
#! Add new commits as checkboxes to the PR description
IFS=$'\n' # Change the Internal Field Separator to newline for correct iteration over lines
checkboxes=""
for commit in $latest_commit_en_branch; do
checkboxes="$checkboxes- [ ] [$commit_messages](https://github.com/${{ github.repository }}/commit/$commit)"
for file in $changed_files; do
#! List only new commits compared with the main branch, tail -n +2 to skip the first line of output from git log, the latest commit will not be added into the message
list_commits=$(git log origin/main..${TRANSLATION_BRANCH} --follow --pretty=format:"%H" -- $file | tail -n +2 | paste -sd, - | sed 's/,/, /g')
for commit in $latest_commit_en_branch; do
checkboxes="$checkboxes- [ ] Chapter [\`$file\`](https://github.com/${{ github.repository }}/pull/$PR_NUMBER/files?file-filters%5B%5D=.qmd&show-viewed-files=true) has changes in the following commit(s): $list_commits. "
checkboxes="$checkboxes"$'\n'"$checkbox"

done
done


# Mention a user in the PR description
if [ "$lang" = "vn" ]; then
checkboxes="$checkboxes @ntluong95, please check the box when you finish"
elif [ "$lang" = "fr" ]; then
checkboxes="$checkboxes @nsbatra, please check the box when you finish"
elif [ "$lang" = "es" ]; then
checkboxes="$checkboxes @robcrystalornelas, please check the box when you finish"
elif [ "$lang" = "jp" ]; then
checkboxes="$checkboxes @ntluong95, please check the box when you finish"
elif [ "$lang" = "tr" ]; then
checkboxes="$checkboxes @ntluong95, please check the box when you finish"
elif [ "$lang" = "pt" ]; then
checkboxes="$checkboxes @ntluong95, please check the box when you finish"
elif [ "$lang" = "ru" ]; then
checkboxes="$checkboxes @ntluong95, please check the box when you finish"
if [ -n "$checkboxes" ]; then
# Append the checkboxes to the new PR body
new_pr_body="$new_pr_body"$'\n'"$checkboxes"
fi


# Retrieve the current PR description
current_pr_body=$(gh pr view $PR_NUMBER --json body --jq '.body')

# Append checkboxes to the current PR description
new_pr_body=$(printf "%s\n%s" "$current_pr_body" "$checkboxes")

# gh api repos/${{ github.repository }}/issues/$PR_NUMBER --method PATCH --field body="$checkboxes"
gh api repos/${{ github.repository }}/issues/$PR_NUMBER --method PATCH --field body="$new_pr_body"

done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ book:
- icon: twitter
href: "https://twitter.com/appliedepi"
- icon: linkedin
href: "https://www.linkedin.com/company/appliedepi/"
href: "https://www.linkedin.com/company/appliedepi"
# - icon: github
# menu:
# - text: Source Code
Expand Down Expand Up @@ -206,6 +206,7 @@ book:
- new_pages/reportfactory.qmd #done
- new_pages/flexdashboard.qmd #done
- new_pages/shiny_basics.qmd #done
- new_pages/quarto.qmd #done

# MISCELLANEOUS
- part: "Miscellaneous"
Expand Down
Binary file added data/contact_tracing.rds
Binary file not shown.
90 changes: 90 additions & 0 deletions data/quarto/outbreak_dashboard.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: "Outbreak dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---

```{r setup, echo=FALSE}
pacman::p_load(rio, here, tidyverse, flexdashboard, # load packages
flextable, incidence2, epicontacts, DT, janitor)

linelist <- import(here("data", "case_linelists", "linelist_cleaned.rds")) # import data
```

## Column 1 {data-width=500}
### Summary and action items

This report is for the Incident Command team of the fictional outbreak of Ebola cases. **As of `r format(max(linelist$date_hospitalisation, na.rm=T), "%d %B")` there have been `r nrow(linelist)` cases reported as hospitalized.**

* Several previously-unaffected areas to the West are now reporting cases
* Internal reviews suggest that better communication is needed between district and provincial level data management teams
* Safe and dignified burial teams are reporting difficulties

### Review data
#### Cases by hospital
```{r}
linelist %>%
count(hospital) %>%
adorn_totals() %>%
rename("Hospital" = hospital,
"Cases" = n) %>%
knitr::kable()
```


## Column 2 {data-width=500}
### Epidemic curve by age

```{r}
age_outbreak <- incidence(linelist, "date_onset", "week", groups = "age_cat")
plot(age_outbreak, fill = "age_cat", col_pal = muted, title = "") %>%
plotly::ggplotly()
```

### Transmission chain (select cases)
```{r}
# load package
pacman::p_load(epicontacts)

## generate contacts
contacts <- linelist %>%
transmute(
infector = infector,
case_id = case_id,
location = sample(c("Community", "Nosocomial"), n(), TRUE),
duration = sample.int(10, n(), TRUE)
) %>%
drop_na(infector)

## generate epicontacts object
epic <- make_epicontacts(
linelist = linelist,
contacts = contacts,
id = "case_id",
from = "infector",
to = "case_id",
directed = TRUE
)

## subset epicontacts object
sub <- epic %>%
subset(
node_attribute = list(date_onset = c(as.Date(c("2014-06-30", "2014-06-01"))))
) %>%
thin("contacts")

# temporal plot
plot(
sub,
x_axis = "date_onset",
node_color = "outcome",
col_pal = c(Death = "firebrick", Recover = "green"),
arrow_size = 0.5,
node_size = 13,
label = FALSE,
height = 700,
width = 700
)
```
Loading