trackViewer Vignette: dandelionPlot

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.4.2 (2024-10-31) Platform: x86_64-pc-linux-gnu Running under: Ubuntu 24.04.1 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Etc/UTC tzcode source: system (glibc)

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

other attached packages: [1] httr_1.4.7
[2] VariantAnnotation_1.53.0
[3] Rsamtools_2.23.1
[4] Biostrings_2.75.2
[5] XVector_0.47.0
[6] SummarizedExperiment_1.37.0
[7] MatrixGenerics_1.19.0
[8] matrixStats_1.4.1
[9] org.Hs.eg.db_3.20.0
[10] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 [11] GenomicFeatures_1.59.1
[12] AnnotationDbi_1.69.0
[13] Biobase_2.67.0
[14] Gviz_1.51.0
[15] rtracklayer_1.67.0
[16] trackViewer_1.43.5
[17] GenomicRanges_1.59.1
[18] GenomeInfoDb_1.43.2
[19] IRanges_2.41.2
[20] S4Vectors_0.45.2
[21] BiocGenerics_0.53.3
[22] generics_0.1.3

loaded via a namespace (and not attached): [1] strawr_0.0.92 RColorBrewer_1.1-3 sys_3.4.3
[4] rstudioapi_0.17.1 jsonlite_1.8.9 magrittr_2.0.3
[7] rmarkdown_2.29 BiocIO_1.17.1 zlibbioc_1.52.0
[10] vctrs_0.6.5 memoise_2.0.1 RCurl_1.98-1.16
[13] base64enc_0.1-3 htmltools_0.5.8.1 S4Arrays_1.7.1
[16] progress_1.2.3 curl_6.0.1 Rhdf5lib_1.29.0
[19] rhdf5_2.51.1 SparseArray_1.7.2 Formula_1.2-5
[22] sass_0.4.9 bslib_0.8.0 htmlwidgets_1.6.4
[25] httr2_1.0.7 cachem_1.1.0 buildtools_1.0.0
[28] GenomicAlignments_1.43.0 lifecycle_1.0.4 pkgconfig_2.0.3
[31] Matrix_1.7-1 R6_2.5.1 fastmap_1.2.0
[34] GenomeInfoDbData_1.2.13 digest_0.6.37 colorspace_2.1-1
[37] Hmisc_5.2-1 RSQLite_2.3.9 filelock_1.0.3
[40] fansi_1.0.6 abind_1.4-8 compiler_4.4.2
[43] bit64_4.5.2 htmlTable_2.4.3 backports_1.5.0
[46] BiocParallel_1.41.0 DBI_1.2.3 biomaRt_2.63.0
[49] rappdirs_0.3.3 DelayedArray_0.33.3 rjson_0.2.23
[52] tools_4.4.2 foreign_0.8-87 nnet_7.3-19
[55] glue_1.8.0 InteractionSet_1.35.0 restfulr_0.0.15
[58] rhdf5filters_1.19.0 checkmate_2.3.2 cluster_2.1.7
[61] gtable_0.3.6 BSgenome_1.75.0 ensembldb_2.31.0
[64] data.table_1.16.4 hms_1.1.3 xml2_1.3.6
[67] utf8_1.2.4 pillar_1.9.0 stringr_1.5.1
[70] dplyr_1.1.4 BiocFileCache_2.15.0 lattice_0.22-6
[73] bit_4.5.0.1 deldir_2.0-4 biovizBase_1.55.0
[76] tidyselect_1.2.1 maketools_1.3.1 knitr_1.49
[79] gridExtra_2.3 ProtGenerics_1.39.0 xfun_0.49
[82] stringi_1.8.4 UCSC.utils_1.3.0 lazyeval_0.2.2
[85] yaml_2.3.10 evaluate_1.0.1 codetools_0.2-20
[88] interp_1.1-6 tibble_3.2.1 BiocManager_1.30.25
[91] cli_3.6.3 rpart_4.1.23 munsell_0.5.1
[94] jquerylib_0.1.4 dichromat_2.0-0.1 Rcpp_1.0.13-1
[97] grImport_0.9-7 dbplyr_2.5.0 png_0.1-8
[100] XML_3.99-0.17 parallel_4.4.2 ggplot2_3.5.1
[103] blob_1.2.4 prettyunits_1.2.0 latticeExtra_0.6-30
[106] jpeg_0.1-10 AnnotationFilter_1.31.0 bitops_1.0-9
[109] txdbmaker_1.3.1 scales_1.3.0 crayon_1.5.3
[112] BiocStyle_2.35.0 rlang_1.1.4 KEGGREST_1.47.0