Skip to content

Commit 02ade48

Browse files
committed
clean up looper docs
1 parent e1ef37e commit 02ade48

3 files changed

Lines changed: 107 additions & 48 deletions

File tree

docs/looper/advanced-guide/advanced-run-options.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ Let's introduce some of the more advanced capabilities of `looper run`.
1818

1919
## Grouping many jobs into one
2020

21-
By default, `looper` will translate each row in your `sample_table` into a single job. But perhaps you are running a project with tens of thousands of rows, and each job only takes mere minutes to run; in this case, you'd rather just submit a single job to process many samples. `Looper` makes this easy with the `--lump` and `--lumpn` command line arguments.
21+
By default, `looper` will translate each row in your `sample_table` into a single job. But perhaps you are running a project with tens of thousands of rows, and each job only takes mere minutes to run; in this case, you'd rather just submit a single job to process many samples. `Looper` makes this easy with the `--lump` and `--lump-n` command line arguments.
2222

23-
### Lumping jobs by job count: `--lumpn`
23+
### Lumping jobs by job count: `--lump-n`
2424

25-
It's quite simple: if you want to run 100 samples in a single job submission script, just tell looper `--lumpn 100`.
25+
It's quite simple: if you want to run 100 samples in a single job submission script, just tell looper `--lump-n 100`.
2626

2727
### Lumping jobs by input file size: `--lump`
2828

29-
But what if your samples are quite different in terms of input file size? For example, your project may include many small samples, which you'd like to lump together with 10 jobs to 1, but you also have a few control samples that are very large and should have their own dedicated job. If you just use `--lumpn` with 10 samples per job, you could end up lumping your control samples together, which would be terrible. To alleviate this problem, `looper` provides the `--lump` argument, which uses input file size to group samples together. By default, you specify an argument in number of gigabytes. Looper will go through your samples and accumulate them until the total input file size reaches your limit, at which point it finalizes and submits the job. This will keep larger files in independent runs and smaller files grouped together.
29+
But what if your samples are quite different in terms of input file size? For example, your project may include many small samples, which you'd like to lump together with 10 jobs to 1, but you also have a few control samples that are very large and should have their own dedicated job. If you just use `--lump-n` with 10 samples per job, you could end up lumping your control samples together, which would be terrible. To alleviate this problem, `looper` provides the `--lump` argument, which uses input file size to group samples together. By default, you specify an argument in number of gigabytes. Looper will go through your samples and accumulate them until the total input file size reaches your limit, at which point it finalizes and submits the job. This will keep larger files in independent runs and smaller files grouped together.
3030

31-
### Lumping jobs by input file size: `--lumpj`
31+
### Lumping jobs by job count: `--lump-j`
3232

33-
Or you can lump samples into number of jobs.
33+
If you want to split your samples across a specific number of jobs, use `--lump-j`. For example, `--lump-j 10` will distribute all your samples evenly across 10 jobs.
3434

3535

