Skip to content

Commit

Permalink
Merge branch 'roy'
Browse files Browse the repository at this point in the history
  • Loading branch information
royfrancis committed Jan 5, 2025
2 parents 90b71d5 + bd87587 commit 9bdb2ac
Show file tree
Hide file tree
Showing 32 changed files with 1,096 additions and 254 deletions.
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
# DOCKER FILE FOR WORKSHOP-NGSINTRO
# 2024 Roy Francis
# 2025 Roy Francis

FROM rocker/verse:4.2.3
FROM rocker/verse:4.4
LABEL Description="Docker image for NBIS workshop"
LABEL Maintainer="[email protected]"
LABEL org.opencontainers.image.source="https://github.com/NBISweden/workshop-ngsintro"
ARG QUARTO_VERSION="1.4.549"
#ARG QUARTO_VERSION="1.6.40"

RUN apt-get update -y \
&& apt-get clean \
&& apt-get install --no-install-recommends -y \
libxml2-dev \
libssl-dev \
libcurl4-openssl-dev \
libudunits2-dev \
libopenblas-base \
libgdal-dev \
curl \
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt-get install -y ./google-chrome-stable_current_amd64.deb \
&& rm -rf ./google-chrome-stable_current_amd64.deb \
&& curl -o quarto-linux-amd64.deb -L https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb \
&& apt-get install -y ./quarto-linux-amd64.deb \
&& rm -rf ./quarto-linux-amd64.deb \
&& Rscript -e 'install.packages(c("remotes","fontawesome","here","htmlTable","leaflet","readxl","writexl"),repos = "http://cran.us.r-project.org");' \
#&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
#&& apt-get install -y ./google-chrome-stable_current_amd64.deb \
#&& rm -rf ./google-chrome-stable_current_amd64.deb \
#&& curl -o quarto-linux-amd64.deb -L https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb \
#&& apt-get install -y ./quarto-linux-amd64.deb \
#&& rm -rf ./quarto-linux-amd64.deb \
&& rm -rf /var/lib/apt/lists/* \
&& install2.r --error --skipinstalled remotes fontawesome here htmlTable leaflet readxl writexl \
&& rm -rf /tmp/downloaded_packages \
&& mkdir /qmd /.cache \
&& chmod 777 /qmd /.cache

## Required when editing rnaseq
## RUN Rscript -e 'BiocManager::install(c("DESeq2","edgeR","goseq","GO.db","org.Mm.eg.db","reactome.db"));'
USER rstudio

## Required when editing rnaseq lab
RUN Rscript -e 'install.packages(c("pheatmap","ggrepel"),repos = "http://cran.us.r-project.org"); BiocManager::install(c("DESeq2", "edgeR", "org.Mm.eg.db", "clusterProfiler"));'

WORKDIR /qmd
#ENV XDG_CACHE_HOME=/tmp/quarto_cache_home
#ENV XDG_DATA_HOME=/tmp/quarto_data_home
CMD quarto render
CMD ["quarto", "render"]

# docker build --platform linux/amd64 -t ghcr.io/nbisweden/workshop-ngsintro:2.3.0 -t ghcr.io/nbisweden/workshop-ngsintro:latest .
# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/work kaczmarj/apptainer build ngsintro.sif docker://ghcr.io/nbisweden/workshop-ngsintro:latest
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ as the first thing, so that old rendered files are not overwritten.

:exclamation: Do not push any rendered .html files or intermediates.

## Docker
### Local build/preview using Docker

You can preview changes and build the whole website locally without a local installation of R or dependency packages by using the pre-built Docker image.
Expand All @@ -47,46 +48,46 @@ docker run --platform linux/amd64 --rm -u 1000:1000 -v ${PWD}:/qmd ghcr.io/nbisw

:exclamation: Output files are for local preview only. Do not push any rendered .html files or intermediates.

## Convert HTML slides to PDF
### Convert HTML slides to PDF

```
docker run --platform=linux/amd64 -v $PWD:/work astefanutti/decktape https://nbisweden.github.io/workshop-ngsintro/2403/topics/rnaseq/slide_rnaseq.html /work/slide_rnaseq.pdf
```

## Repo organisation
### Serving and automatic rendering

The source material is located on the *master* branch (default). The rendered material is located on the *gh-pages* branch. One only needs to update source materials in *master*. Changes pushed to the *master* branch is automatically rendered to the *gh-pages* branch using github actions.
You can use `quarto preview` to serve the site, and handle automatic rebuilding of pages when any `.qmd` file is changed.

:exclamation: Every push rebuilds the whole website using a pre-built docker image.
```bash
# serve the site
docker run --rm -it --platform linux/amd64 -u $(id -u):$(id -g) -v ${PWD}:/qmd -p 8800:8800 ghcr.io/nbisweden/workshop-ngsintro:latest quarto preview --port 8800 --host 0.0.0.0
```

This repo is loosely based on the quarto template [specky](https://github.com/royfrancis/specky).
Go to [http://localhost:8800/](http://localhost:8800/) or [http://0.0.0.0:8800](http://0.0.0.0:8800) in your browser.

## Building docker container
### Building your own docker container

```bash
# build container
docker build --platform linux/amd64 -t ghcr.io/nbisweden/workshop-ngsintro:2.3.0 -t ghcr.io/nbisweden/workshop-ngsintro:latest .
docker build --platform linux/amd64 -t ghcr.io/nbisweden/workshop-ngsintro:2.4.0 -t ghcr.io/nbisweden/workshop-ngsintro:latest .

# push to ghcr
# docker login ghcr.io
docker push ghcr.io/nbisweden/workshop-ngsintro:2.3.0
docker push ghcr.io/nbisweden/workshop-ngsintro:2.4.0
docker push ghcr.io/nbisweden/workshop-ngsintro:latest

# run container in the root of the repo
docker run --rm --platform linux/amd64 -u $(id -u):$(id -g) -v ${PWD}:/qmd ghcr.io/nbisweden/workshop-ngsintro:latest
docker run --rm --platform linux/amd64 -u $(id -u):$(id -g) -v ${PWD}:/qmd ghcr.io/nbisweden/workshop-ngsintro:latest quarto render index.qmd
```

## Serving and automatic rendering
## Repo organisation

You can use `quarto preview` to serve the site, and handle automatic rebuilding of pages when any `.qmd` file is changed.
The source material is located on the *master* branch (default). The rendered material is located on the *gh-pages* branch. One only needs to update source materials in *master*. Changes pushed to the *master* branch is automatically rendered to the *gh-pages* branch using github actions.

```bash
# serve the site
docker run --rm -it --platform linux/amd64 -u $(id -u):$(id -g) -v ${PWD}:/qmd -p 8800:8800 ghcr.io/nbisweden/workshop-ngsintro:latest quarto preview --port 8800 --host 0.0.0.0
```
:exclamation: Every push rebuilds the whole website using a pre-built docker image.

Go to [http://localhost:8800/](http://localhost:8800/) or [http://0.0.0.0:8800](http://0.0.0.0:8800) in your browser.
This repo is loosely based on the quarto template [specky](https://github.com/royfrancis/specky).

## Test scripts

Expand All @@ -98,4 +99,4 @@ The contents of these scripts should use identical steps and tools as the studen

---

**2024** • NBIS • SciLifeLab
**2025** • NBIS • SciLifeLab
6 changes: 4 additions & 2 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ execute:

filters:
- assets/custom.lua
- assets/fold-results.lua
- reveal-logo

# used site-wide
Expand All @@ -138,8 +139,9 @@ id_slurm_res_wed: "edu25-03-26"
id_slurm_res_thu: "edu25-03-27"
id_slurm_res_fri: "edu25-03-28"

# location options are linkoping, lund, umea, uppsala or online. For rendering the info page.
# one or more separated by commas or semicolon. online doesn't display any location info.
# location is used to render the info page
# location options are linkoping, lund, umea, stockholm, uppsala or online
# one or more separated by commas or semicolon.
location: online
assistants:
- "AJ: Anna Johansson"
Expand Down
4 changes: 3 additions & 1 deletion assets/_child-info.qmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
```{r}
#| echo: false
icons <- awesomeIcons(icon = dfr2$marker_icon, markerColor = dfr2$marker_color, iconColor = "#FFFFFF", library = "fa")
htmltools::div(
style = "margin-bottom:1em;",
htmltools::tagList(leaflet(height = 450, width = "auto", elementId = paste0("leaflet-", p)) %>%
addTiles(urlTemplate = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") %>%
addAwesomeMarkers(lat = dfr2$lat, lng = dfr2$lon, label = dfr2$label, popup = dfr2$popup, icon = icons) %>%
setView(lat = dfr2$lat[1], lng = dfr2$lon[1], zoom = 13))
)
```
```
4 changes: 2 additions & 2 deletions assets/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ body {
}

.navbar {
background-color: transparent !important;
background-color: transparent !important;
}

.nav-footer {
background-color: transparent !important;
background-color: transparent !important;
}

.home-container {
Expand Down
25 changes: 25 additions & 0 deletions assets/css/slides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ $presentation-h6-font-size: 1em;
margin-bottom: 0.5em;
}

.reveal .code-with-filename-file pre {
background-color: transparent;
font-size: 80% !important;
}

.reveal pre,
.reveal code {
border-radius: 6px;
Expand Down Expand Up @@ -118,6 +123,26 @@ $presentation-h6-font-size: 1em;
text-align: right;
}

/* vertical alignment */

