Skip to content

Commit

Permalink
Add orientation parameter for genome labels
Browse files Browse the repository at this point in the history
  • Loading branch information
koalive committed Feb 8, 2019
1 parent b078224 commit edcb386
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: BioCircos
Title: Interactive Circular Visualization of Genomic Data using 'htmlwidgets' and 'BioCircos.js'
Version: 0.3.3
Version: 0.3.4
Authors@R: c(person("Loan", "Vulliard", email = "lvulliard@cemm.at", role = c("trl", "cre")),
person("Xiaowei", "Chen", email = "chenxiaowei@moon.ibp.ac.cn", role = c("aut")),
person("Ya", "Cui", email = "cui_ya@163.com", role = c("aut")))
Expand All @@ -14,7 +14,7 @@ License: GPL-2 | file LICENSE
Encoding: UTF-8
URL: https://github.com/lvulliard/BioCircos.R
LazyData: true
RoxygenNote: 6.0.1
RoxygenNote: 6.1.1
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
Imports: RColorBrewer, htmlwidgets, jsonlite, plyr, grDevices
7 changes: 4 additions & 3 deletions R/BioCircos.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#' @param genomeTicksDisplay,genomeTicksLen,genomeTicksColor,genomeTicksTextSize,genomeTicksTextColor,genomeTicksScale
#' Should the refence genome have ticks, of which length, color (in hexadecimal RGB format), with labels in which font
#' size and color, and spaced by how many bases?
#' @param genomeLabelDisplay,genomeLabelTextSize,genomeLabelTextColor,genomeLabelDx,genomeLabelDy
#' @param genomeLabelDisplay,genomeLabelTextSize,genomeLabelTextColor,genomeLabelDx,genomeLabelDy,genomeLabelOrientation
#' Should the reference genome have labels on each chromosome, in which font size and color? Moreover rotation
#' and radius shifts for the label texts can be adde
#' and radius shifts for the label texts can be added, and the angle between the radius and the label changed.
#'
#' @param zoom Is zooming and moving in the visualization allowed?
#'
Expand Down Expand Up @@ -164,7 +164,7 @@ BioCircos <- function(tracklist = BioCircosTracklist(),
genomeTicksDisplay = TRUE, genomeTicksLen = 5, genomeTicksColor = "#000",
genomeTicksTextSize = "0.6em", genomeTicksTextColor = "#000", genomeTicksScale = 30000000,
genomeLabelDisplay = TRUE, genomeLabelTextSize = "10pt", genomeLabelTextColor = "#000",
genomeLabelDx = 0.028, genomeLabelDy = "-0.55em",
genomeLabelDx = 0.0, genomeLabelDy = 10, genomeLabelOrientation = 0,
zoom = TRUE, TEXTModuleDragEvent = FALSE,
SNPMouseOverDisplay = TRUE, SNPMouseOverColor = "#FF0000", SNPMouseOverCircleSize = 3,
SNPMouseOverCircleOpacity = 0.9,
Expand Down Expand Up @@ -261,6 +261,7 @@ BioCircos <- function(tracklist = BioCircosTracklist(),
genomeLabelTextColor = genomeLabelTextColor,
genomeLabelDx = genomeLabelDx,
genomeLabelDy = genomeLabelDy,
genomeLabelOrientation = genomeLabelOrientation,
SNPMouseEvent = T,
SNPMouseClickDisplay = F,
SNPMouseClickColor = "red",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Since the visualizations are powered by JavaScript, they are affected by the env
* If nothing shows up in the Rstudio viewer pane, try displaying the plot you generated in your browser instead. You can export the figure using the *Save as Web Page...* option in the *Export* tab of the viewer pane.
* If nothing shows up in a shiny application or an Rmarkdown document, try to update your web browser.
See the vignettes for examples of BioCircos plots that should be correctly displayed.
* Rotation of labels using the *genomeLabelOrientation* parameter leads to a slight offset of the text when displayed in Firefox because some recent CSS options are not yet implemented.

### Obseved behavior

Expand Down Expand Up @@ -78,6 +79,7 @@ The following features have been added to the original BioCircos.js library, bas
* Parameter *snp_value_maxmin_instance* set by *SNPsettings.range* when provided, to allow the use of a pre-defined range of values for the SNP track.
* Similar parameters added for the range of Histogram/Bar tracks, Line tracks, CNV tracks and Heatmap tracks (for the range to be used for color mapping).
* Parameter *opacity* added to each elements of SNP and Arc tracks.
* Changes were made in order to allow rotation of genome labels with the new parameter *genomeLabelOrientation* and the radial offset *dy* is now directly integrated in the label translation.


## Contact
Expand Down
3 changes: 2 additions & 1 deletion inst/htmlwidgets/BioCircos.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ HTMLWidgets.widget({
textSize : opts.genomeLabelTextSize,
textColor : opts.genomeLabelTextColor,
dx : opts.genomeLabelDx,
dy : opts.genomeLabelDy
dy : opts.genomeLabelDy,
rotation : opts.genomeLabelOrientation
},
TEXTModuleDragEvent : opts.TEXTModuleDragEvent
});
Expand Down
19 changes: 13 additions & 6 deletions inst/htmlwidgets/lib/biocircos-1.1.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ var BioCircos;
"textSize" : 15,
"textColor" : "#000",
"dx" : 0.028,
"dy" : "-0.55em"
"dy" : 15,
"rotation" : 0
}
};

