diff --git a/modules/nf-core/propr/propd/meta.yml b/modules/nf-core/propr/propd/meta.yml index 1c408d7341b..7dcb46259bf 100644 --- a/modules/nf-core/propr/propd/meta.yml +++ b/modules/nf-core/propr/propd/meta.yml @@ -52,8 +52,16 @@ output: pattern: "*.propd.tsv" - fdr: type: file - description: (optional) propr fdr table + description: (optional) propd fdr table pattern: "*.fdr.tsv" + - adj: + type: file + description: (optional) propd adj table + pattern: "*.adj.csv" + - warnings: + type: file + description: propd warnings + pattern: "*.warnings.txt" - session_info: type: file description: dump of R SessionInfo diff --git a/modules/nf-core/propr/propd/templates/propd.R b/modules/nf-core/propr/propd/templates/propd.R index 00677a9f513..63dbed49d31 100644 --- a/modules/nf-core/propr/propd/templates/propd.R +++ b/modules/nf-core/propr/propd/templates/propd.R @@ -67,24 +67,27 @@ read_delim_flexible <- function(file, header = TRUE, row.names = 1, check.names #' #' @param object propd object one_metric_df <- function(object){ - result <- getResults(object) - genes <- unique(c(result\$Pair, result\$Partner)) - - empty_matrix <- matrix(NA, nrow = length(genes), ncol = length(genes), dimnames = list(genes, genes)) - - if (object@active == "theta_d"){ - metric <- "theta" - }else{ - metric <- object@active - } - - for (i in 1:nrow(result)) { - row_name <- result\$Pair[i] - col_name <- result\$Partner[i] - empty_matrix[row_name, col_name] <- result[[metric]][i] - empty_matrix[col_name, row_name] <- result[[metric]][i] - } - return(empty_matrix) + results <- getResults(object) + #keep only the metric of interest + one_metric <- cbind(results\$Partner, results\$Pair, results\$theta) + colnames(one_metric) <- c("Partner", "Pair", "theta") + one_metric <- as.data.frame(one_metric) + + # Extract the unique gene names + gene_names <- sort(unique(c(one_metric\$Partner, one_metric\$Pair))) + # Initialize a square matrix with NA + square_matrix <- matrix(NA, nrow = length(gene_names), ncol = length(gene_names)) + rownames(square_matrix) <- gene_names + colnames(square_matrix) <- gene_names + + # Use the `match` function to get the row and column indices + row_indices <- match(one_metric\$Partner, gene_names) + col_indices <- match(one_metric\$Pair, gene_names) + # Use these indices to populate the matrix + square_matrix[cbind(row_indices, col_indices)] <- one_metric[["theta"]] + # Populate the reverse pairs to ensure symmetry + square_matrix[cbind(col_indices, row_indices)] <- one_metric[["theta"]] + return(square_matrix) } #' Extract the differential proportionality cutoff for a specified FDR value. diff --git a/modules/nf-core/propr/propd/tests/main.nf.test.snap b/modules/nf-core/propr/propd/tests/main.nf.test.snap index 58199b4b8ca..e0291044aef 100644 --- a/modules/nf-core/propr/propd/tests/main.nf.test.snap +++ b/modules/nf-core/propr/propd/tests/main.nf.test.snap @@ -14,7 +14,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T11:55:35.703293" + "timestamp": "2024-05-23T13:10:06.778954" }, "Test propr/propd using theta_e and boxcox permutation - results": { "content": [ @@ -31,7 +31,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T11:59:33.28078" + "timestamp": "2024-05-23T13:13:35.158486" }, "Test propr/propd using theta_e permutation - results": { "content": [ @@ -48,7 +48,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T11:57:24.038188" + "timestamp": "2024-05-23T13:12:03.500722" }, "versions": { "content": [ @@ -60,7 +60,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T11:53:45.165637" + "timestamp": "2024-05-23T13:07:07.588326" }, " - results": { "content": [ @@ -77,7 +77,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T14:13:47.602525" + "timestamp": "2024-05-23T13:16:44.428551" }, " Test propr/propd using default boxcox permutation - results": { "content": [ @@ -94,7 +94,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T11:55:32.476341" + "timestamp": "2024-05-23T13:10:02.25738" }, "Test propr/propd using default permutation - results": { "content": [ @@ -111,7 +111,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T11:53:43.056295" + "timestamp": "2024-05-23T13:07:04.720183" }, "Test propr/propd with adjacency matrix - adj": { "content": [ @@ -120,7 +120,7 @@ { "id": "test" }, - "test.adj.csv:md5,f9d19255f9400e6c4daa01f86d74f017" + "test.adj.csv:md5,9da907136fba72b0e098c7fbacbeb837" ] ] ], @@ -128,6 +128,6 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-04-16T14:13:47.427246" + "timestamp": "2024-05-23T13:16:38.527389" } } \ No newline at end of file