Skip to content

Commit e92cadd

Browse files
committed
Adding tutorials
0 parents  commit e92cadd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+81956
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.cache
3+
.idea
4+
serve
5+
nextflow
6+
work
7+
.nextflow*
8+
nf-training/results
9+
transcript-index
10+
.vscode

README.md

Whitespace-only changes.

bin/fastqc.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
set -u
4+
5+
sample_id=${1}
6+
reads=${2}
7+
8+
mkdir fastqc_${sample_id}_logs
9+
fastqc -o fastqc_${sample_id}_logs -f fastq -q ${reads}

closure.nf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
square = { num -> num * num }
2+
3+
x = [ 1, 2, 3, 4 ].collect(square)
4+
println x
5+
6+
printMap = { a, b -> println "$a with value $b" }
7+
values = [ "Yue" : "Wu", "Mark" : "Williams", "Sudha" : "Kumari" ]
8+
values.each(printMap)

conditional_compress.nf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
params.compress = 'gzip'
2+
params.file2compress = "$baseDir/data/ggal/transcriptome.fa"
3+
4+
process FOO {
5+
6+
input:
7+
path file
8+
9+
script:
10+
if( params.compress == 'gzip' )
11+
"""
12+
gzip -c $file > ${file}.gz
13+
"""
14+
else if( params.compress == 'bzip2' )
15+
"""
16+
bzip2 -c $file > ${file}.bz2
17+
"""
18+
else
19+
throw new IllegalArgumentException("Unknown aligner $params.compress")
20+
}
21+
22+
workflow {
23+
FOO(params.file2compress)
24+
}

dag.png

47.1 KB
Loading

data/ggal/gut_1.fq

Lines changed: 11748 additions & 0 deletions
Large diffs are not rendered by default.

data/ggal/gut_2.fq

Lines changed: 11748 additions & 0 deletions
Large diffs are not rendered by default.

data/ggal/liver_1.fq

Lines changed: 11748 additions & 0 deletions
Large diffs are not rendered by default.

data/ggal/liver_2.fq

Lines changed: 11748 additions & 0 deletions
Large diffs are not rendered by default.

data/ggal/lung_1.fq

Lines changed: 11748 additions & 0 deletions
Large diffs are not rendered by default.

data/ggal/lung_2.fq

Lines changed: 11748 additions & 0 deletions
Large diffs are not rendered by default.

data/ggal/transcriptome.fa

Lines changed: 2852 additions & 0 deletions
Large diffs are not rendered by default.

data/meta/random.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
2+
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
3+
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
4+
It has survived not only five centuries, but also the leap into electronic typesetting,
5+
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
6+
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like
7+
Aldus PageMaker including versions of Lorem Ipsum

environment.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: nf-tutorial
2+
channels:
3+
- conda-forge
4+
- defaults
5+
- bioconda
6+
dependencies:
7+
- bioconda::salmon=1.5.1
8+
- bioconda::fastqc=0.11.9
9+
- bioconda::multiqc=1.12
10+
- conda-forge::tbb=2020.2

example.nf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ch1 = Channel.of(1,2,3)
2+
ch2 = Channel.of(1)
3+
4+
process SUM {
5+
input:
6+
val x
7+
val y
8+
9+
output:
10+
stdout
11+
12+
script:
13+
"""
14+
echo \$(($x+$y))
15+
"""
16+
}
17+
18+
workflow {
19+
SUM(ch1,ch2.first()).view()
20+
21+
Channel.fromPath( './data/ggal/**.fq' , hidden:true)
22+
.view()
23+
24+
Channel
25+
.fromFilePairs('./data/ggal/*_{1,2}.fq')
26+
.view()
27+
28+
Channel
29+
.fromPath('data/meta/random.txt')
30+
.splitText( by: 2 ) { it.toUpperCase() }
31+
.view()
32+
}

foo.nf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
process foo {
2+
echo true
3+
'''
4+
env | egrep 'ALPHA|BETA'
5+
'''
6+
}

groovy.nf

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
println "Hello, World!"
2+
3+
// comment a single config file
4+
5+
/*
6+
a comment spanning
7+
multiple lines
8+
*/
9+
10+
x = 1
11+
println x
12+
13+
x = new java.util.Date()
14+
println x
15+
16+
x = -3.1499392
17+
println x
18+
19+
x = false
20+
println x
21+
22+
x = "Hi"
23+
println x
24+
25+
26+
27+
def x = 'foo'
28+
29+
30+
list = [10,20,30,40]
31+
println list[0]
32+
println list.get(0)
33+
println list.size()
34+
35+
36+
37+
map = [a:0, b:1, c:2]
38+
map['a'] = 'x'
39+
map.b = 'y'
40+
map.put('c', 'z')
41+
assert map == [a:'x', b:'y', c:'z']
42+
43+
44+
45+
foxtype = 'quick'
46+
foxcolor = ['b', 'r', 'o', 'w', 'n']
47+
println "The $foxtype ${foxcolor.join()} fox"
48+
49+
x = 'Hello'
50+
println '$x + $y'
51+
52+
text = """
53+
Hello there James.
54+
How are you today?
55+
"""
56+
println text
57+
58+
59+
60+
61+
list = [1,2,3]
62+
if( list != null && list.size() > 0 ) {
63+
println list
64+
}
65+
else {
66+
println 'The list is empty'
67+
}
68+
69+
70+
71+
list = ['a','b','c']
72+
73+
for( String elem : list ) {
74+
println elem
75+
}
76+
77+
78+
79+
int fib(int n) {
80+
return n < 2 ? 1 : fib(n-1) + fib(n-2)
81+
}
82+
83+
assert fib(10)==89
84+

