# trackViewer Vignette: dandelionPlot

#### Jianhong Ou, Lihua Julie Zhu

#### 17 May 2023

Abstract

Visualize high dense methylation or mutation data along with annotation as track layers via Dandelion Plot.

# Dandelion Plot

Sometimes, there are as many as hundreds of SNPs invoved in one gene. Dandelion plot can be used to depict such dense SNPs. Please note that the height of the dandelion indicates the desity of the SNPs.

    library(trackViewer)
    library(TxDb.Hsapiens.UCSC.hg19.knownGene)
    library(org.Hs.eg.db)
    library(rtracklayer)
    methy <- import(system.file("extdata", "methy.bed", package="trackViewer"), "BED")
    gr <- GRanges("chr22", IRanges(50968014, 50970514, names="TYMP"))
    trs <- geneModelFromTxdb(TxDb.Hsapiens.UCSC.hg19.knownGene,
                             org.Hs.eg.db,
                             gr=gr)
    features <- c(range(trs[[1]]$dat), range(trs[[5]]$dat))
    names(features) <- c(trs[[1]]$name, trs[[5]]$name)
    features$fill <- c("lightblue", "mistyrose")
    features$height <- c(.02, .04)
    dandelion.plot(methy, features, ranges=gr, type="pin")

## Change the type of Dandelion plot

There are one more type for dandelion plot, i.e., type “fan”. The area of the fan indicates the percentage of methylation or rate of mutation.

    methy$color <- 3
    methy$border <- "gray"
    ## Score info is required and the score must be a number in [0, 1]
    m <- max(methy$score)
    methy$score <- methy$score/m
    dandelion.plot(methy, features, ranges=gr, type="fan")

    methy$color <- rep(list(c(3, 5)), length(methy))
    methy$score2 <- (max(methy$score) - methy$score)/m
    legends <- list(list(labels=c("s1", "s2"), fill=c(3, 5)))
    dandelion.plot(methy, features, ranges=gr, type="pie", legend=legends)

## Change the number of dandelions

    ## Less dandelions
    dandelion.plot(methy, features, ranges=gr, type="circle", maxgaps=1/10)

    ## More dandelions
    dandelion.plot(methy, features, ranges=gr, type="circle", maxgaps=1/100)

Users can also specify the maximum distance between neighboring dandelions by setting the maxgaps as a GRanges object.

    maxgaps <- tile(gr, n = 10)[[1]]
    dandelion.plot(methy, features, ranges=gr, type="circle", maxgaps=maxgaps)

## Add y-axis (yaxis)

Set yaxis to TRUE to add y-axis, and set `heightMethod`=`mean` to use the mean score as the height.

    dandelion.plot(methy, features, ranges=gr, type="pie",
                   maxgaps=1/100, yaxis = TRUE, heightMethod = mean,
                   ylab='mean of methy scores')

    yaxis = c(0, 0.5, 1)
    dandelion.plot(methy, features, ranges=gr, type="pie",
                   maxgaps=1/100, yaxis = yaxis, heightMethod = mean,
                   ylab='mean of methy scores')

# Session Info

    sessionInfo()

R version 4.3.0 RC (2023-04-13 r84269 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server 2022 x64 (build 20348)

Matrix products: default

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

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] httr_1.4.6
[2] VariantAnnotation_1.46.0
[3] Rsamtools_2.16.0
[4] Biostrings_2.68.1
[5] XVector_0.40.0
[6] SummarizedExperiment_1.30.1
[7] MatrixGenerics_1.12.0
[8] matrixStats_0.63.0
[9] org.Hs.eg.db_3.17.0
[10] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 [11] GenomicFeatures_1.52.0
[12] AnnotationDbi_1.62.1
[13] Biobase_2.60.0
[14] Gviz_1.44.0
[15] rtracklayer_1.60.0
[16] trackViewer_1.36.2
[17] GenomicRanges_1.52.0
[18] GenomeInfoDb_1.36.0
[19] IRanges_2.34.0
[20] S4Vectors_0.38.1
[21] BiocGenerics_0.46.0

loaded via a namespace (and not attached): [1] strawr_0.0.91 RColorBrewer_1.1-3 rstudioapi_0.14
[4] jsonlite_1.8.4 magrittr_2.0.3 rmarkdown_2.21
[7] BiocIO_1.10.0 zlibbioc_1.46.0 vctrs_0.6.2
[10] memoise_2.0.1 RCurl_1.98-1.12 base64enc_0.1-3
[13] htmltools_0.5.5 S4Arrays_1.0.4 progress_1.2.2
[16] plotrix_3.8-2 curl_5.0.0 Rhdf5lib_1.22.0
[19] Formula_1.2-5 rhdf5_2.44.0 sass_0.4.6
[22] bslib_0.4.2 htmlwidgets_1.6.2 cachem_1.0.8
[25] GenomicAlignments_1.36.0 lifecycle_1.0.3 pkgconfig_2.0.3
[28] Matrix_1.5-4 R6_2.5.1 fastmap_1.1.1
[31] GenomeInfoDbData_1.2.10 digest_0.6.31 colorspace_2.1-0
[34] Hmisc_5.1-0 RSQLite_2.3.1 filelock_1.0.2
[37] fansi_1.0.4 compiler_4.3.0 bit64_4.0.5
[40] htmlTable_2.4.1 backports_1.4.1 BiocParallel_1.34.1
[43] DBI_1.1.3 highr_0.10 biomaRt_2.56.0
[46] rappdirs_0.3.3 DelayedArray_0.26.2 rjson_0.2.21
[49] tools_4.3.0 foreign_0.8-84 nnet_7.3-19
[52] glue_1.6.2 restfulr_0.0.15 InteractionSet_1.28.0
[55] rhdf5filters_1.12.1 checkmate_2.2.0 cluster_2.1.4
[58] generics_0.1.3 gtable_0.3.3 BSgenome_1.68.0
[61] ensembldb_2.24.0 data.table_1.14.8 hms_1.1.3
[64] xml2_1.3.4 utf8_1.2.3 pillar_1.9.0
[67] stringr_1.5.0 dplyr_1.1.2 BiocFileCache_2.8.0
[70] lattice_0.21-8 bit_4.0.5 deldir_1.0-9
[73] biovizBase_1.48.0 tidyselect_1.2.0 knitr_1.42
[76] gridExtra_2.3 ProtGenerics_1.32.0 xfun_0.39
[79] stringi_1.7.12 lazyeval_0.2.2 yaml_2.3.7
[82] evaluate_0.21 codetools_0.2-19 interp_1.1-4
[85] tibble_3.2.1 Rgraphviz_2.44.0 BiocManager_1.30.20
[88] graph_1.78.0 cli_3.6.1 rpart_4.1.19
[91] munsell_0.5.0 jquerylib_0.1.4 dichromat_2.0-0.1
[94] Rcpp_1.0.10 grImport_0.9-7 dbplyr_2.3.2
[97] png_0.1-8 XML_3.99-0.14 parallel_4.3.0
[100] ellipsis_0.3.2 ggplot2_3.4.2 blob_1.2.4
[103] prettyunits_1.1.1 latticeExtra_0.6-30 jpeg_0.1-10
[106] AnnotationFilter_1.24.0 bitops_1.0-7 scales_1.2.1
[109] crayon_1.5.2 BiocStyle_2.28.0 rlang_1.1.1
[112] KEGGREST_1.40.0