Skip to content

Commit 56a5d9d

Browse files
authored
Merge pull request #22 from Novartis/develop
Add gene-level effective lengths (closes #6)
2 parents 323920d + 4b62d5f commit 56a5d9d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pisces/R/make_expression_matrix.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,17 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) {
239239
message("Writing annotation data matrix...")
240240
write.table(as.data.frame(annotation), paste0(args[["--name"]], ".", species,
241241
".annotation.txt"), quote = FALSE, sep = "\t", row.names = F, col.names = T)
242+
243+
message("Making gene-level length matrix...")
244+
as.data.frame(txi.gene$abundance) %>% tibble::rownames_to_column("gene_id") %>%
245+
left_join(annotation) %>% as.data.frame %>%
246+
write.table(format(., nsmall = 3, scientific = F, trim = T), paste0(args[["--name"]],
247+
".", species, ".length.txt"), quote = FALSE, sep = "\t", row.names = F,
248+
col.names = T)
242249

243-
message("Making raw TPM matrix...")
250+
message("Making gene-level TPM matrix...")
244251
raw_df <- as.data.frame(txi.gene$abundance) %>% tibble::rownames_to_column("gene_id") %>%
245252
left_join(annotation) %>% as.data.frame
246-
247253

248254
if (!args[["--no-rescale"]]) {
249255
message(paste("Scaling TPM of", args[["--scale-tpm"]], "to 1e6..."))
@@ -263,6 +269,7 @@ Summarize <- function(txi, tx2gene, annotation, args, metadata, species) {
263269
write.table(format(normed_df, nsmall = 3, scientific = F, trim = T), paste0(args[["--name"]],
264270
".", species, ".log2fc.txt"), quote = FALSE, sep = "\t", row.names = F,
265271
col.names = T)
272+
266273

267274

268275
message(paste("Calculating TMM scaling factors using", args[["--scale-tpm"]],

0 commit comments

Comments
 (0)