From fb9993537c756206e9a130a91d9b09a8d3479424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Camargo?= Date: Tue, 26 Jun 2018 16:53:24 -0300 Subject: [PATCH] Add gene-level 'obs_raw' support to 'sleuth_to_matrix' --- R/matrix.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/matrix.R b/R/matrix.R index 4ffecf3..ab3d63d 100644 --- a/R/matrix.R +++ b/R/matrix.R @@ -40,12 +40,6 @@ sleuth_to_matrix <- function(obj, which_df, which_units) { which_units <- check_quant_mode(obj, which_units) - if (obj$gene_mode && which_df == "obs_raw") { - warning("This object is in gene mode, and the raw values are ", - "transcripts. Using 'obs_norm' instead.") - which_df <- "obs_norm" - } - data <- as.data.frame(obj[[which_df]]) res <- list() @@ -56,5 +50,13 @@ sleuth_to_matrix <- function(obj, which_df, which_units) { s_data$target_id <- NULL s_data <- as.matrix(s_data) + if (obj$gene_mode && which_df == "obs_raw") { + if (which_units == "scaled_reads_per_base") { + s_data <- t(t(s_data)*obj$est_counts_sf) + } else { + s_data <- t(t(s_data)*obj$tpm_sf) + } + } + s_data }