| ... | ... |
@@ -31,6 +31,9 @@ |
| 31 | 31 |
#' plot.params <- getDefaultPlotParams(plot.type=2) |
| 32 | 32 |
#' plot.params$leftmargin <- 0.2 |
| 33 | 33 |
#' plot.params$rightmargin <- 0.2 |
| 34 |
+#' |
|
| 35 |
+#' #In standard whole karyotypes, labels are drawn for all chromosomes |
|
| 36 |
+#' |
|
| 34 | 37 |
#' kp <- plotKaryotype("hg19", chromosomes=c("chr1", "chr2"), plot.type=2, plot.params = plot.params)
|
| 35 | 38 |
#' #data panel 1 |
| 36 | 39 |
#' kpDataBackground(kp, r0=0, r1=0.5, col="#FFDDDD") |
| ... | ... |
@@ -48,6 +51,52 @@ |
| 48 | 51 |
#' kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6, side="right") |
| 49 | 52 |
#' kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6, side="right") |
| 50 | 53 |
#' |
| 54 |
+#' |
|
| 55 |
+#' |
|
| 56 |
+#' #In karyotypes with all chromosomes in a single line, |
|
| 57 |
+#' #labels are added on the first (side="left") or last (side="right") chromosome |
|
| 58 |
+#' |
|
| 59 |
+#' kp <- plotKaryotype("hg19", chromosomes=c("chr1", "chr2", "chr3"), plot.type=3, plot.params = plot.params)
|
|
| 60 |
+#' #data panel 1 |
|
| 61 |
+#' kpDataBackground(kp, r0=0, r1=0.5, col="#FFDDDD") |
|
| 62 |
+#' kpDataBackground(kp, r0=0.5, r1=1, col="#DDFFDD") |
|
| 63 |
+#' kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=3, cex=0.8) |
|
| 64 |
+#' kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6) |
|
| 65 |
+#' kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6) |
|
| 66 |
+#' #data panel 2 |
|
| 67 |
+#' kpDataBackground(kp, col="#DDDDFF", data.panel = 2) |
|
| 68 |
+#' kpAddLabels(kp, "BLUE", data.panel=2) |
|
| 69 |
+#' |
|
| 70 |
+#' #Plot on the right |
|
| 71 |
+#' #data panel 1 |
|
| 72 |
+#' kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=1, cex=0.8, side="right") |
|
| 73 |
+#' kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6, side="right") |
|
| 74 |
+#' kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6, side="right") |
|
| 75 |
+#' |
|
| 76 |
+#' |
|
| 77 |
+#' |
|
| 78 |
+#' #In Zoomed regions, they are placed at the correct position too |
|
| 79 |
+#' kp <- plotKaryotype("hg19", zoom="chr1:20000000-40000000", plot.type=2, plot.params = plot.params)
|
|
| 80 |
+#' kpAddBaseNumbers(kp, tick.dist=5000000, add.units=TRUE) |
|
| 81 |
+#' #data panel 1 |
|
| 82 |
+#' kpDataBackground(kp, r0=0, r1=0.5, col="#FFDDDD") |
|
| 83 |
+#' kpDataBackground(kp, r0=0.5, r1=1, col="#DDFFDD") |
|
| 84 |
+#' kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=3, cex=0.8) |
|
| 85 |
+#' kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6) |
|
| 86 |
+#' kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6) |
|
| 87 |
+#' #data panel 2 |
|
| 88 |
+#' kpDataBackground(kp, col="#DDDDFF", data.panel = 2) |
|
| 89 |
+#' kpAddLabels(kp, "BLUE", data.panel=2) |
|
| 90 |
+#' |
|
| 91 |
+#' #Plot on the right |
|
| 92 |
+#' #data panel 1 |
|
| 93 |
+#' kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=1, cex=0.8, side="right") |
|
| 94 |
+#' kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6, side="right") |
|
| 95 |
+#' kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6, side="right") |
|
| 96 |
+#' |
|
| 97 |
+#' |
|
| 98 |
+#' |
|
| 99 |
+#' |
|
| 51 | 100 |
#' @export kpAddLabels |
| 52 | 101 |
#' |
| 53 | 102 |
|
| ... | ... |
@@ -73,7 +122,7 @@ kpAddLabels <- function(karyoplot, labels, label.margin=0.01, side="left", pos= |
| 73 | 122 |
adj.y <- prepareParameters2("kpAddLabels", karyoplot, data=NULL, chr=chrs,
|
| 74 | 123 |
x=0, y=c(0,1), ymax=1, ymin=0, r0=r0, r1=r1, |
| 75 | 124 |
data.panel=data.panel)$y |
| 76 |
- #Compute the verstical position of the labels |
|
| 125 |
+ #Compute the vertical position of the labels |
|
| 77 | 126 |
y0 <- karyoplot$coord.change.function(chr = chrs, x = 0, y=rep(adj.y[1], length(chrs)), data.panel = data.panel)$y |
| 78 | 127 |
y1 <- karyoplot$coord.change.function(chr = chrs, x = 0, y=rep(adj.y[2], length(chrs)), data.panel = data.panel)$y |
| 79 | 128 |
y <- (y0+y1)/2 |
| ... | ... |
@@ -86,7 +135,7 @@ kpAddLabels <- function(karyoplot, labels, label.margin=0.01, side="left", pos= |
| 86 | 135 |
} else { #if side="right", plot them on the right
|
| 87 | 136 |
#The last position of each chrs plus the label.margin |
| 88 | 137 |
x <- karyoplot$coord.change.function(chr = chrs, |
| 89 |
- x = end(karyoplot$genome[chrs]), |
|
| 138 |
+ x = end(karyoplot$plot.region[chrs]), |
|
| 90 | 139 |
y=rep(adj.y[1], length(chrs)), |
| 91 | 140 |
data.panel = data.panel)$x + label.margin |
| 92 | 141 |
if(is.null(pos)) pos <- 4 |
| ... | ... |
@@ -41,6 +41,9 @@ Given a KaryoPlot object, plot labels on the side of the data panels to help ide |
| 41 | 41 |
plot.params <- getDefaultPlotParams(plot.type=2) |
| 42 | 42 |
plot.params$leftmargin <- 0.2 |
| 43 | 43 |
plot.params$rightmargin <- 0.2 |
| 44 |
+ |
|
| 45 |
+#In standard whole karyotypes, labels are drawn for all chromosomes |
|
| 46 |
+ |
|
| 44 | 47 |
kp <- plotKaryotype("hg19", chromosomes=c("chr1", "chr2"), plot.type=2, plot.params = plot.params)
|
| 45 | 48 |
#data panel 1 |
| 46 | 49 |
kpDataBackground(kp, r0=0, r1=0.5, col="#FFDDDD") |
| ... | ... |
@@ -58,6 +61,52 @@ kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=1, cex=0.8, side= |
| 58 | 61 |
kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6, side="right") |
| 59 | 62 |
kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6, side="right") |
| 60 | 63 |
|
| 64 |
+ |
|
| 65 |
+ |
|
| 66 |
+#In karyotypes with all chromosomes in a single line, |
|
| 67 |
+#labels are added on the first (side="left") or last (side="right") chromosome |
|
| 68 |
+ |
|
| 69 |
+kp <- plotKaryotype("hg19", chromosomes=c("chr1", "chr2", "chr3"), plot.type=3, plot.params = plot.params)
|
|
| 70 |
+#data panel 1 |
|
| 71 |
+kpDataBackground(kp, r0=0, r1=0.5, col="#FFDDDD") |
|
| 72 |
+kpDataBackground(kp, r0=0.5, r1=1, col="#DDFFDD") |
|
| 73 |
+kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=3, cex=0.8) |
|
| 74 |
+kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6) |
|
| 75 |
+kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6) |
|
| 76 |
+#data panel 2 |
|
| 77 |
+kpDataBackground(kp, col="#DDDDFF", data.panel = 2) |
|
| 78 |
+kpAddLabels(kp, "BLUE", data.panel=2) |
|
| 79 |
+ |
|
| 80 |
+#Plot on the right |
|
| 81 |
+#data panel 1 |
|
| 82 |
+kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=1, cex=0.8, side="right") |
|
| 83 |
+kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6, side="right") |
|
| 84 |
+kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6, side="right") |
|
| 85 |
+ |
|
| 86 |
+ |
|
| 87 |
+ |
|
| 88 |
+#In Zoomed regions, they are placed at the correct position too |
|
| 89 |
+kp <- plotKaryotype("hg19", zoom="chr1:20000000-40000000", plot.type=2, plot.params = plot.params)
|
|
| 90 |
+kpAddBaseNumbers(kp, tick.dist=5000000, add.units=TRUE) |
|
| 91 |
+#data panel 1 |
|
| 92 |
+kpDataBackground(kp, r0=0, r1=0.5, col="#FFDDDD") |
|
| 93 |
+kpDataBackground(kp, r0=0.5, r1=1, col="#DDFFDD") |
|
| 94 |
+kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=3, cex=0.8) |
|
| 95 |
+kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6) |
|
| 96 |
+kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6) |
|
| 97 |
+#data panel 2 |
|
| 98 |
+kpDataBackground(kp, col="#DDDDFF", data.panel = 2) |
|
| 99 |
+kpAddLabels(kp, "BLUE", data.panel=2) |
|
| 100 |
+ |
|
| 101 |
+#Plot on the right |
|
| 102 |
+#data panel 1 |
|
| 103 |
+kpAddLabels(kp, "Everything", label.margin = 0.12, srt=90, pos=1, cex=0.8, side="right") |
|
| 104 |
+kpAddLabels(kp, "Red", r0=0, r1=0.5, cex=0.6, side="right") |
|
| 105 |
+kpAddLabels(kp, "Green", r0=0.5, r1=1, cex=0.6, side="right") |
|
| 106 |
+ |
|
| 107 |
+ |
|
| 108 |
+ |
|
| 109 |
+ |
|
| 61 | 110 |
} |
| 62 | 111 |
\seealso{
|
| 63 | 112 |
\code{\link{plotKaryotype}}
|