Skip to content

Commit

Permalink
Fixed rsem-gen-transcript-plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Li committed Nov 11, 2015
1 parent a1014bb commit 9414e50
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rsem-gen-transcript-plots
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,22 @@ build_map <- function(filename) {
map
}

canonical_id = function(id) {
pos = regexpr("_", id, fixed = T)
ifelse(pos > 0, substr(id, 1, pos - 1), id)
}

make_a_plot <- function(id) {
vec <- readdepth[[id]]
cid = canonical_id(id)

vec <- readdepth[[cid]]
if (is.null(vec)) exit_with_error(sprintf("Unknown %s detected, %s is not included in RSEM's indices.", ifelse(alleleS, "allele-specific transcript", "transcript"), id))
if (is.na(vec[[2]])) wiggle <- rep(0, vec[[1]]) else wiggle <- as.numeric(unlist(strsplit(vec[[2]], split = " ")))
len <- length(wiggle)
if (!show_uniq) {
plot(wiggle, type = "h")
} else {
vec <- readdepth_uniq[[id]]
vec <- readdepth_uniq[[cid]]
stopifnot(!is.null(vec))
if (is.na(vec[[2]])) wiggle_uniq <- rep(0, vec[[1]]) else wiggle_uniq <- as.numeric(unlist(strsplit(vec[[2]], split = " ")))
stopifnot(len == length(wiggle_uniq))
Expand Down

1 comment on commit 9414e50

@hotdogee
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the script if the reference_fasta_file ids have the "_" character:
Unknown transcript detected, CNW_00000001 is not included in RSEM's indices.

Please sign in to comment.