Skip to content
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

Multiqc metrics #14

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## v1.2.0dev

### New features

1. The metrics are now in the multiqc report instead of in a separate file

### Changes

1. Updated the pipeline template to nf-core v2.13.1
Expand Down
31 changes: 17 additions & 14 deletions workflows/wisecondorx.nf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.yaml.YamlBuilder

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT MODULES / SUBWORKFLOWS / FUNCTIONS
Expand Down Expand Up @@ -119,6 +121,10 @@ workflow WISECONDORX {
counts
}
.map { genders -> create_metrics(genders)}
.collectFile(name: "metrics_mqc.tsv")
.set { ch_metrics }

ch_multiqc_files = ch_multiqc_files.mix(ch_metrics)

}

Expand Down Expand Up @@ -202,20 +208,17 @@ def get_gender(tsv) {
}

def create_metrics(genders) {
male = genders["male"]
female = genders["female"]
male_count = male.size()
female_count = female.size()
total_count = male_count + female_count
ratio_male_to_female = male_count / female_count

output = file("${params.outdir}/metrics.txt")
output.write("Ratio male to female: ${ratio_male_to_female}\n")
output.append("Male count: ${male_count}\n")
output.append("Female count: ${female_count}\n")
output.append("Total count: ${total_count}\n")
output.append("Males: ${male.join(',')}\n")
output.append("Females: ${female.join(',')}\n")
def List male = genders["male"]
def List female = genders["female"]
def Integer male_count = male.size()
def Integer female_count = female.size()
def Float male_to_female_ratio = male_count / female_count
def Integer total_count = male_count + female_count

return """# plot_type: 'table'
Male to female ratio\tMale count\tFemale count\tTotal count\tMales\tFemales
${male_to_female_ratio}\t${male_count}\t${female_count}\t${total_count}\t${male.join(",")}\t${female.join(",")}
"""
}

/*
Expand Down
Loading