-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcross_species_integration_multiple_species.nf
261 lines (182 loc) · 8.02 KB
/
cross_species_integration_multiple_species.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
// © EMBL-European Bioinformatics Institute, 2023
// Updated upon containerization of BENGAL envs
// Yuyao Song <[email protected]>
// Oct 2023
log.info """
===========================================================
Cross-species integration and assessment - nextflow pipeline
- Integrate scRNA-seq data from multiple species - this workflow
- SCCAF projection on integrated data to assess integration quality
- harmony, scanorama, scVI - python based
- Seurat CCA, Seurat RPCA, fastMNN, LIGER, LIGER-UINMF - r based
Author: [email protected]
Mar 2022
===========================================================
"""
.stripIndent()
process harmony_integration {
label 'scanpy_based'
label 'regular_intg_resource'
publishDir "${params.results}/results/harmony/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_harmony_integrated.h5ad", emit: harmony_cross_species_h5ad_ch
path "${baseName}_harmony_integrated_UMAP.png", emit: harmony_cross_species_umap_ch
script:
"""
python ${projectDir}/bin/harmony_integration.py \
--batch_key ${params.batch_key} --species_key ${params.species_key} --cluster_key ${params.cluster_key} \
${file} ${baseName}_harmony_integrated.h5ad ${baseName}_harmony_integrated_UMAP.png
"""
}
process scanorama_integration {
label 'scanpy_based'
label 'regular_intg_resource'
publishDir "${params.results}/results/scanorama/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_scanorama_integrated.h5ad", emit: scanorama_cross_species_h5ad_ch
path "${baseName}_scanorama_integrated_UMAP.png", emit: scanorama_cross_species_umap_ch
script:
"""
python ${projectDir}/bin/scanorama_integration.py \
--batch_key ${params.batch_key} --species_key ${params.species_key} --cluster_key ${params.cluster_key} \
${file} ${baseName}_scanorama_integrated.h5ad ${baseName}_scanorama_integrated_UMAP.png
"""
}
// scVI uses GPU
process scvi_integration {
label 'scvi_based'
label 'GPU_intg_resource'
publishDir "${params.results}/results/scVI/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_scVI_integrated.h5ad", emit: scvi_cross_species_h5ad_ch
path "${baseName}_scVI_integrated_UMAP.png", emit: scvi_cross_species_umap_ch
script:
"""
python ${projectDir}/bin/scvi_integration.py \
--batch_key ${params.batch_key} --species_key ${params.species_key} --cluster_key ${params.cluster_key} \
${file} ${baseName}_scVI_integrated.h5ad ${baseName}_scVI_integrated_UMAP.png
"""
}
// scANVI uses GPU
process scanvi_integration {
label 'scvi_based'
label 'GPU_intg_resource'
publishDir "${params.results}/results/scANVI/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_scANVI_integrated.h5ad", emit: scanvi_cross_species_h5ad_ch
path "${baseName}_scANVI_integrated_UMAP.png", emit: scanvi_cross_species_umap_ch
script:
"""
python ${projectDir}/bin/scANVI_integration.py \
--batch_key ${params.batch_key} --species_key ${params.species_key} --cluster_key ${params.cluster_key} \
${file} ${baseName}_scANVI_integrated.h5ad ${baseName}_scANVI_integrated_UMAP.png ${baseName}_scANVI_integrated_mde.png
"""
}
process seurat_CCA_integration{
label 'seurat_based'
label 'bigmem_intg_resource'
publishDir "${params.results}/results/seuratCCA/cross_species/integrated_h5ad/", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_seuratCCA_integrated.rds", emit: seuratCCA_cross_species_rds_ch
path "${baseName}_seuratCCA_integrated_UMAP.pdf" , emit: seuratCCA_cross_species_umap_ch
script:
"""
Rscript ${projectDir}/bin/seurat_CCA_integration.R -i ${file} -o ${baseName}_seuratCCA_integrated.rds -p ${baseName}_seuratCCA_integrated_UMAP.pdf -b ${params.batch_key} -s ${params.species_key} -c ${params.cluster_key}
"""
}
process seurat_RPCA_integration{
label 'seurat_based'
label 'bigmem_intg_resource'
publishDir "${params.results}/results/seuratRPCA/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_seuratRPCA_integrated.rds" , emit: seuratRPCA_cross_species_rds_ch
path "${baseName}_seuratRPCA_integrated_UMAP.pdf" , emit: seuratRPCA_cross_species_umap_ch
script:
"""
Rscript ${projectDir}/bin/seurat_RPCA_integration.R -i ${file} -o ${baseName}_seuratRPCA_integrated.rds -p ${baseName}_seuratRPCA_integrated_UMAP.pdf -b ${params.batch_key} -s ${params.species_key} -c ${params.cluster_key}
"""
}
process fastMNN_integration{
label 'R_based'
label 'regular_intg_resource'
publishDir "${params.results}/results/fastMNN/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_fastMNN_integrated.rds" , emit: fastMNN_cross_species_rds_ch
path "${baseName}_fastMNN_integrated_UMAP.pdf" , emit: fastMNN_cross_species_UMAP_ch
script:
"""
Rscript ${projectDir}/bin/fastMNN_integration.R -i ${file} -o ${baseName}_fastMNN_integrated.rds -p ${baseName}_fastMNN_integrated_UMAP.pdf -b ${params.batch_key} -s ${params.species_key} -c ${params.cluster_key}
"""
}
process liger_integration{
label 'R_based'
label 'regular_intg_resource'
publishDir "${params.results}/results/LIGER/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(file)
output:
path "${baseName}_LIGER_integrated.rds", emit: liger_cross_species_rds_ch
path "${baseName}_LIGER_integrated_UMAP.pdf", emit: liger_cross_species_UMAP_ch
script:
"""
Rscript ${projectDir}/bin/LIGER_integration.R -i ${file} -o ${baseName}_LIGER_integrated.rds -p ${baseName}_LIGER_integrated_UMAP.pdf -b ${params.batch_key} -s ${params.species_key} -c ${params.cluster_key}
"""
}
process rligerUINMF_integration{
label 'R_based'
label 'regular_intg_resource'
publishDir "${params.results}/results/rligerUINMF/cross_species/integrated_h5ad", mode: 'copy'
input:
tuple val(baseName), path(metadata)
output:
path "*_rligerUINMF_integrated.rds"
path "*_rligerUINMF_integrated_UMAP.pdf"
script:
"""
mkdir -p ${params.results}/results/rligerUINMF/cross_species/integrated_h5ad && \
Rscript ${projectDir}/bin/rliger_integration_UINMF_multiple_species.R \
--basename ${baseName} \
--metadata ${params.liger_metadata} \
--out_dir . \
--cluster_key ${params.cluster_key}
"""
}
// nextflow will search for the output file in the cwd
// so set the out_dir in the script to cwd, then nextflow will copy the results to the publishDir anyway
workflow {
all_homology_h5ad_mapped_ch = Channel.fromPath(params.homology_concat_h5ad)
.map { file -> tuple(file.baseName, file) }
all_homology_rds_mapped_ch = Channel.fromPath(params.homology_concat_rds)
.map { file -> tuple(file.baseName, file) }
concatenated_h5ad = all_homology_h5ad_mapped_ch
concatenated_h5ad.view()
harmony_integration(concatenated_h5ad)
scanorama_integration(concatenated_h5ad)
scvi_integration(concatenated_h5ad)
scanvi_integration(concatenated_h5ad)
concatenated_rds = all_homology_rds_mapped_ch
seurat_CCA_integration(concatenated_rds)
seurat_RPCA_integration(concatenated_rds)
fastMNN_integration(concatenated_rds)
liger_integration(concatenated_rds)
liger_metadata = Channel.fromPath(params.liger_metadata)
.map { file -> tuple(file.baseName, file) }
liger_metadata.view()
rligerUINMF_integration(liger_metadata)
}