-
Notifications
You must be signed in to change notification settings - Fork 1
Add CINmetrics module #64
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
base: master
Are you sure you want to change the base?
Changes from all commits
b6a2ea5
5c5d156
f46cdb6
34a56a8
4307667
eb3c0dd
4491b45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env Rscript | ||
| suppressPackageStartupMessages({ | ||
| library(CINmetrics, quietly = TRUE) | ||
| library(argparser, quietly = TRUE) | ||
| library(readr, quietly = TRUE) | ||
| library(dplyr, quietly = TRUE) | ||
| }) | ||
|
|
||
| parser <- arg_parser("Compute CINmetrics", hide.opts = TRUE) | ||
|
|
||
| parser <- add_argument(parser, "--seg_file", | ||
| help = "Input segmentation file", | ||
| nargs = Inf) | ||
| parser <- add_argument(parser, "--output", | ||
| help = "Output TSV file", | ||
| default = "cinmetrics_output.tsv") | ||
| parser <- add_argument(parser, "--segmentMean_tai", | ||
| help = "Threshold for TAI", | ||
| type = "numeric", default = 0.2) | ||
| parser <- add_argument(parser, "--segmentMean_cna", | ||
| help = "Threshold for CNA", | ||
| type = "numeric", default = (log(1.7, 2) - 1)) | ||
| parser <- add_argument(parser, "--segmentMean_base_segments", | ||
| help = "Threshold for base segments", | ||
| type = "numeric", default = 0.2) | ||
| parser <- add_argument(parser, "--segmentMean_break_points", | ||
| help = "Threshold for break points", | ||
| type = "numeric", default = 0.2) | ||
| parser <- add_argument(parser, "--segmentMean_fga", | ||
| help = "Threshold for FGA", | ||
| type = "numeric", default = 0.2) | ||
| parser <- add_argument(parser, "--numProbes", | ||
| help = "Minimum number of probes", | ||
| type = "numeric", default = NA) | ||
| parser <- add_argument(parser, "--segmentDistance_cna", | ||
| help = "Segment distance for CNA", | ||
| type = "numeric", default = 0.2) | ||
| parser <- add_argument(parser, "--minSegSize_cna", | ||
| help = "Minimum segment size for CNA", | ||
| type = "numeric", default = 10) | ||
| parser <- add_argument(parser, "--genomeSize_fga", | ||
| help = "Genome size for FGA", | ||
| type = "numeric", default = 2873203431) | ||
|
|
||
| args <- parse_args(parser) | ||
|
|
||
| input_file <- args$seg_file | ||
| cat("Reading:", input_file, "\n") | ||
| df <- read_tsv(input_file, show_col_types = FALSE) | ||
|
|
||
| colnames(df) <- c("Sample", "Chromosome", "Start", "End", "Num_Probes", "Segment_Mean") | ||
|
|
||
| df <- df %>% | ||
| mutate( | ||
| Sample = as.character(Sample), | ||
| Chromosome = gsub("^chr", "", Chromosome) | ||
| ) | ||
|
|
||
| cat("CINmetrics calculation...\n") | ||
| metrics <- CINmetrics( | ||
| cnvData = df, | ||
| segmentMean_tai = args$segmentMean_tai, | ||
| segmentMean_cna = args$segmentMean_cna, | ||
| segmentMean_base_segments = args$segmentMean_base_segments, | ||
| segmentMean_break_points = args$segmentMean_break_points, | ||
| segmentMean_fga = args$segmentMean_fga, | ||
| numProbes = args$numProbes, | ||
| segmentDistance_cna = args$segmentDistance_cna, | ||
| minSegSize_cna = args$minSegSize_cna, | ||
| genomeSize_fga = args$genomeSize_fga | ||
| ) | ||
|
|
||
| metrics$tai[is.na(metrics$tai)] <- 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this? A |
||
|
|
||
| write_tsv(metrics, args$output) | ||
| cat("Output file:", args$output, "\n") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| process COMPUTE_CINMETRICS{ | ||
| tag "Compute CINmetrics" | ||
| label 'process_single' | ||
|
|
||
| container 'ghcr.io/dincalcilab/cinmetrics:0.1.0' | ||
|
|
||
| input: | ||
| file(seg_file) | ||
|
|
||
| output: | ||
| path("*.tsv"), emit: cinmetrics_summary | ||
| path("versions.yml"), emit: versions | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
| def args = task.ext.args ?: '' | ||
| def VERSION = "0.1" | ||
| """ | ||
| compute_cinmetrics.R \\ | ||
| --seg_file $seg_file \\ | ||
| --output cinmetrics_summary_mqc.tsv \\ | ||
| $args | ||
SaraPotente marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| cat << END_VERSIONS > versions.yml | ||
| "${task.process}": | ||
| CINmetrics: ${VERSION} | ||
| END_VERSIONS | ||
| """ | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ include { methodsDescriptionText } from '../subworkflows/local/utils_samur | |
| // | ||
|
|
||
| include { CIN_SIGNATURE_QUANTIFICATION } from '../modules/local/cin_signature_quantification/main' | ||
| include { COMPUTE_CINMETRICS } from '../modules/local/cinmetrics/main' | ||
| include { SOLID_BIOPSY } from '../subworkflows/local/solid_biopsy/main' | ||
| include { SIZE_SELECTION } from '../subworkflows/local/size_selection/main' | ||
| include { LIQUID_BIOPSY } from '../subworkflows/local/liquid_biopsy/main' | ||
|
|
@@ -186,29 +187,29 @@ workflow SAMURAI { | |
| } | ||
|
|
||
| // QC metrics about alignment (coverage, etc.) | ||
| BAM_QC_PICARD( | ||
| ch_bam_bai.map { meta, bam, bai -> | ||
| [meta, bam, bai, [], []] | ||
| }, | ||
| ch_fasta, | ||
| ch_fai, | ||
| ch_dict, | ||
| [[], []] /* fasta_gzi */ | ||
| ) | ||
|
|
||
| ch_versions = ch_versions.mix( | ||
| BAM_QC_PICARD.out.versions.first() | ||
| ) | ||
| ch_multiqc_files = ch_multiqc_files.mix( | ||
| BAM_QC_PICARD.out.coverage_metrics.collect { _meta, metrics -> | ||
| metrics | ||
| } | ||
| ) | ||
| ch_multiqc_files = ch_multiqc_files.mix( | ||
| BAM_QC_PICARD.out.multiple_metrics.collect { _meta, metrics -> | ||
| metrics | ||
| } | ||
| ) | ||
| //BAM_QC_PICARD( | ||
SaraPotente marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // ch_bam_bai.map { meta, bam, bai -> | ||
| // [meta, bam, bai, [], []] | ||
| // }, | ||
| // ch_fasta, | ||
| // ch_fai, | ||
| // ch_dict, | ||
| // [[], []] /* fasta_gzi */ | ||
| //) | ||
| // | ||
| //ch_versions = ch_versions.mix( | ||
| // BAM_QC_PICARD.out.versions.first() | ||
| //) | ||
| //ch_multiqc_files = ch_multiqc_files.mix( | ||
| // BAM_QC_PICARD.out.coverage_metrics.collect { _meta, metrics -> | ||
| // metrics | ||
| // } | ||
| //) | ||
| //ch_multiqc_files = ch_multiqc_files.mix( | ||
| // BAM_QC_PICARD.out.multiple_metrics.collect { _meta, metrics -> | ||
| // metrics | ||
| // } | ||
| //) | ||
|
|
||
| // CN Calling | ||
|
|
||
|
|
@@ -286,6 +287,13 @@ workflow SAMURAI { | |
| error("Unknown / unsupported analysis ${analysis_type}") | ||
| } | ||
|
|
||
| // Run CINmetrics if specified | ||
| if (params.compute_cinmetrics) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You use |
||
| COMPUTE_CINMETRICS(gistic_file) | ||
| ch_versions = ch_versions.mix(COMPUTE_CINMETRICS.out.versions) | ||
| ch_multiqc_files = ch_multiqc_files.mix(COMPUTE_CINMETRICS.out.cinmetrics_summary) | ||
| } | ||
|
|
||
| // Run GISTIC if specified | ||
| if (run_gistic) { | ||
| RUN_GISTIC(gistic_file, genome) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you pass the column names directly to
read_tsv?