hello.nf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env nextflow
2+
3+
params.greeting = 'Hello'
4+
greeting_ch = Channel.of(params.greeting)
5+
6+
process SPLITLETTERS {
7+
input:
8+
val x
9+
10+
output:
11+
path 'test_*'
12+
13+
"""
14+
printf '$x' | split -b 6 - test_
15+
"""
16+
}
17+
18+
process CONVERTTOUPPER {
19+
input:
20+
path y
21+
22+
output:
23+
stdout
24+
25+
"""
26+
rev $y
27+
"""
28+
}
29+
30+
workflow {
31+
letters_ch = SPLITLETTERS(greeting_ch)
32+
results_ch = CONVERTTOUPPER(letters_ch.flatten())
33+
results_ch.view{ it }
34+
}

modules/hello.nf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env nextflow
2+
3+
params.greeting = 'Hello world!'
4+
greeting_ch = Channel.of(params.greeting)
5+
6+
include { SPLITLETTERS } from './modules.nf'
7+
include { CONVERTTOUPPER } from './modules.nf'
8+
9+
workflow {
10+
letters_ch = SPLITLETTERS(greeting_ch)
11+
results_ch = CONVERTTOUPPER(letters_ch.flatten())
12+
results_ch.view{ it }
13+
}

modules/hello2.nf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env nextflow
2+
3+
params.greeting = 'Hello world!'
4+
greeting_ch = Channel.of(params.greeting)
5+
6+
include { SPLITLETTERS as SPLITLETTERS_one } from './modules.nf'
7+
include { SPLITLETTERS as SPLITLETTERS_two } from './modules.nf'
8+
9+
include { CONVERTTOUPPER as CONVERTTOUPPER_one } from './modules.nf'
10+
include { CONVERTTOUPPER as CONVERTTOUPPER_two } from './modules.nf'
11+
12+
workflow {
13+
letters_ch1 = SPLITLETTERS_one(greeting_ch)
14+
results_ch1 = CONVERTTOUPPER_one(letters_ch1.flatten())
15+
results_ch1.view{ it }
16+
17+
letters_ch2 = SPLITLETTERS_two(greeting_ch)
18+
results_ch2 = CONVERTTOUPPER_two(letters_ch2.flatten())
19+
results_ch2.view{ it }
20+
}

modules/modules.nf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
process SPLITLETTERS {
2+
3+
input:
4+
val x
5+
6+
output:
7+
path 'chunk_*'
8+
9+
"""
10+
printf '$x' | split -b 6 - chunk_
11+
"""
12+
}
13+
14+
process CONVERTTOUPPER {
15+
16+
input:
17+
path y
18+
19+
output:
20+
stdout
21+
22+
"""
23+
cat $y | tr '[a-z]' '[A-Z]'
24+
"""
25+
}

modules/piped_workflow.nf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env nextflow
2+
3+
params.greeting = 'Hello world!'
4+
5+
include { SPLITLETTERS as SL; CONVERTTOUPPER } from './modules.nf'
6+
7+
workflow my_pipeline {
8+
Channel.of(params.greeting) | SL | flatten() | CONVERTTOUPPER | view
9+
}
10+
11+
workflow {
12+
my_pipeline()
13+
}

my-env.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
env.ALPHA = 'some value'
2+
env.BETA = "$HOME/some/path"

nextflow.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
process.container = 'nextflow/rnaseq-nf'
2+
docker.runOptions = '-u $(id -u):$(id -g)'
3+
docker.enabled = true
4+
propertyOne = 'world'
5+
anotherProp = "Hello $propertyOne"
6+
7+
params.greeting = "bonjour"
8+
9+

operators.nf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Channel
2+
.of(1,2,3,4)
3+
.map { it -> it * it }
4+
.mix(Channel.of( 1,2,3 ))
5+
.collect()
6+
.flatten()
7+
.view { "- $it" }
8+
9+
left = Channel.of(['X', 1], ['Y', 2], ['Z', 3], ['P', 7])
10+
right = Channel.of(['Z', 6], ['Y', 5], ['X', 4])
11+
left.join(right).view()
12+
13+
Channel
14+
.of( [1,'A'], [1,'B'], [2,'C'], [3, 'B'], [1,'C'], [2, 'A'], [3, 'D'] )
15+
.groupTuple()
16+
.view()
17+
18+
Channel
19+
.of(1,2,3,40,50)
20+
.branch {
21+
small: it < 10
22+
large: it > 10
23+
}
24+
.set { result }
25+
26+
result.small.view { "$it is small" }
27+
result.large.view { "$it is large" }

report-20230820-58158878.html

Lines changed: 1047 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)