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.
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
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)
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)
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,
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:  LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252  LC_MONETARY=English_United States.1252 LC_NUMERIC=C  LC_TIME=English_United States.1252 attached base packages:  stats4 parallel stats graphics grDevices utils datasets methods base other attached packages:  Homo.sapiens_1.3.1 TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2  org.Hs.eg.db_3.3.0 GO.db_3.3.0  OrganismDbi_1.14.1 GenomicFeatures_1.24.5  AnnotationDbi_1.34.4 Biobase_2.32.0  GenomicRanges_1.24.3 GenomeInfoDb_1.8.7  IRanges_2.6.1 S4Vectors_0.10.3  biovizBase_1.20.0 ggbio_1.20.2  ggplot2_2.1.0 BiocGenerics_0.18.0 loaded via a namespace (and not attached):  Rcpp_0.12.7 lattice_0.20-34 Rsamtools_1.24.0  Biostrings_2.40.2 digest_0.6.10 mime_0.5  R6_2.1.3 plyr_1.8.4 chron_2.3-47  acepack_1.3-3.3 RSQLite_1.0.0 httr_1.2.1  BiocInstaller_1.22.3 zlibbioc_1.18.0 data.table_1.9.6  rpart_4.1-10 Matrix_1.2-7.1 labeling_0.3  splines_3.3.1 BiocParallel_1.6.6 AnnotationHub_2.4.2  stringr_1.1.0 foreign_0.8-67 RCurl_1.95-4.8  biomaRt_2.28.0 munsell_0.4.3 shiny_0.14  httpuv_1.3.3 rtracklayer_1.32.2 htmltools_0.3.5  nnet_7.3-12 SummarizedExperiment_1.2.3 gridExtra_2.2.1  interactiveDisplayBase_1.10.3 Hmisc_3.17-4 XML_3.98-1.4  reshape_0.8.5 GenomicAlignments_1.8.4 bitops_1.0-6  RBGL_1.48.1 grid_3.3.1 xtable_1.8-2  GGally_1.2.0 gtable_0.2.0 DBI_0.5-1  magrittr_1.5 scales_0.4.0 graph_1.50.0  stringi_1.1.1 XVector_0.12.1 reshape2_1.4.1  latticeExtra_0.6-28 Formula_1.2-1 RColorBrewer_1.1-2  ensembldb_1.4.7 tools_3.3.1 dichromat_2.0-0  BSgenome_1.40.1 survival_2.39-5 colorspace_1.2-6  cluster_2.0.4 VariantAnnotation_1.18.7