-
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: merge_pvalues and create_consensus modules
- Loading branch information
1 parent
5bfa231
commit 1a7ef3b
Showing
6 changed files
with
118 additions
and
2 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
22 changes: 22 additions & 0 deletions
22
micone/pipelines/modules/network_inference/network/create_consensus.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,22 @@ | ||
include { getHierarchy } from '../../../functions/functions.nf' | ||
|
||
process create_consensus { | ||
label 'micone' | ||
tag "${meta.id}" | ||
publishDir "${params.output_dir}/${f[0]}/network/${f[1]}/${directory}/${meta.id}", | ||
mode: 'copy', | ||
overwrite: true | ||
input: | ||
tuple val(meta), file('*_network.json') | ||
output: | ||
tuple val(meta), file('*_network.json') | ||
script: | ||
String task_process = "${task.process}" | ||
f = getHierarchy(task_process) | ||
directory = "${meta.denoise_cluster}-${meta.chimera_checking}-${meta.tax_assignment}-${meta.tax_level}-${meta.network_inference}" | ||
method = params.network_inference.network['create_consensus']['method'] | ||
parameter = params.network_inference.network['create_consensus']['parameter'] | ||
pvalue_filter = params.network_inference.network['create_consensus']['pvalue_filter'] | ||
interaction_filter = params.network_inference.network['create_consensus']['interaction_filter'] | ||
template 'network_inference/network/create_consensus.py' | ||
} |
18 changes: 18 additions & 0 deletions
18
micone/pipelines/modules/network_inference/network/merge_pvalues.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,18 @@ | ||
include { getHierarchy } from '../../../functions/functions.nf' | ||
|
||
process merge_pvalues { | ||
label 'micone' | ||
tag "${meta.id}" | ||
publishDir "${params.output_dir}/${f[0]}/network/${f[1]}/${directory}/${meta.id}", | ||
mode: 'copy', | ||
overwrite: true | ||
input: | ||
tuple val(meta), file('*_network.json') | ||
output: | ||
tuple val(meta), file('*_network.json') | ||
script: | ||
String task_process = "${task.process}" | ||
f = getHierarchy(task_process) | ||
directory = "${meta.denoise_cluster}-${meta.chimera_checking}-${meta.tax_assignment}-${meta.tax_level}-${meta.network_inference}" | ||
template 'network_inference/network/merge_pvalues.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
38 changes: 38 additions & 0 deletions
38
micone/pipelines/templates/network_inference/network/create_consensus.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,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pathlib | ||
from typing import List | ||
|
||
from micone import Network, NetworkGroup | ||
|
||
|
||
def main( | ||
base_name: str, | ||
network_files: List[pathlib.Path], | ||
method: str, | ||
parameter: float, | ||
pvalue_filter: bool, | ||
interaction_filter: bool, | ||
) -> None: | ||
networks: List[Network] = [] | ||
for network_file in network_files: | ||
networks.append(Network.load_json(str(network_file))) | ||
network_group = NetworkGroup(networks) | ||
cids = [ctx["cid"] for ctx in network_group.contexts] | ||
filtered_network_group = network_group.filter( | ||
pvalue_filter=pvalue_filter, interaction_filter=interaction_filter | ||
) | ||
consensus_network_group = filtered_network_group.get_consensus_network( | ||
cids, method=method, parameter=parameter | ||
) | ||
consensus_network_group.write(base_name + "_network.json") | ||
|
||
|
||
if __name__ == "__main__": | ||
BASE_NAME = "${meta.id}" | ||
METHOD = "${method}" | ||
PARAMETER = float("${parameter}") | ||
PVALUE_FILTER = True if "${pvalue_filter}" == "true" else False | ||
INTERACTION_FILTER = True if "${interaction_filter}" == "true" else False | ||
NETWORK_FILES = list(pathlib.Path().glob("*.json")) | ||
main(BASE_NAME, NETWORK_FILES, METHOD, PARAMETER, PVALUE_FILTER, INTERACTION_FILTER) |
22 changes: 22 additions & 0 deletions
22
micone/pipelines/templates/network_inference/network/merge_pvalues.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,22 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pathlib | ||
from typing import List | ||
|
||
from micone import Network, NetworkGroup | ||
|
||
|
||
def main(base_name: str, network_files: List[pathlib.Path]) -> None: | ||
networks: List[Network] = [] | ||
for network_file in network_files: | ||
networks.append(Network.load_json(str(network_file))) | ||
network_group = NetworkGroup(networks) | ||
cids = [ctx["cid"] for ctx in network_group.contexts] | ||
merged_network_group = network_group.combine_pvalues(cids) | ||
merged_network_group.write(base_name + "_network.json", split_files=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
BASE_NAME = "${meta.id}" | ||
NETWORK_FILES = list(pathlib.Path().glob("*.json")) | ||
main(BASE_NAME, NETWORK_FILES) |