From 0e44850d0931a66c9f9f3cc0191723b43d80bd8d Mon Sep 17 00:00:00 2001 From: Matt Shirley Date: Wed, 24 Mar 2021 10:49:22 -0400 Subject: [PATCH 1/4] Negate filtering --- pisces/R/make_expression_matrix.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pisces/R/make_expression_matrix.R b/pisces/R/make_expression_matrix.R index 369b302..c071679 100755 --- a/pisces/R/make_expression_matrix.R +++ b/pisces/R/make_expression_matrix.R @@ -389,7 +389,7 @@ deseq_analysis <- function(contrasts, txi.gene, contrast.metadata, formula, fail } else { deseq.dataset <- DESeqDataSetFromTximport(txi.gene, contrast.metadata, as.formula(paste0("~", contrasts$Factor[1])))} message(paste("Filtering", length(failing.quartile.filter), "genes failing --quartile-expression cutoff from DESeq2 dataset.")) - deseq.dataset <- deseq.dataset[failing.quartile.filter,] + deseq.dataset <- deseq.dataset[-failing.quartile.filter,] message("Running DESeq2...") deseq.dataset <- DESeq(deseq.dataset) From f321fc1456cca931ff1f01c9bd1a8a92d16b9e14 Mon Sep 17 00:00:00 2001 From: Matt Shirley Date: Wed, 24 Mar 2021 10:54:48 -0400 Subject: [PATCH 2/4] Better document first_quartile --- pisces/R/make_expression_matrix.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pisces/R/make_expression_matrix.R b/pisces/R/make_expression_matrix.R index c071679..e4155fb 100755 --- a/pisces/R/make_expression_matrix.R +++ b/pisces/R/make_expression_matrix.R @@ -269,7 +269,14 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) { "genes.")) ribo.genes <- which(grepl("^RP[SL]", scaled_df[, "symbol"], ignore.case = T)) - first_quartile <- function(x) { y <- quantile(x, c(0.25, 0.5, 0.75), type=1) + + + first_quartile <- function(x) { + # > seq(10) + # [1] 1 2 3 4 5 6 7 8 9 10 + # > first_quartile(seq(10)) + #[1] 3 + y <- quantile(x, c(0.25, 0.5, 0.75), type=1) return(y[[1]]) } From bfc6805d9e66a03d9d0ea82ab15695b43756c342 Mon Sep 17 00:00:00 2001 From: Matt Shirley Date: Wed, 24 Mar 2021 11:01:40 -0400 Subject: [PATCH 3/4] Take the top quantile instead of bottom --- pisces/R/make_expression_matrix.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pisces/R/make_expression_matrix.R b/pisces/R/make_expression_matrix.R index e4155fb..b7dda00 100755 --- a/pisces/R/make_expression_matrix.R +++ b/pisces/R/make_expression_matrix.R @@ -275,9 +275,9 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) { # > seq(10) # [1] 1 2 3 4 5 6 7 8 9 10 # > first_quartile(seq(10)) - #[1] 3 + #[1] 8 y <- quantile(x, c(0.25, 0.5, 0.75), type=1) - return(y[[1]]) + return(y[[3]]) } message(paste("Excluding", length(ribo.genes), "ribosomal genes from TMM scaling factor calulation.")) From ab6760a1e72604a1dca873375bac81646c772a08 Mon Sep 17 00:00:00 2001 From: Matt Shirley Date: Wed, 24 Mar 2021 11:09:29 -0400 Subject: [PATCH 4/4] function doc --- pisces/R/make_expression_matrix.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pisces/R/make_expression_matrix.R b/pisces/R/make_expression_matrix.R index b7dda00..4f74ca4 100755 --- a/pisces/R/make_expression_matrix.R +++ b/pisces/R/make_expression_matrix.R @@ -272,10 +272,8 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) { first_quartile <- function(x) { - # > seq(10) - # [1] 1 2 3 4 5 6 7 8 9 10 - # > first_quartile(seq(10)) - #[1] 8 + # > first_quartile(c(0,0,0,0,0,0,0,1,10,10)) + # [1] 1 y <- quantile(x, c(0.25, 0.5, 0.75), type=1) return(y[[3]]) }