From 4b62d5f74e7d1c21d7bf6ef51df34ae446b61c5f Mon Sep 17 00:00:00 2001 From: Matt Shirley Date: Wed, 1 Sep 2021 21:32:15 -0400 Subject: [PATCH] Add gene-level effective lengths (#6) --- pisces/R/make_expression_matrix.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pisces/R/make_expression_matrix.R b/pisces/R/make_expression_matrix.R index 4f74ca4..6067823 100755 --- a/pisces/R/make_expression_matrix.R +++ b/pisces/R/make_expression_matrix.R @@ -239,11 +239,17 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) { message("Writing annotation data matrix...") write.table(as.data.frame(annotation), paste0(args[["--name"]], ".", species, ".annotation.txt"), quote = FALSE, sep = "\t", row.names = F, col.names = T) + + message("Making gene-level length matrix...") + as.data.frame(txi.gene$abundance) %>% tibble::rownames_to_column("gene_id") %>% + left_join(annotation) %>% as.data.frame %>% + write.table(format(., nsmall = 3, scientific = F, trim = T), paste0(args[["--name"]], + ".", species, ".length.txt"), quote = FALSE, sep = "\t", row.names = F, + col.names = T) - message("Making raw TPM matrix...") + message("Making gene-level TPM matrix...") raw_df <- as.data.frame(txi.gene$abundance) %>% tibble::rownames_to_column("gene_id") %>% left_join(annotation) %>% as.data.frame - if (!args[["--no-rescale"]]) { message(paste("Scaling TPM of", args[["--scale-tpm"]], "to 1e6...")) @@ -263,6 +269,7 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) { write.table(format(normed_df, nsmall = 3, scientific = F, trim = T), paste0(args[["--name"]], ".", species, ".log2fc.txt"), quote = FALSE, sep = "\t", row.names = F, col.names = T) + message(paste("Calculating TMM scaling factors using", args[["--scale-tpm"]],