3636
## Running project-level pipelines
@@ -251,22 +251,28 @@ For example, to choose only samples where the `species` attribute is `human`, `m
251251

252252
```console
253253
looper run \
254-
--sel-attr species
254+
--sel-attr species \
255255
--sel-incl human mouse fly
256256
```
257257

258258
Similarly, to submit only one sample, with `sample_name` as `sample`, you could use:
259259

260260
```console
261261
looper run \
262-
--sel-attr sample_name
262+
--sel-attr sample_name \
263263
--sel-incl sample1
264264
```
265265

266266
### Sample selection by exclusion
267267

268-
If more convenient to *exclude* samples by filter, you can use the analogous arguments `--sel-attr` with `--sel-excl`.
269-
This will
268+
If it's more convenient to *exclude* samples by filter, you can use the analogous arguments `--sel-attr` with `--sel-excl`.
269+
This will exclude any samples matching the specified values. For example, to run all samples *except* those where `species` is `rat`:
270+
271+
```console
272+
looper run \
273+
--sel-attr species \
274+
--sel-excl rat
275+
```
270276

271277
### Toggling sample jobs through the sample table
272278

docs/looper/user-tutorial/initialize.md

Lines changed: 87 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -87,36 +87,56 @@ Chiapas
8787

8888
## Step 3: Create a metadata table
8989

90-
Looper needs a list of samples in the form of a sample metadata table, which names each sample and includes paths to the data files. Looper will accept a PEP, which we'll discuss more later, or just a simple CSV file, which is where we'll start. Create a new file called `metadata/sample_table.csv` and paste this content in it:
90+
Looper needs a list of samples in the form of a sample metadata table, which names each sample and includes paths to the data files. Looper will accept a PEP, which we'll discuss more later, or just a simple CSV file, which is where we'll start. Create a new file called `metadata/sample_table.csv` with this content:
9191

92-
```csv title="metadata/sample_table.csv"
93-
sample_name,area_type,file_path
94-
mexico,state,data/mexico.txt
95-
switzerland,canton,data/switzerland.txt
96-
canada,province,data/canada.txt
97-
```
92+
=== "View"
93+
94+
```csv title="metadata/sample_table.csv"
95+
sample_name,area_type,file_path
96+
mexico,state,data/mexico.txt
97+
switzerland,canton,data/switzerland.txt
98+
canada,province,data/canada.txt
99+
```
100+
101+
=== "Create"
102+
103+
```sh
104+
mkdir -p metadata && cat > metadata/sample_table.csv << 'EOF'
105+
sample_name,area_type,file_path
106+
mexico,state,data/mexico.txt
107+
switzerland,canton,data/switzerland.txt
108+
canada,province,data/canada.txt
109+
EOF
110+
```
98111

99112
Each row corresponds to a sample, with a unique identifier under `sample_name`, a pointer to its corresponding file in `file_path`, and any other information you want to include about the sample (in this case, `area_type`). These will be the different values available to pass to your pipeline.
100113

101114
## Step 4: Create the pipeline
102115

103-
Our example pipeline is a shell script that counts the lines in an input file. Since our data has one line per province, this script will tell us how many provinces there are in each country. Create a file under `pipeline/count_lines.sh` with this content:
116+
Our example pipeline is a shell script that counts the lines in an input file. Since our data has one line per province, this script will tell us how many provinces there are in each country. Create a file at `pipeline/count_lines.sh` with this content:
104117

105-
```sh title="pipeline/count_lines.sh"
106-
#!/bin/bash
107-
linecount=`wc -l $1 | sed -E 's/^[[:space:]]+//' | cut -f1 -d' '`
108-
echo "Number of lines: $linecount"
109-
```
118+
=== "View"
119+
120+
```sh title="pipeline/count_lines.sh"
121+
#!/bin/bash
122+
linecount=`wc -l $1 | sed -E 's/^[[:space:]]+//' | cut -f1 -d' '`
123+
echo "Number of lines: $linecount"
124+
```
110125

126+
=== "Create"
127+
128+
```sh
129+
mkdir -p pipeline && cat > pipeline/count_lines.sh << 'EOF'
130+
#!/bin/bash
131+
linecount=`wc -l $1 | sed -E 's/^[[:space:]]+//' | cut -f1 -d' '`
132+
echo "Number of lines: $linecount"
133+
EOF
134+
chmod 755 pipeline/count_lines.sh
135+
```
111136

112137
All this script does is run the unix `wc` command, and then parse the output using `sed` and `cut`, and then print the result with `echo`.
113138
In a real workspace, your pipeline is more likely to be a powerful Python script or something else.
114-
The important thing for looper is just that there's a command you can run to execute the pipeline, and you can pass arguments on the command line.
115-
Since looper will need to execute it, make sure your script has execute permission:
116-
117-
```sh
118-
chmod 755 pipeline/count_lines.sh
119-
```
139+
The important thing for looper is just that there's a command you can run to execute the pipeline, and you can pass arguments on the command line.
120140

121141

122142
## Step 5: Create a pipeline interface
@@ -125,14 +145,27 @@ In order to run a pipeline, looper needs to know how to construct the command, w
125145
A pipeline developer does this through the *pipeline interface*.
126146
Our `count_lines.sh` pipeline just takes a single argument, which is the file path, so the command would be `count_lines.sh path/to/file.txt`.
127147
Here's how to create the appropriate pipeline interface for this pipeline.
128-
Create a file in `pipeline/pipeline_interface.yaml` and paste this content into it:
148+
Create a file at `pipeline/pipeline_interface.yaml` with this content:
129149

130-
```yaml title="pipeline/pipeline_interface.yaml"
131-
pipeline_name: count_lines
132-
sample_interface:
133-
command_template: >
134-
pipeline/count_lines.sh {sample.file_path}
135-
```
150+
=== "View"
151+
152+
```yaml title="pipeline/pipeline_interface.yaml"
153+
pipeline_name: count_lines
154+
sample_interface:
155+
command_template: >
156+
pipeline/count_lines.sh {sample.file_path}
157+
```
158+
159+
=== "Create"
160+
161+
```sh
162+
cat > pipeline/pipeline_interface.yaml << 'EOF'
163+
pipeline_name: count_lines
164+
sample_interface:
165+
command_template: >
166+
pipeline/count_lines.sh {sample.file_path}
167+
EOF
168+
```
136169

137170
This is the pipeline interface file.
138171
It specifies the `pipeline_name`, which looper uses to keep track of pipelines in case it is running multiple of them.
@@ -144,8 +177,12 @@ For now, the important part is just that the `command_template` is telling loope
144177

145178
Now you have all the components finished for your looper project.
146179
The last step is to create the looper configuration file.
147-
The easiest way to do this is to run `looper init` from within your workspace folder.
148-
This will walk you through a wizard that will build the file for you.
180+
The easiest way to do this is to run the *looper init* wizard from within your workspace folder.
181+
This wizard will walk you through building the file.
182+
183+
```
184+
looper init # Run looper initialization wizard
185+
```
149186

150187
Here's how to answer the questions
151188

@@ -159,12 +196,25 @@ Here's how to answer the questions
159196

160197
This will create a file at `.looper.yaml`, with this content:
161198

162-
```yaml title=".looper.yaml"
163-
pep_config: metadata/sample_table.csv
164-
output_dir: results
165-
pipeline_interfaces:
166-
- pipeline/pipeline_interface.yaml
167-
```
199+
=== "View"
200+
201+
```yaml title=".looper.yaml"
202+
pep_config: metadata/sample_table.csv
203+
output_dir: results
204+
pipeline_interfaces:
205+
- pipeline/pipeline_interface.yaml
206+
```
207+
208+
=== "Create"
209+
210+
```sh
211+
cat > .looper.yaml << 'EOF'
212+
pep_config: metadata/sample_table.csv
213+
output_dir: results
214+
pipeline_interfaces:
215+
- pipeline/pipeline_interface.yaml
216+
EOF
217+
```
168218

169219
Right now, this file is basically just 3 pointers.
170220
The first line points to the metadata table we just created.
@@ -196,7 +246,7 @@ For example, here are some looper arguments:
196246
In the upcoming tutorials, we'll cover these and other features in more detail.
197247

198248
!!! tip "Summary"
199-
- To use looper, you'll need to have data, metadata, a pipeline (with pipeline interface), and a looper configuration file.
200-
- Looper is best suited for data that is split into samples, where you're trying to run a pipeline independently on each sample.
201-
- Once you've configured everything correctly, you run your samples with the command `looper run`.
249+
- To use looper, you'll create a looper configuration file which points to: 1. data, 2. metadata, and 3. a pipeline with pipeline interface.
250+
- Looper is best suited for data that is split into samples or jobs, where you're trying to run a pipeline independently on each sample.
251+
- Once you've configured looper, you run jobs with the command `looper run`.
202252

mkdocs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ theme:
2929
- navigation.sections
3030
# - navigation.expand
3131
- navigation.footer
32-
- navigation.indexes
32+
- navigation.indexes
3333
- toc.follow
3434
- content.action.edit
3535
- content.action.view
36+
- content.code.copy
3637
- navigation.tabs
3738
- navigation.top
3839

@@ -42,6 +43,8 @@ markdown_extensions:
4243
- admonition
4344
- pymdownx.details
4445
- pymdownx.superfences
46+
- pymdownx.tabbed:
47+
alternate_style: true
4548
- pymdownx.highlight:
4649
use_pygments: true
4750
# - pymdownx.emoji:

0 commit comments

Comments
 (0)