0

I'm trying to use geom_alignment in the ggbio package to plot a stretch of genes, and I want to show labels under each gene. The docs for geom_alignment say that this is done by specifying label = TRUE, and supplying a vector of labels in names.expr. The problem is that it doesn't seem to work, and it's not throwing any error messages that might hold a clue.

  gr <- GRanges(seqnames="test",
      IRanges(start=c(10,40,60),
      end=c(25,55,70),
      names=c("A","B","C"),
      group = "groupA")
    )

ggplot(gr) + geom_alignment(aes(fill=group,col=group), gap.geom = "segment", label = TRUE,names.expr = names(gr))

enter image description here

So it plots the segments exactly as expected, but leaves off the labels. Am I missing something here?

There is an earlier question similar to this: Adding Labels to Individual Genes with ggbio and ggplot2

the suggested answer there involves splitting the GRanges object on the group variable before plotting, but I need to keep the parts of the GRanges object together, and at any rate this fix doesn't seem to be working as suggested.

here is my session info:

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggbio_1.42.0         stringr_1.4.0        gplots_3.1.1         rtracklayer_1.54.0   ggplot2_3.3.5       
 [6] GenomicRanges_1.46.1 GenomeInfoDb_1.30.0  IRanges_2.28.0       S4Vectors_0.32.3     BiocGenerics_0.40.0 
[11] dplyr_1.0.7          readr_2.1.0          vcfR_1.12.0          ballgown_2.26.0  
Keith Allen
  • 143
  • 2
  • 8

0 Answers0