GViz Annotation Track Stacking
1
0
Entering edit mode
Lance Parsons ▴ 130
@lance-parsons-6529
Last seen 9.4 years ago
United States
I've recently started using the option to put group labels below the features in Gviz 1.8.1 AnnotationTracks (just.group="below"). However, I have noticed that when the label is larger than the feature, the stacking algorithm does not move the features onto a separate line as it does when justification is to the left. See the example photos: just.group="left": http://imgur.com/VfUN3G0 just.group="below": http://imgur.com/zmRGtxD I have been putting the labels below since that often makes it clearer which feature is being labeled (at least in my cases with small features). I'd be willing to help work on a patch for this, but could use a little help finding the relevant code. It'd be great to update the stacking code to account for label widths below the feature as well as to have an option to control the spacing when a label is to the left (or right) of a feature. -- Lance Parsons - Scientific Programmer 134 Carl C. Icahn Laboratory Lewis-Sigler Institute for Integrative Genomics Princeton University
Gviz Gviz • 1.2k views
ADD COMMENT
0
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.7 years ago
Switzerland
Hi Lance, All of this should be happening in the .computeGroupRange function in Gviz.R. The following switch statement seems to do something reasonable for the left or right justification, but ignores any extra space for above and below. Should be trivial to fix: switch(as.character(just), "left"={ if(!rev){ start(finalRanges) <- start(finalRanges) - (spaceBefore + labelWidths + spaceAfter) }else{ end(finalRanges) <- end(finalRanges) + spaceAfter + labelWidths + spaceBefore } sb <- spaceBefore sa <- spaceAfter }, "right"={ if(!rev){ end(finalRanges) <- end(finalRanges) + spaceAfter + labelWidths + spaceBefore }else{ start(finalRanges) <- start(finalRanges) - (spaceBefore + labelWidths + spaceAfter) } sb <- spaceBefore sa <- spaceAfter }, "above"={ sa <- sb <- 0 }, "below"={ sa <- sb <- 0 }, stop(sprintf("Unknown label justification '%s'", just))) On 19/05/14 17:05, "Lance Parsons" <lparsons at="" princeton.edu=""> wrote: >I've recently started using the option to put group labels below the >features in Gviz 1.8.1 AnnotationTracks (just.group="below"). However, >I have noticed that when the label is larger than the feature, the >stacking algorithm does not move the features onto a separate line as it >does when justification is to the left. See the example photos: > >just.group="left": http://imgur.com/VfUN3G0 > >just.group="below": http://imgur.com/zmRGtxD > >I have been putting the labels below since that often makes it clearer >which feature is being labeled (at least in my cases with small >features). I'd be willing to help work on a patch for this, but could >use a little help finding the relevant code. It'd be great to update >the stacking code to account for label widths below the feature as well >as to have an option to control the spacing when a label is to the left >(or right) of a feature. > >-- >Lance Parsons - Scientific Programmer >134 Carl C. Icahn Laboratory >Lewis-Sigler Institute for Integrative Genomics >Princeton University >
ADD COMMENT
0
Entering edit mode
# HG changeset patch # User Lance Parsons <lparsons@princeton.edu> # Date 1400683688 14400 # Wed May 21 10:48:08 2014 -0400 # Node ID ae2dae0f6a891442a0146d590543eb095241f9d0 # Parent e4dc83c56938a09ea7d410aff24f0fa4e93da515 Account for label width when labels above or below feature diff --git a/R/Gviz.R b/R/Gviz.R --- a/R/Gviz.R +++ b/R/Gviz.R @@ -2467,10 +2467,36 @@ sa <- spaceAfter }, "above"={ - sa <- sb <- 0 + if(!rev){ + featureWidths <- end(finalRanges) - start(finalRanges) + additionalLabelSpace <- ceiling((labelWidths - featureWidths) / 2) + additionalLabelSpace[additionalLabelSpace < 0] <- 0 + end(finalRanges) <- end(finalRanges) + additionalLabelSpace + start(finalRanges) <- start(finalRanges) - additionalLabelSpace + }else{ + featureWidths <- start(finalRanges) - end(finalRanges) + additionalLabelSpace <- ceiling((labelWidths - featureWidths) / 2) + additionalLabelSpace(additionalLabelSpace < 0) <- 0 + end(finalRanges) <- end(finalRanges) - additionalLabelSpace + start(finalRanges) <- start(finalRanges) + additionalLabelSpace + } + sa <- sb <- 0 }, "below"={ - sa <- sb <- 0 + if(!rev){ + featureWidths <- end(finalRanges) - start(finalRanges) + additionalLabelSpace <- ceiling((labelWidths - featureWidths) / 2) + additionalLabelSpace[additionalLabelSpace < 0] <- 0 + end(finalRanges) <- end(finalRanges) + additionalLabelSpace + start(finalRanges) <- start(finalRanges) - additionalLabelSpace + }else{ + featureWidths <- start(finalRanges) - end(finalRanges) + additionalLabelSpace <- ceiling((labelWidths - featureWidths) / 2) + additionalLabelSpace(additionalLabelSpace < 0) <- 0 + end(finalRanges) <- end(finalRanges) - additionalLabelSpace + start(finalRanges) <- start(finalRanges) + additionalLabelSpace + } + sa <- sb <- 0 }, stop(sprintf("Unknown label justification '%s'", just))) displayPars(GdObjectOrig) <- list(".__groupLabelWidths"=data.frame(before=sb, label=labelWidths, after=sa),
ADD REPLY

Login before adding your answer.

Traffic: 400 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6