Merge branch 'logfold_column_CW-7233' into 'dev'
Rename log2Fold_contrast column [CW-7233] See merge request epi2melabs/workflows/wf-transcriptomes!253
This commit is contained in:
commit
b87c916247
@ -514,6 +514,37 @@ de_run_dexseq_result <- function(
|
||||
result
|
||||
}
|
||||
|
||||
de_dtu_transcript_columns <- c(
|
||||
"featureID",
|
||||
"groupID",
|
||||
"log2FoldChange",
|
||||
"pvalue",
|
||||
"padj",
|
||||
"exonBaseMean"
|
||||
)
|
||||
|
||||
#' Extract transcript-level DTU columns for TSV output.
|
||||
#'
|
||||
#' Renames the contrast-specific DEXSeq fold-change column to
|
||||
#' `log2FoldChange`, normalizes data for TSV output
|
||||
#' and returns only the transcript output columns.
|
||||
#'
|
||||
#' @param dex_df DEXSeq results as a data frame.
|
||||
#' @param contrast_name Contrast suffix used in the DEXSeq fold-change column.
|
||||
#'
|
||||
#' @return A normalized data frame ready for `results_dtu_transcript.tsv`.
|
||||
de_extract_dtu_transcript_table <- function(dex_df, contrast_name) {
|
||||
log2fold_column <- paste0("log2fold_", contrast_name)
|
||||
if (log2fold_column %in% names(dex_df)) {
|
||||
names(dex_df)[names(dex_df) == log2fold_column] <- "log2FoldChange"
|
||||
}
|
||||
tx_dtu <- dex_df[, intersect(
|
||||
de_dtu_transcript_columns,
|
||||
names(dex_df)
|
||||
), drop = FALSE]
|
||||
workflow_glue_r_normalise_tsv_df(tx_dtu)
|
||||
}
|
||||
|
||||
main_run_de_analysis <- function(argv) {
|
||||
set.seed(42)
|
||||
dir.create(argv$out_dir, showWarnings = FALSE, recursive = TRUE)
|
||||
@ -764,14 +795,7 @@ main_run_de_analysis <- function(argv) {
|
||||
)
|
||||
|
||||
if (is.null(dex_res)) {
|
||||
dex_df <- workflow_glue_r_empty_tsv(c(
|
||||
"featureID",
|
||||
"groupID",
|
||||
"log2fold",
|
||||
"pvalue",
|
||||
"padj",
|
||||
"exonBaseMean"
|
||||
))
|
||||
dex_df <- workflow_glue_r_empty_tsv(de_dtu_transcript_columns)
|
||||
tx_dtu <- dex_df
|
||||
gene_dtu <- workflow_glue_r_empty_tsv(c("GENEID", "qval"))
|
||||
de_write_placeholder_pdf(
|
||||
@ -793,11 +817,10 @@ main_run_de_analysis <- function(argv) {
|
||||
}
|
||||
dex_df <- as.data.frame(dex_res$dxr)
|
||||
dex_df <- workflow_glue_r_normalise_tsv_df(dex_df)
|
||||
tx_dtu <- dex_df[, intersect(
|
||||
c("featureID", "groupID", "log2fold", "pvalue", "padj", "exonBaseMean"),
|
||||
names(dex_df)
|
||||
), drop = FALSE]
|
||||
tx_dtu <- workflow_glue_r_normalise_tsv_df(tx_dtu)
|
||||
tx_dtu <- de_extract_dtu_transcript_table(
|
||||
dex_df,
|
||||
paste(target_level, reference_level, sep = "_")
|
||||
)
|
||||
|
||||
gene_q <- DEXSeq::perGeneQValue(dex_res$dxr)
|
||||
gene_dtu <- data.frame(
|
||||
|
||||
@ -92,6 +92,34 @@ testthat::test_that("formula-unsafe column names rejected", {
|
||||
)
|
||||
})
|
||||
|
||||
testthat::test_that("DTU transcript output renames contrast-specific log2fold column", {
|
||||
contrast_name <- "treated_control"
|
||||
dex_df <- data.frame(
|
||||
featureID = "tx1",
|
||||
groupID = "gene1",
|
||||
log2fold_treated_control = 1.5,
|
||||
pvalue = 0.01,
|
||||
padj = 0.05,
|
||||
exonBaseMean = 100,
|
||||
stringsAsFactors = FALSE,
|
||||
check.names = FALSE
|
||||
)
|
||||
|
||||
dtu_tx <- de_extract_dtu_transcript_table(dex_df, contrast_name)
|
||||
|
||||
testthat::expect_equal(
|
||||
names(dtu_tx),
|
||||
c(
|
||||
"featureID",
|
||||
"groupID",
|
||||
"log2FoldChange",
|
||||
"pvalue",
|
||||
"padj",
|
||||
"exonBaseMean"
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
# Sample aliases CAN have spaces/hyphens (they're not used in formulas, just for matching).
|
||||
# Sample sheet rows can be in different order than SE columns - should reorder automatically.
|
||||
testthat::test_that("non-syntactic aliases allowed, sheets reordered", {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user