jianhong / trackViewer

A bioconductor package with minimalist design for drawing elegant tracks or lollipop plot
https://jianhong.github.io/trackViewer/
66 stars 16 forks source link

Plotting multiple transcripts in lolliplot #14

Closed Jeromeg666 closed 3 years ago

Jeromeg666 commented 3 years ago

Hi,

I am sorry to disturb you with this question. I am quite a beginner when it comes to coding in R. I am currently plotting a lot of different genes with lolliplot (great package btw). However, I am facing issues when it comes to plotting three or more transcripts. I have looked over google to find examples, but I have not find any yet with three or more transcripts. Is it feasible ? if yes, could you let me know how. Thank you very much.

jianhong commented 3 years ago

Are you talking about similar samples like this https://bioconductor.org/packages/release/bioc/vignettes/trackViewer/inst/doc/lollipopPlot.html#Plot_multiple_transcripts_in_the_features but with more transcripts?

Here is pseudo codes:

features.mul <- GRangesList(transcripts) # an object of GRangesList
features.ul <- unlist(features.mul) # convert it to GRanges
if(length(names(features.mul))!=length(features.mul){
  names(features.mul) <- paste0("tx_", seq_along(features.mul)) 
}
features.ul$featureLayerID <- rep(names(features.mul), lengths(features.mul))
# names(features.ul) <- features.ul$featureLayerID ## rename the GRanges if you want
lolliplot(sample.gr, features.ul) 

Let me know if you have any questions.

Jeromeg666 commented 3 years ago

Yes, that's exactly what I would like to add. Thanks for the code. It is extremely appreciated!