diff --git a/modules/local/stimulus/compare_tensors/main.nf b/modules/local/stimulus/compare_tensors/main.nf index d2c1fff..072f6fe 100644 --- a/modules/local/stimulus/compare_tensors/main.nf +++ b/modules/local/stimulus/compare_tensors/main.nf @@ -18,7 +18,7 @@ process STIMULUS_COMPARE_TENSORS { """ stimulus compare-tensors \ ${tensors} \ - -s scores.csv \ + -o scores.csv \ ${args} # Extract first row of scores.csv diff --git a/subworkflows/local/evaluation/main.nf b/subworkflows/local/evaluation/main.nf index bd0b364..5e13a82 100644 --- a/subworkflows/local/evaluation/main.nf +++ b/subworkflows/local/evaluation/main.nf @@ -41,26 +41,42 @@ workflow EVALUATION_WF { // and the same number of trials, we can estimate the noise across replicates // This is done by comparing the predictions of the alternative models between each other // and then calculatin a summary metric over them (e.g. mean, median, std, etc.) - - replicate_predictions = predictions.map{ - meta, prediction -> - [["id": meta.id, - "split_id": meta.split_id, - "transform_id": meta.transform_id, - "n_trials": meta.n_trials ], meta, prediction] - }.groupTuple(by:0) - .map{ - merging_meta, metas, predictions -> - [merging_meta, predictions] + pairs = predictions + .collate(2) + .collect() + .map { items -> + def pairs = [] + // Create all unique combinations using index comparison + (0.. + (i+1.. + def meta1 = items[i][0] + def meta2 = items[j][0] + def files = [items[i][1], items[j][1]] + // Only compare different transforms OR different replicates + if(meta1.transform_id != meta2.transform_id || meta1.replicate != meta2.replicate) { + pairs << [ + [ + "id1": meta1.id, + "id2": meta2.id, + "split_id1": meta1.split_id, + "split_id2": meta2.split_id, + "transform_id1": meta1.transform_id, + "transform_id2": meta2.transform_id, + "replicate1": meta1.replicate, + "replicate2": meta2.replicate + ], + // Create unique filenames using both transforms and replicates + files + ] + } + } } - - // check if the predictions are at least 2, meta,predictions - replicate_predictions.filter{ - it[1].size() > 1 - }.set{ replicate_predictions } + pairs + } + .flatMap { it } STIMULUS_COMPARE_TENSORS_COSINE( - replicate_predictions + pairs ) cosine_scores = STIMULUS_COMPARE_TENSORS_COSINE.out.csv