-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Config for otu_processing workflows
- Loading branch information
1 parent
8f58904
commit 6901f16
Showing
14 changed files
with
155 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// -*- mode: groovy -*- | ||
|
||
/* | ||
* Reference for useful snippets: | ||
publishDir "${params.output_dir}/${f[0]}/${f[1]}/${f[2]}/${meta.id}", | ||
saveAs: { filename -> filename.split("/")[1] }, | ||
mode: 'copy', | ||
overwrite: true | ||
String task_process = "${task.process}" | ||
f = getHierarchy(task_process) | ||
*/ | ||
|
||
params { | ||
otu_processing { | ||
export { | ||
'biom2tsv' {} | ||
} | ||
transform { | ||
'group' { | ||
tax_levels = ['Phylum', 'Class', 'Order', 'Family', 'Genus', 'Species'] | ||
} | ||
// NOTE: Set to "False" to disable filtering | ||
// NOTE: Set axis to "None" to disable normalization | ||
'normalize' { | ||
axis = "sample" | ||
count_thres = 500 | ||
prevalence_thres = 0.05 | ||
abundance_thres = 0.01 | ||
rm_sparse_obs = "True" | ||
rm_sparse_samples = "True" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
micone/pipelines/modules/otu_processing/export/biom2tsv.nf
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,15 @@ | ||
process biom2tsv { | ||
label 'micone' | ||
tag "${meta.id}" | ||
publishDir "${params.output_dir}/${f[0]}/${f[1]}/${f[2]}/${meta.id}", | ||
mode: 'copy', | ||
overwrite: true | ||
input: | ||
tuple val(meta), val(tax_level), file(otu_file), file(children_file) | ||
output: | ||
tuple val(meta), file("*_otu.tsv"), file("*_obs_metadata.csv"), file("*_sample_metadata.tsv"), file(children_file) | ||
script: | ||
String task_process = "${task.process}" | ||
f = getHierarchy(task_process) | ||
template 'otu_processing/export/biom2tsv.py' | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
micone/pipelines/modules/otu_processing/otu_processing_workflow.nf
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,24 @@ | ||
// Main variables to be defined | ||
// NOTE: These should be defined before any include statements | ||
|
||
|
||
// Sequencing processing imports | ||
include { group } from './transform/group.nf' | ||
include { normalize} from './transform/normalize.nf' | ||
include { biom2tsv } from './export/biom2tsv.nf' | ||
|
||
// Main workflow | ||
workflow denoise_cluster_workflow { | ||
take: | ||
// tuple val(id), file(otu_file) | ||
input_channel | ||
main: | ||
input_channel \ | ||
| normalize \ | ||
| group \ | ||
| export \ | ||
emit: | ||
// all processes have publishDir | ||
// tuple val(meta), file("*_otu.tsv"), file("*_obs_metadata.csv"), file("*_sample_metadata.tsv"), file(children_file) | ||
export.out | ||
} |
16 changes: 16 additions & 0 deletions
16
micone/pipelines/modules/otu_processing/transform/group.nf
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,16 @@ | ||
process group { | ||
label 'micone' | ||
tag "${meta.id}" | ||
publishDir "${params.output_dir}/${f[0]}/${f[1]}/${f[2]}/${meta.id}", | ||
mode: 'copy', | ||
overwrite: true | ||
input: | ||
tuple val(meta), file(otu_file) | ||
each tax_level from params.otu_processing.transform['group']['tax_levels'] | ||
output: | ||
tuple val(meta), val(tax_level), file("*.biom"), file("*.json") | ||
script: | ||
String task_process = "${task.process}" | ||
f = getHierarchy(task_process) | ||
template 'otu_processing/transform/group.py' | ||
} |
21 changes: 21 additions & 0 deletions
21
micone/pipelines/modules/otu_processing/transform/normalize.nf
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,21 @@ | ||
process normalize { | ||
label 'micone' | ||
tag "${meta.id}" | ||
publishDir "${params.output_dir}/${f[0]}/${f[1]}/${f[2]}/${meta.id}", | ||
mode: 'copy', | ||
overwrite: true | ||
input: | ||
tuple val(meta), file(otu_file) | ||
output: | ||
tuple val(meta), file("*_normalized.biom") | ||
script: | ||
String task_process = "${task.process}" | ||
f = getHierarchy(task_process) | ||
axis = params.otu_processing.transform['normalize']['axis'] | ||
count_thres = params.otu_processing.transform['normalize']['count_thres'] | ||
prevalence_thres = params.otu_processing.transform['normalize']['prevalence_thres'] | ||
abundance_thres = params.otu_processing.transform['normalize']['abundance_thres'] | ||
rm_sparse_obs = params.otu_processing.transform['normalize']['rm_sparse_obs'] | ||
rm_sparse_samples = params.otu_processing.transform['normalize']['rm_sparse_samples'] | ||
template 'otu_processing/transform/normalize.py' | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
micone/pipelines/templates/otu_processing/transform/group.py
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,25 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Script that groups OTU data on different taxa levels | ||
|
||
import json | ||
from typing import Tuple | ||
|
||
from micone import Otu | ||
|
||
|
||
# Group the otu_data on all the tax_levels | ||
def grp_otu_data(otu_data: Otu, tax_level: str) -> Tuple[Otu, dict]: | ||
child_otu, child_groups = otu_data.collapse_taxa(tax_level) | ||
return child_otu, child_groups | ||
|
||
|
||
if __name__ == "__main__": | ||
TAX_LEVEL: str = "${tax_level}" # ['Family', 'Genus', 'Species'] | ||
OTU_FILE = "${otu_file}" # "otu.biom" | ||
OTU_DATA = Otu.load_data(OTU_FILE) | ||
child_otu, child_groups = grp_otu_data(OTU_DATA, TAX_LEVEL) | ||
fname = child_otu.tax_level + "_level" | ||
child_otu.write(fname, file_type="biom") | ||
with open(fname + "_children.json", "w") as fid: | ||
json.dump(child_groups, fid, indent=2, sort_keys=True) |
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