.reveal .v-center {
display: grid;
align-items: center;
height: 90%;
}

.reveal .v-top {
display: grid;
align-items: start;
height: 90%;
}

.reveal .v-bottom {
display: grid;
align-items: end;
height: 90%;
}

/* lists */

.reveal .slide ul,
Expand Down
1 change: 1 addition & 0 deletions assets/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $code-color: #496985;
$code-block-bg: WhiteSmoke;
$font-family-sans-serif: 'Nunito', 'Source Sans Pro', 'Helvetica', 'sans-serif' ;
$font-family-monospace: 'Fira Mono', 'Ubuntu Mono', 'Liberation Mono', 'Lucida Console', 'Courier', 'monospace';
$mermaid-font-family: 'Nunito', 'Source Sans Pro', 'Helvetica', 'sans-serif' ;
$font-size-root: 18px;
$code-font-size: 14px;
/* major second scale */
Expand Down
20 changes: 20 additions & 0 deletions assets/fold-results.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Fold output from code chunks
-- In code chunk, add #| attr.output: '.details summary="Output"'
-- Only works for knitr chunks
-- https://gist.github.com/atusy/f2b5b992e45c68ab6823499f2339c6e6

function CodeBlock(elem)
if elem.classes and elem.classes:find("details") then
local summary = "Code"
if elem.attributes.summary then
summary = elem.attributes.summary
end
return{
pandoc.RawBlock(
"html", "<details><summary>" .. summary .. "</summary>"
),
elem,
pandoc.RawBlock("html", "</details>")
}
end
end
6 changes: 0 additions & 6 deletions assets/fonts/head.html

