aboutsummaryrefslogtreecommitdiff
path: root/day2/ex4-scanpy/solution.nix
blob: dcc20374e7cf010d29e1f5a717f8a247f1ab0ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
  bionix,
  mach-nix,
}:
with bionix; let
  python = mach-nix.mkPython {
    requirements = ''
      jupyterlab
      scanpy
      anndata=0.7.8
      leidenalg
    '';
  };
in
  stage {
    name = "scanpy-tutorial.html";
    buildInputs = [python];
    outputs = ["out" "results"];

    src = pkgs.fetchurl {
      url = "http://cf.10xgenomics.com/samples/cell-exp/1.1.0/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz";
      sha256 = "sha256-hH1uvZoeyado8r5+QMpCy/516+ttdqTCQWcEFpncKLU=";
    };

    notebook = pkgs.fetchurl {
      url = "https://github.com/scverse/scanpy-tutorials/raw/532f755ac31d9baf00116a44243b73174765a6a6/pbmc3k.ipynb";
      sha256 = "sha256-mwIPHKAsDd1F4F9fNnAfrapBehBN3jjEsrLGsI37Igg=";
    };

    buildCommand = ''
      export NUMBA_CACHE_DIR=$TMPDIR
      cp $notebook notebook.ipynb
      mkdir data
      tar -zxf $src -C data
      mkdir write
      jupyter nbconvert  --execute --to html ./notebook.ipynb
      cp notebook.html $out
      cp -r write $results
    '';

    stripStorePaths = false;
  }