Skip to content

Commit

Permalink
Merge pull request #6 from gofflab/jupyter
Browse files Browse the repository at this point in the history
Jupyter build
  • Loading branch information
chaichontat authored Sep 25, 2022
2 parents e173ae8 + cfd4103 commit d7f17af
Show file tree
Hide file tree
Showing 9 changed files with 33,211 additions and 25 deletions.
51 changes: 47 additions & 4 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,43 @@ on:
branches: [ "main" ]
pull_request:

defaults:
run:
shell: bash -l {0}

jobs:
build:
jupyter-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest] #, macos-latest]

steps:
- uses: actions/checkout@v3

- uses: mamba-org/provision-with-micromamba@main
with:
cache-downloads: true
cache-env: true
environment-name: qmn
environment-file: environment.yml

- name: Execute and export
run: |
jupytext --to notebook modules/**/*.py
jupyter nbconvert --NbConvertApp.recursive_glob=True --output-dir=modules/jupyter --execute --to html modules/**/*.ipynb
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: modules/jupyter/

Rmd-build:
needs: jupyter-build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest] #, macos-latest]

steps:
- uses: actions/checkout@v3
Expand All @@ -33,8 +63,21 @@ jobs:
- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2

- name: Render
run: Rscript render.R
- name: Cache Reference
uses: actions/cache@v3
with:
path: modules/module_3/data/reference
key: constant

# - uses: mxschmitt/action-tmate@v3

# - name: Render
# run: Rscript render.R

- name: Download jupyter artifacts
uses: actions/download-artifact@v3
with:
path: modules/jupyter/

- name: Generate index
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/main'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ vignettes/*.pdf
*.pdf

**/data/**
*.ipynb
9 changes: 8 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ Package: quant_mol_neuro_2022
Title: Package
Version: 0.1.0
Imports:
here,
rmarkdown,
tidyverse
tidyverse,
ggridges,
scRNAseq,
scater,
scran,
uwot,
BiocManager,
12 changes: 12 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: qmn

channels:
- conda-forge

dependencies:
- python=3.10
- jupyterlab
- jupytext
- scanpy
- seaborn
- pandas
32,834 changes: 32,834 additions & 0 deletions modules/module_2/notebooks/data/spotify_songs.csv

Large diffs are not rendered by default.

16 changes: 3 additions & 13 deletions modules/module_2/notebooks/mod2_ans.Rmd
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
## Part 1
```{r}
library(here)
tuesdata <- tidytuesdayR::tt_load("2020-01-21")
spotify_songs <- tuesdata$spotify_songs
# tests if a directory named "data" exists locally
if (!dir.exists(here::here("data"))) {
dir.create(here::here("data"))
}
# saves data only once (not each time you knit a R Markdown)
if (!file.exists(here::here("data", "spotify_songs.RDS"))) {
url_csv <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-01-21/spotify_songs.csv"
spotify_songs <- readr::read_csv(url_csv)
# save the file to RDS objects
saveRDS(spotify_songs, file = here("data", "spotify_songs.RDS"))
}
spotify_songs <- readRDS(here("data", "spotify_songs.RDS"))
url_csv <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-01-21/spotify_songs.csv"
spotify_songs <- readr::read_csv(url_csv)
df <- dplyr::as_tibble(spotify_songs)
```

Expand Down Expand Up @@ -146,4 +136,4 @@ colLabels(sce) <- scran::clusterCells(sce,
# Visualization.
sce <- scater::runUMAP(sce, dimred = "PCA")
scater::plotUMAP(sce, colour_by = "label")
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

here = Path(".")
data = here / "data"
data.mkdir(exist_ok=True, parents=True)
#%% Part 1

# This is a dataframe (like tibble).
spotify_songs = pd.read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-01-21/spotify_songs.csv")
spotify_songs = pd.read_csv(data / "spotify_songs.csv")
spotify_songs.to_csv(data / 'spotify_songs.csv', index=False)

spotify_songs
Expand Down
Loading

0 comments on commit d7f17af

Please sign in to comment.