Skip to content

Commit

Permalink
Merge pull request #22 from Novartis/develop
Browse files Browse the repository at this point in the history
Add gene-level effective lengths (closes #6)
  • Loading branch information
mdshw5 authored Sep 8, 2021
2 parents 323920d + 4b62d5f commit 56a5d9d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pisces/R/make_expression_matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -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..."))
Expand All @@ -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"]],
Expand Down

0 comments on commit 56a5d9d

Please sign in to comment.