Expand Down Expand Up @@ -761,6 +762,7 @@ var BioCircos;
self.genomeTextColor=self.settings.genomeLabel.textColor;
self.genomeTextDx=self.settings.genomeLabel.dx;
self.genomeTextDy=self.settings.genomeLabel.dy;
self.genomeTextRotation=self.settings.genomeLabel.rotation;

var labeli= self.genomeLabel.length;
var initGenome = new Object();
Expand Down Expand Up @@ -1164,12 +1166,17 @@ var BioCircos;
.each( function(d,i) {
d.angle = (d.startAngle + d.endAngle) / 2 - self.genomeTextDx;
d.name = self.genomeLabel[i];
d.rotation = self.genomeTextRotation;
d.dy = self.genomeTextDy;
})
.attr("dy",self.genomeTextDy)
.attr("text-anchor", "middle") // Rotate around horizontal center of text box
.attr("alignment-baseline", "middle") // Rotate around vertical center of text box
.attr("vertical-align", "middle")
.attr("transform", function(d){
return "rotate(" + ( d.angle * 180 / Math.PI ) + ")" +
"translate(0,"+ -1.0*(outerRadius+10) +")" +
( ( d.angle > Math.PI*2 && d.angle < Math.PI*0 ) ? "rotate(180)" : "");
return "rotate(" + (d.angle * 180 / Math.PI ) + ")" +
"translate(0,"+ -1.0*(outerRadius+10+d.dy) +")" +
( ( d.angle > Math.PI*2 && d.angle < Math.PI*0 ) ? "rotate(180)" : "") +
"rotate(" + d.rotation +")";
})
.text(function(d){
return d.name;
Expand Down Expand Up @@ -1206,7 +1213,7 @@ var BioCircos;

ticks.append("text")
.attr("x", 8)
.attr("dy", ".35em")
.attr("dy", "0.35em")
.style("font-size", self.ticksTextSize)
.style("fill", self.ticksTextColor)
.attr("transform", function(d) { return d.angle > Math.PI ? "rotate(180)translate(-16)" : null; })
Expand Down
2 changes: 1 addition & 1 deletion vignettes/BioCircos.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ output:
vignette: >
%\VignetteIndexEntry{BioCircos: Generating circular multi-track plots}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
%\usepackage[utf8]{inputenc}
date: "`r Sys.Date()`"
author: "Loan Vulliard"
---
Expand Down

0 comments on commit edcb386

Please sign in to comment.