-
Notifications
You must be signed in to change notification settings - Fork 6
Node degree distribution #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
af736f2
failing yaml version of network degree distribution plot
48800ba
outsourced networkdegree distribution to separte script for formatting
29fc4c8
removed unused file
454e7c8
pre-commit linting
219bb57
changed calculation of node degrees to be handled in graphtools parser
Schansiate 594ddf9
removed debug print and import from visualize_modules.py
3c9611e
formatting
f8c531e
updated dependency container
2b7504d
added node_degree anonotations to the output documentation
f6caf8b
fix: use correct Nextflow publishDir saveAs key
Copilot 1b14dab
added parent id to network_node_degree_distribution_header
479c513
Merge branch 'dev' into node_degree_distribution
JohannesKersting 8dfa936
fixed multiqc_formatter not generating outputfile
Schansiate d417671
updated test snap
JohannesKersting 5a34365
linting
JohannesKersting df9e7d8
formatting
JohannesKersting 3827cbd
moved multiqcformatter down to have it listed directly before multiqc
JohannesKersting 5bde6c8
changed fraction to percentage
JohannesKersting 4b0d264
adjusted multiqc header
JohannesKersting 19816d7
updated test snap
JohannesKersting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 contains hidden or 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 @@ | ||
| id: network_node_degree_distribution | ||
| parent_name: Input | ||
| section_name: network node degree distribution | ||
| description: node degree distributions of the network. | ||
| plot_type: linegraph | ||
| pconfig: | ||
| id: network_node_degree_distribution_line_graph | ||
| title: Node Degree Distribution | ||
| xlab: Node Degree | ||
| ylab: Relative Frequency | ||
| data_labels: | ||
| - name: Counts | ||
| ylab: Counts | ||
| - name: Percentages | ||
| ylab: Percentage | ||
| data: | ||
This file contains hidden or 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 contains hidden or 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,63 @@ | ||
| #!/usr/bin/env python | ||
| import argparse | ||
| from pathlib import Path | ||
| import yaml | ||
| import sys | ||
|
|
||
|
|
||
| def parse_args(argv=None): | ||
| parser = argparse.ArgumentParser( | ||
| description="formats file for multiqc custom contents", | ||
| epilog="Example: python multiqc_formatter.py -i network.gt -f network_degree", | ||
| ) | ||
| parser.add_argument( | ||
| "-i", "--input", type=Path, nargs="*", required=True, help="Input files" | ||
| ) | ||
| parser.add_argument("-H", "--header", type=Path, required=True, help="Header file") | ||
| return parser.parse_args(argv) | ||
|
|
||
|
|
||
| def parse_input(input_files, header_file): | ||
| with open(header_file, "r") as header: | ||
| header_id = header.readline().split(":", 1)[1].strip() | ||
|
|
||
| if header_id == "network_node_degree_distribution": | ||
| save_node_degree_distribution(input_files, header_file) | ||
|
|
||
|
|
||
| def save_node_degree_distribution(input_files, header_file): | ||
| with open(header_file, "r", encoding="utf-8") as header: | ||
| mqc_payload = yaml.safe_load(header) or {} | ||
|
|
||
| absolute_data = {} | ||
| relative_data = {} | ||
|
|
||
| for file in input_files: | ||
| with open(file, "r", encoding="utf-8") as distribution_file: | ||
| distribution = yaml.safe_load(distribution_file) or {} | ||
|
|
||
| network_name = distribution.get("name") or file.stem | ||
| absolute = distribution.get("absolute") | ||
| relative = distribution.get("relative") | ||
|
|
||
| if absolute is None or relative is None: | ||
| raise ValueError( | ||
| f"Invalid distribution YAML in {file}: expected keys 'absolute' and 'relative'" | ||
| ) | ||
|
|
||
| absolute_data[network_name] = absolute | ||
| relative_data[network_name] = relative | ||
|
|
||
| mqc_payload["data"] = [absolute_data, relative_data] | ||
|
|
||
| with open("./node_degree_distribution_mqc.yaml", "w", encoding="utf-8") as file: | ||
| yaml.safe_dump(mqc_payload, file, sort_keys=False, default_flow_style=None) | ||
|
|
||
|
|
||
| def main(): | ||
| args = parse_args() | ||
| parse_input(args.input, args.header) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
This file contains hidden or 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 contains hidden or 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 contains hidden or 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 contains hidden or 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 contains hidden or 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 MULTIQCFORMATTER { | ||
| label 'process_single' | ||
|
JohannesKersting marked this conversation as resolved.
|
||
| input: | ||
| tuple path(header), path(inputFiles) | ||
| output: | ||
| path("*mqc*"), emit : multiqc | ||
| path "versions.yml" , emit: versions | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
| script: | ||
| """ | ||
| multiqc_formatter.py -i $inputFiles -H $header | ||
| cat <<-END_VERSIONS > versions.yml | ||
| "${task.process}": | ||
| python: \$(python --version | sed 's/Python //g') | ||
| graph-tool: \$(python -c "import graph_tool; print(graph_tool.__version__)") | ||
| END_VERSIONS | ||
| """ | ||
|
|
||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.