stianlagstad / chimeraviz

chimeraviz is an R package that automates the creation of chimeric RNA visualizations.
36 stars 14 forks source link

plot_circle line width not assigned to right fusion #52

Closed fmarois closed 5 years ago

fmarois commented 5 years ago

Hello, I noticed that the line width in the plot_circle function do not correspond to the reads. If you look at your own example using

soapfuse833ke <- system.file( "extdata", "soapfuse_833ke_final.Fusion.specific.for.genes", package = "chimeraviz") fusions <- import_soapfuse(soapfuse833ke, "hg38", 10)

You will notice that the link which should be the widest is the one between gene EEF1A1P5 and the gene PABPC1 (chr8 and chr9).

The issue is in the RCircos.Link.Plot, the parameter lineWidth expects an ordered numeric vector according to the chromosome:position. RCircos.Link.Plot(link.data = link_data, track.num = track_num, by.chromosome = TRUE, start.pos = NULL, genomic.columns = 3, is.sorted = FALSE, lineWidth = link_data$link_width)

Here is the solution I used : Create a reorder function that uses the mixedsort function from the gtools library. (This function was not written by me but I took it from : https://stackoverflow.com/questions/20396582/order-a-mixed-vector-numbers-with-letters

multi.mixedorder <- function(..., na.last = TRUE, decreasing = FALSE){ do.call(order, c( lapply(list(...), function(l){ if(is.character(l)){ factor(l, levels=mixedsort(unique(l))) } else { l } }), list(na.last = na.last, decreasing = decreasing) )) }

Then apply that function in the plot_circle function:

ordered_link_width <- link_data[multi.mixedorder(as.character(link_data$chromosome),link_data$chrom_start),]$link_width

Finally return the RCircos function with the ordred link width data:

return(RCircos::RCircos.Link.Plot(link.data = link_data, track.num = track_num, by.chromosome = TRUE, start.pos = NULL, genomic.columns = 3, is.sorted = FALSE, lineWidth = ordered_link_width))

stianlagstad commented 5 years ago

Hey @fmarois,

Super nice catch! I've implemented your change here: https://github.com/stianlagstad/chimeraviz/pull/53. Do you mind taking a look?

stianlagstad commented 5 years ago

Fixed in release_3_8 in version 1.8.1. Fixed in master/dev in version 1.9.1. Thanks again @fmarois!