ggbio icon indicating copy to clipboard operation
ggbio copied to clipboard

Odd lengths matching behavior og layout_circle

Open Deleetdk opened this issue 7 years ago • 0 comments

Often we want to match the sizes of different geoms, so that they lie perfectly on top of each other. However, this can be difficult. Not sure if this is intentional or not.

gg = ggplot() +
  layout_circle(hg19Ideo, 
                geom = "ideo", 
                fill = "gray70", 
                radius = 25,
                trackWidth = 5) +
  layout_circle(hg19Ideo,
                geom = "text", 
                aes(label = seqnames), 
                vjust = 0,
                radius = 24, 
                size = 2.5) +
  layout_circle(hg19Ideo,
                geom = "rect",
                fill = "green",
                color = "green",
                radius = 20,
                trackWidth = 4)

So we want to add another layer with a rect, such that it begins closer to center and ends exactly on top of the green rect. E.g. it begins at 15 and ends at 24. 24 being green rect radius start at 20, with width 4, so ends at 24. So we need a width of 9:

gg + layout_circle(genome_ranges,
              geom = "rect",
              radius = 15,
              trackWidth = 9,
              color = "red")

gp too short

Too short.

Hm? 10 then?

gg + layout_circle(genome_ranges,
              geom = "rect",
              radius = 15,
              trackWidth = 10,
              color = "red")

gp too long

Too long.

Maybe just try a bunch of values until we get it right:

gg + layout_circle(genome_ranges,
              geom = "rect",
              radius = 15,
              trackWidth = 9.25,
              color = "red")

gp justright

Just right. My question is: is this a bug or is there some clever way to determine that this value should be 9.25?

Data files and example code: lengths_mismatch.tar.gz

Deleetdk avatar Sep 19 '16 22:09 Deleetdk