This file was deleted.

72 changes: 54 additions & 18 deletions home_info.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,45 @@ format: html
library(yaml)
library(here)
library(leaflet)
library(readxl)
#' Get location data from YAML into a list and data.frame
#' @param y YAML data
#' @param loc Name of location
#' @return List with description and data.frame with map data
#'
get_info <- function(y, loc) {
loc <- tolower(loc)
if (loc %in% names(y)) {
info <- y[[loc]]
if (!is.null(info$description)) {
d <- info$description
} else {
d <- NULL
}
if (!is.null(info$map)) {
m <- do.call(rbind, lapply(info$map, function(x){
required_fields <- c("label", "marker_icon", "marker_color", "lat", "lon", "popup")
missing_fields <- setdiff(required_fields, names(x))
if (length(missing_fields) > 0) {
stop(paste("Missing fields:", paste(missing_fields, collapse = ", ")))
}
as.data.frame(x)
}))
} else {
m <- NULL
}
return(list(description = d, map = m))
} else {
message(paste0("Location ", loc, " not found in the data"))
return(NULL)
}
}
# set location in _quarto.yml
loc <- sapply(unlist(strsplit(yaml::read_yaml(here("_quarto.yml"))$location,";|,")),trimws)
dfr <- readxl::read_xlsx("info.xlsx")
loc <- sapply(unlist(strsplit(yaml::read_yaml(here("_quarto.yml"))$location, ";|,")), trimws)
l <- yaml::yaml.load_file(here("info.yml"))
```

## Location
Expand All @@ -25,25 +59,27 @@ dfr <- readxl::read_xlsx("info.xlsx")
cat("\n::: {.panel-tabset}\n")
for (i in seq_along(loc)) {
p <- loc[i]
cat(paste0("\n### ", tools::toTitleCase(p), "\n"))
p <- loc[i]
cat(paste0("\n### ", tools::toTitleCase(p), "\n"))
if(p %in% dfr$location){
dfr1 <- dfr[dfr$location %in% p, , drop = FALSE]
dfr1$address <- gsub(";|; ", "<br>", dfr1$address)
idata <- get_info(l, p)
if (!is.null(idata)) {
if (!is.null(idata$map)) {
dfr1 <- idata$map
dfr1$popup <- gsub(";|; ", "<br>", dfr1$popup)
dfr2 <- dfr1[complete.cases(dfr1$lat, dfr1$lon), ]
icons <- awesomeIcons(icon = dfr2$marker_icon, markerColor = dfr2$marker_colour, iconColor = "#FFFFFF", library = "fa")
if(p != "online") {
cat(knitr::knit_child(input = "assets/_child-info.qmd", envir = environment(), quiet = TRUE))
cat("\n")
cat("\n", dfr1$address[1], "\n")
}
cat("\n", dfr1$description[1])
}else{
cat("No additional information is provided.")
cat(knitr::knit_child(input = "assets/_child-info.qmd", envir = environment(), quiet = TRUE))
cat("\n")
}
if (!is.null(idata$description)) {
cat("\n", idata$description)
}
cat("\n")
} else {
cat("No additional information is provided.")
}
cat("\n")
}
cat(":::\n")
Expand Down
Binary file removed info.xlsx
Binary file not shown.
Loading

0 comments on commit 9bdb2ac

Please sign in to comment.