tracks () function from ggbio does not allow italic expression in the title
0
0
Entering edit mode
@oswaldolorenzo-11449
Last seen 4.0 years ago

I'm trying to combine plain text with italic text in the title of a combined tracks() plot generated by ggbio, but I can not include the part of the title that I want in italic fonts.

Here you have several examples of titles that allow italics using expression(italic(x)) and the last one is the one that does not work for me.

library(ggbio)
library(grDevices)

This is the title that I want to use: "Variation in AAAA gene"

I can get it with this code:

plot_title <- expression(paste("Variation in ", italic("AAAA"), " gene"))

It works for me in this first example using the plot()

x <- c(2*5)
y <- c(2^5)
plot(x,y, main = plot_title)

It also works for me in the second example using the autoplot()

test_a = GRanges('chr1', IRanges(start = 150, end = 180))
t_a <- autoplot(test_a, main = plot_title)
fixed(t_a) <- TRUE
t_a

test_b = GRanges('chr1', IRanges(start = 100, end = 200))
t_b <- autoplot(test_b,  main = plot_title)
fixed(t_b) <- TRUE
t_b

This is the plot that I would like to have with the title including the AAAA in italics

combined_tracks <-   tracks(t_a, t_b, title = "Variation in AAAA gene") + xlim (100, 200)    
combined_tracks

When I use the tracks() and I try to use the plot_title to generate the final plot, R crashes

combined_tracks2 <-   tracks(t_a, t_b, title = plot_title) + xlim (100, 200)    
combined_tracks2

I get the following error:

Error in validObject(.Object) :
  invalid class "Tracks" object: invalid object for slot "main" in class "Tracks": got class "expression", should be or extend class "characterORNULL"

Does anybody how to get around this error,

I have looked on the Internet, but I haven't found an answer for this specific tracks() function.

Thank you very much,

Best,

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
 [1] Homo.sapiens_1.3.1                      TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
 [3] org.Hs.eg.db_3.3.0                      GO.db_3.3.0                            
 [5] OrganismDbi_1.14.1                      GenomicFeatures_1.24.5                 
 [7] AnnotationDbi_1.34.4                    Biobase_2.32.0                         
 [9] GenomicRanges_1.24.3                    GenomeInfoDb_1.8.7                     
[11] IRanges_2.6.1                           S4Vectors_0.10.3                       
[13] biovizBase_1.20.0                       ggbio_1.20.2                           
[15] ggplot2_2.1.0                           BiocGenerics_0.18.0                    

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7                   lattice_0.20-34               Rsamtools_1.24.0             
 [4] Biostrings_2.40.2             digest_0.6.10                 mime_0.5                     
 [7] R6_2.1.3                      plyr_1.8.4                    chron_2.3-47                 
[10] acepack_1.3-3.3               RSQLite_1.0.0                 httr_1.2.1                   
[13] BiocInstaller_1.22.3          zlibbioc_1.18.0               data.table_1.9.6             
[16] rpart_4.1-10                  Matrix_1.2-7.1                labeling_0.3                 
[19] splines_3.3.1                 BiocParallel_1.6.6            AnnotationHub_2.4.2          
[22] stringr_1.1.0                 foreign_0.8-67                RCurl_1.95-4.8               
[25] biomaRt_2.28.0                munsell_0.4.3                 shiny_0.14                   
[28] httpuv_1.3.3                  rtracklayer_1.32.2            htmltools_0.3.5              
[31] nnet_7.3-12                   SummarizedExperiment_1.2.3    gridExtra_2.2.1              
[34] interactiveDisplayBase_1.10.3 Hmisc_3.17-4                  XML_3.98-1.4                 
[37] reshape_0.8.5                 GenomicAlignments_1.8.4       bitops_1.0-6                 
[40] RBGL_1.48.1                   grid_3.3.1                    xtable_1.8-2                 
[43] GGally_1.2.0                  gtable_0.2.0                  DBI_0.5-1                    
[46] magrittr_1.5                  scales_0.4.0                  graph_1.50.0                 
[49] stringi_1.1.1                 XVector_0.12.1                reshape2_1.4.1               
[52] latticeExtra_0.6-28           Formula_1.2-1                 RColorBrewer_1.1-2           
[55] ensembldb_1.4.7               tools_3.3.1                   dichromat_2.0-0              
[58] BSgenome_1.40.1               survival_2.39-5               colorspace_1.2-6             
[61] cluster_2.0.4                 VariantAnnotation_1.18.7     
 
 

 

ggbio ggplot2 title typography • 808 views
ADD COMMENT
0
Entering edit mode

This issue was solved by Michael Lawrence in ggbio 1.21.6 version.

Thanks

ADD REPLY
0
Entering edit mode

Dear Michael Lawrence,

I posted this comment as a new question. It was really long.

Thanks,

Oswaldo

ADD REPLY

Login before adding your answer.

Traffic: 222 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