-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kenny/sm-gatk' of github.com:latchbio/latch into kenny/…
…sm-gatk
- Loading branch information
Showing
44 changed files
with
615 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,4 @@ docs/build | |
.vscode | ||
scratch.py | ||
/scratch | ||
test_* | ||
.latch_report.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,7 @@ cli/mv | |
:maxdepth: 2 | ||
:caption: Manual | ||
manual/snakemake.md | ||
manual/tutorial.md | ||
``` | ||
|
||
```{toctree} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# A simple Snakemake example | ||
|
||
In this guide, we will walk through how you can upload a simple Snakemake workflow to Latch. | ||
|
||
The example being used here comes from the [short tutorial in Snakemake's documentation](https://snakemake.readthedocs.io/en/stable/tutorial/short.html). | ||
|
||
## Prerequisites | ||
|
||
* Install the [Latch SDK](https://github.com/latchbio/latch#installation) and [snakemake](https://snakemake.readthedocs.io/en/stable/getting_started/installation.html) with: | ||
|
||
```console | ||
pip install latch[snakemake] | ||
``` | ||
|
||
* Install [Docker](https://www.docker.com/get-started/) and have Docker run locally | ||
|
||
## Step 1 | ||
|
||
First, initialize an example Snakemake workflow: | ||
|
||
```console | ||
latch init snakemake-wf --template snakemake | ||
``` | ||
|
||
The workflow generated contains what is typically seen in a Snakemake workflow, such as python scripts and a Snakefile. | ||
|
||
```console | ||
snakemake-wf | ||
├── Dockerfile # Latch specific | ||
├── Snakefile | ||
├── data | ||
│ ├── genome.fa | ||
│ ├── genome.fa.amb | ||
│ ├── genome.fa.ann | ||
│ ├── genome.fa.bwt | ||
│ ├── genome.fa.fai | ||
│ ├── genome.fa.pac | ||
│ ├── genome.fa.sa | ||
│ └── samples | ||
│ ├── A.fastq | ||
│ ├── B.fastq | ||
│ └── C.fastq | ||
├── environment.yaml | ||
├── scripts | ||
│ ├── __pycache__ | ||
│ │ └── plot-quals.cpython-39.pyc | ||
│ └── plot-quals.py | ||
├── version | ||
└── wf | ||
``` | ||
|
||
To make the workflow compatible to execute on Latch, two additional files are needed: | ||
|
||
* `Dockerfile` to specify dependencies the workflow needs to run | ||
* `latch_metadata.py` to specify workflow parameters to expose on the user interface. | ||
|
||
In this tutorial, we will walk through how these two files can be constructed. | ||
|
||
## Step 2: Add a metadata file | ||
|
||
The `latch_metadata.py` is used to specify the input parameters that the Snakemake workflow needs to run. | ||
|
||
For example, by examining the Snakefile, we determine there are two parameters that the workflow needs: a reference genome and a list of samples to be aligned against the reference genome. | ||
|
||
```python | ||
# latch_metadata.py | ||
from latch.types.metadata import SnakemakeMetadata, SnakemakeFileParameter | ||
from latch.types.directory import LatchDir | ||
from latch.types.metadata import LatchAuthor, LatchMetadata, LatchParameter | ||
from pathlib import Path | ||
|
||
SnakemakeMetadata( | ||
display_name="snakemake_tutorial_workflow", | ||
author=LatchAuthor( | ||
name="latchbio", | ||
), | ||
parameters={ | ||
"samples" : SnakemakeFileParameter( | ||
display_name="Sample Input Directory", | ||
description="A directory full of FastQ files", | ||
type=LatchDir, | ||
path=Path("data/samples"), | ||
), | ||
"ref_genome" : SnakemakeFileParameter( | ||
display_name="Indexed Reference Genome", | ||
description="A directory with a reference Fasta file and the 6 index files produced from `bwa index`", | ||
type=LatchDir, | ||
path=Path("genome"), | ||
), | ||
}, | ||
) | ||
``` | ||
|
||
For each `LatchFile`/`LatchDir` parameter, the `path` keyword specifies the path where files will be copied before the Snakemake workflow is run and should match the paths of the inputs for each rule in the Snakefile. | ||
|
||
## Step 3: Add dependencies | ||
|
||
Next, create an `environment.yaml` file to specify the dependencies that the Snakefile needs to run successfully: | ||
|
||
```python | ||
# environment.yaml | ||
channels: | ||
- bioconda | ||
- conda-forge | ||
dependencies: | ||
- snakemake=7.25.0 | ||
- jinja2 | ||
- matplotlib | ||
- graphviz | ||
- bcftools =1.15 | ||
- samtools =1.15 | ||
- bwa =0.7.17 | ||
- pysam =0.19 | ||
- pygments | ||
``` | ||
|
||
A Dockerfile can be automatically generated by typing: | ||
```console | ||
latch dockerfile snakemake-wf --snakemake | ||
``` | ||
|
||
## Step 3: Upload the workflow to Latch | ||
|
||
Finally, type the following command to register the workflow to Latch: | ||
|
||
```console | ||
cd snakemake-wf &&\ | ||
latch register . --snakefile Snakefile | ||
``` | ||
|
||
During registration, a workflow image is built based on dependencies specified in the `environment.yaml` file. Once the registration finishes, the `stdout` provides a link to your workflow on Latch. | ||
|
||
![Snakemake workflow interface on Latch](../assets/snakemake/tutorial.png) | ||
|
||
## Step 4: Run the workflow | ||
|
||
Snakemake support is currently uses JIT (Just-In-Time) registration. This means that the workflow produced by `latch register` will register a second workflow, which will run the actual Snakemake jobs. | ||
|
||
Once the workflow finishes running, results will be deposited to [Latch Data](https://console.latch.bio/data) under the `Snakemake Outputs` folder. | ||
|
||
## Next Steps | ||
|
||
* Learn more in-depth about how Snakemake integration works on Latch by reading our [manual](../manual/snakemake.md). | ||
* Visit the repository of [public examples](https://github.com/latchbio/latch-snakemake-examples) of Snakemake workflows on Latch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.