forked from porchard/2021-03-sn-muscle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-quality-nuclei-count-files.nf
181 lines (129 loc) · 4.25 KB
/
make-quality-nuclei-count-files.nf
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env nextflow
STARSOLO_DIR_GLOB = params.starsolo_dir_glob
ATAC_GENE_COUNT_FILE_GLOB = params.atac_gene_count_glob
NUCLEI = params.nuclei
individual_assignments = params.individual_assignments
HUMAN_ATAC_COUNTS = Channel.fromPath(ATAC_GENE_COUNT_FILE_GLOB).filter({it -> it.getName().contains('hg19')})
RAT_ATAC_COUNTS = Channel.fromPath(ATAC_GENE_COUNT_FILE_GLOB).filter({it -> it.getName().contains('rn6')})
process get_atac_gene_counts {
publishDir "${params.results}/atac"
memory '20 GB'
cache 'deep'
input:
file(nuclei) from Channel.fromPath(NUCLEI)
each file(counts) from Channel.fromPath(ATAC_GENE_COUNT_FILE_GLOB)
output:
file("${library}.hdf5") into liger_atac_in
file("${library}.hdf5") into liger_atac_in_2
script:
library = counts.getName().replaceAll('.counts.txt', '')
"""
grep -w $library $nuclei | cut -f2 > keep-barcodes.txt
atac-gene-counts-to-hdf5.py $counts keep-barcodes.txt ${library}.hdf5
"""
}
process get_rna_gene_counts {
publishDir "${params.results}/rna"
memory '20 GB'
cache 'deep'
input:
file(nuclei) from Channel.fromPath(NUCLEI)
each file(starsolo) from Channel.fromPath(STARSOLO_DIR_GLOB, type: 'dir')
output:
set val(library), file("${library}.hdf5") into seurat_in
set val(library), file("${library}.hdf5") into seurat_in_2
set val(library), file("${library}.hdf5") into decontx_in
script:
library = starsolo.getName()
"""
grep -w $library $nuclei | cut -f2 > keep-barcodes.txt
starsolo-counts-to-hdf5-gene-name.py ${starsolo}/Solo.out/GeneFull/raw/matrix.mtx ${starsolo}/Solo.out/GeneFull/raw/barcodes.tsv ${starsolo}/Solo.out/GeneFull/raw/features.tsv keep-barcodes.txt ${library} ${library}.hdf5
"""
}
human_seurat_in = seurat_in.filter({it -> it[0].contains('hg19')}).map({it -> it[1]})
rat_seurat_in = seurat_in_2.filter({it -> it[0].contains('rn6')}).map({it -> it[1]})
process seurat {
publishDir "${params.results}/seurat/hg19"
container "${params.containers.seuratv4}"
memory '50 GB'
cache 'deep'
input:
file(x) from human_seurat_in.toSortedList()
output:
set file('clusters.txt'), file('umap.txt') into decontx_clusters
file("*.png")
"""
run-seurat-by-individual.R $individual_assignments '*.hdf5'
"""
}
process seurat_rat {
publishDir "${params.results}/seurat/rn6"
container "${params.containers.seuratv4}"
memory '50 GB'
cache 'deep'
input:
file(x) from rat_seurat_in.toSortedList()
output:
set file('clusters.txt'), file('umap.txt') into decontx_clusters_rat
file("*.png")
"""
run-seurat-rat.R $individual_assignments '*.hdf5'
"""
}
human_decontx_in = Channel.create()
rat_decontx_in = Channel.create()
decontx_in.choice(human_decontx_in, rat_decontx_in) { it -> it[0].contains('hg19') ? 0 : 1}
process decontX {
publishDir "${params.results}/decontX"
container "${params.containers.decontX}"
memory '20 GB'
cache 'deep'
input:
set val(library), file(uncorrected), file(clusters), file(umap) from human_decontx_in.combine(decontx_clusters).mix(rat_decontx_in.combine(decontx_clusters_rat))
output:
set val(library), file("${library}.decontaminated-counts-rounded.txt") into decontx_out
file("*.png")
file("*.txt")
"""
decontX.R $uncorrected $clusters $umap ${library}.
"""
}
process make_corrected_hdf5 {
publishDir "${params.results}/rna-corrected"
memory '40 GB'
cache 'deep'
input:
set val(library), file(txt) from decontx_out
output:
file("${library}.hdf5") into liger_rna_in
file("${library}.hdf5") into liger_rna_in_2
"""
tsv-to-hd5.py $txt ${library}.hdf5 ${library} nucleus
"""
}
process make_liger_in {
publishDir "${params.results}/liger-in"
memory '150 GB'
input:
file(rna) from liger_rna_in.toSortedList()
file(atac) from liger_atac_in.toSortedList()
file(x) from Channel.fromPath(individual_assignments)
output:
file("*.hdf5")
"""
make-liger-in.py --individuals $x --rna ${rna.join(' ')} --atac ${atac.join(' ')}
"""
}
process make_liger_in_by_species_and_modality {
publishDir "${params.results}/liger-in-by-species-and-modality"
memory '150 GB'
input:
file(rna) from liger_rna_in_2.toSortedList()
file(atac) from liger_atac_in_2.toSortedList()
file(x) from Channel.fromPath(individual_assignments)
output:
file("*.hdf5")
"""
make-liger-in-merge-samples.py --individuals $x --rna ${rna.join(' ')} --atac ${atac.join(' ')}
"""
}