Giter Club home page Giter Club logo

spiralize's Introduction

Visualize Data on Spirals

R-CMD-check CRAN CRAN

Features

The package spiralize visualizes data along an Archimedean spiral. It has two major advantages for visualization:

  1. It is able to visualize data with very long axis with high resolution.
  2. It is efficient for time series data to reveal periodic patterns.

Documentation

https://jokergoo.github.io/spiralize/

Citation

Zuguang Gu, et al., spiralize: an R package for Visualizing Data on Spirals, Bioinformatics, 2021. https://doi.org/10.1093/bioinformatics/btab778

Install

The package is available on CRAN and can be installed by:

install.packages("spiralize")

If you want the latest version, install it directly from GitHub:

library(devtools)
install_github("jokergoo/spiralize")

Usage

It includes three steps:

  1. initialize the spiral,
  2. add a track,
  3. add graphics to the track.

Step 2 and 3 can be applied multiple times to allow multiple-track visualization along the spiral.

The code for making spiral plot looks likes follows:

library(spiralize)
spiral_initialize(...)
spiral_track(...)
spiral_points(...)
...

Graphics

Complex plots are baiscally constructed from simple graphics. Here there are following low-level graphics functions:

  • spiral_points()
  • spiral_lines()
  • spiral_rect()
  • spiral_segments()
  • spiral_polygon()
  • spiral_bars()
  • spiral_text()
  • spiral_axis()
  • spiral_yaxis()
  • spiral_raster()

Particularlly, horizon chart is very suitable to put on the spiral, thus there is one function for this:

  • spiral_horizon()

Spiral plot can also visualize dendrograms with large number of leaves, thus there are following two functions:

  • spiral_dendrogram()
  • spiral_phylo()

Examples

  1. Difference of ggplot2 daily downloads to the mean of the current year (2015-2021). Each loop contains 52 weeks so that same weeks in different years locate at the same angle in the polar coordinates.

  1. A phylogenetic life tree with 50645 species.

  1. The spiral COVID-19 Shiny app

License

MIT @ Zuguang Gu

spiralize's People

Contributors

jokergoo avatar

Stargazers

 avatar W. Joel Schneider avatar tianwen_TAN avatar Andreas Dutzler avatar Josep Pueyo-Ros avatar CWCWW avatar Altay Yuzeir avatar Raphael Saldanha avatar Vilius Puidokas avatar Paul Cryan avatar  avatar Krystal Won avatar  avatar HDZ avatar Halil İbrahim Ergül avatar Lakhansing Pardeshi avatar  avatar Billy Rowell avatar Gleb Ebert avatar  avatar  avatar Ge-Zhang avatar  avatar Mohammed Hamdy avatar  avatar  avatar Yonatan D. E. avatar JunJun avatar H Wrightson avatar Curro Campuzano avatar Pan Haoran avatar AndyGru avatar Philipp A. avatar Iker Rivas-González avatar Jie Zhu avatar Qing LIU avatar Leon Xiao avatar  avatar  avatar Neto Silveira avatar Huan Yang avatar  avatar Biront avatar  avatar libaoshen avatar  avatar GeoLibra avatar AaronCao avatar Chengxi Zang avatar  avatar Wei Zhai avatar vk avatar Bingjie Liu avatar Fu Yan avatar yangji avatar Mashiro avatar lvwzhen avatar Clearlove avatar AlexHang avatar  avatar Ben avatar susiwen8 avatar  avatar Calvin Yu avatar  avatar  avatar Joey Tsui avatar Mark Keller avatar SEHI L'YI avatar Loukas Theodosiou avatar  avatar Rafael Belokurows avatar Isabella Velásquez avatar  avatar Kozo Nishida avatar Aurélien Ginolhac avatar  avatar  avatar Amber Rivera avatar João Palmeiro avatar Asmus Harre avatar Petros Morfiris avatar Jan Simson avatar Heather Zurel avatar Carlos avatar Julia avatar Jimmy Briggs avatar Hao Li avatar Felipe Mattioni Maturana, Ph.D. avatar  avatar Xiaogang He avatar Marco Sciaini avatar Mauro Maver avatar Cédric Scherer avatar  avatar Marian Eberl avatar Minghao Jiang avatar Ruì avatar W. A. Corrales avatar Miao Cai avatar

Watchers

Kozo Nishida avatar  avatar timelyportfolio avatar James Cloos avatar Sheng Wang avatar  avatar

spiralize's Issues

Two spirals in the same plot

Hi @jokergoo

How can I create two spirals with different start and end angles in the same plot? I was trying to use twice the spiral_initialize function and the newpage parameter sets to False, but it is not working correctly.

Best

spiral_text slightly off each year

Hi,

I was following the global temperature change example in your vignette but I produced a plot that has the years label slightly off.

library(spiralize)
library(ComplexHeatmap)
library(lubridate)
eg <- data.frame(date = ymd(20000101) + days(0:3652), num = rnorm(3653, 100, 20))

spiral_initialize_by_time(
  xlim = range(eg$date),
  unit_on_axis = "days",
  period = "month",
  period_per_loop = 12)

spiral_track()
lt = spiral_horizon(eg$date, eg$num, use_bar = TRUE)
spiral_text("2000-01-01", 0.5, "2000", gp = gpar(fontsize = 8))
spiral_text("2001-01-01", 0.5, "2001", gp = gpar(fontsize = 8))
spiral_text("2002-01-01", 0.5, "2002", gp = gpar(fontsize = 8))
spiral_text("2003-01-01", 0.5, "2003", gp = gpar(fontsize = 8))
spiral_text("2004-01-01", 0.5, "2004", gp = gpar(fontsize = 8))
spiral_text("2005-01-01", 0.5, "2005", gp = gpar(fontsize = 8))
spiral_text("2006-01-01", 0.5, "2006", gp = gpar(fontsize = 8))
spiral_text("2007-01-01", 0.5, "2007", gp = gpar(fontsize = 8))
spiral_text("2008-01-01", 0.5, "2008", gp = gpar(fontsize = 8))
spiral_text("2009-01-01", 0.5, "2009", gp = gpar(fontsize = 8))
spiral_text("2010-01-01", 0.5, "2010", gp = gpar(fontsize = 8))
lgd = horizon_legend(lt, title = "Random")
draw(lgd, x = unit(1, "npc") + unit(2, "mm"), just = "left")

image

I tried to set normalize_year to TRUE but then I get an error: Error in as.POSIXlt.numeric(pos) : 'origin' must be supplied .

library(spiralize)
library(ComplexHeatmap)
library(lubridate)
eg <- data.frame(date = ymd(20000101) + days(0:3652), num = rnorm(3653, 100, 20))

spiral_initialize_by_time(
  xlim = range(eg$date),
  unit_on_axis = "days",
  period = "month",
  period_per_loop = 12,
  normalize_year = TRUE)

spiral_track()
lt = spiral_horizon(eg$date, eg$num, use_bar = TRUE)
Error in as.POSIXlt.numeric(pos) : 'origin' must be supplied

May you let me know how I can align the years?

Many thanks,
Dave

Some questions about using the library

Hi @jokergoo

I would be interested in using your library for plotting some multivariate longitudinal data. I was wondering the following:

1- Is it possible to create a spiral not by using the Archimedean formula, but the method of two points centers?
2- If a create different spirals, is possible to fill the space between spirals by doing a color interpolation method?

Best regards and thanks

Darker colours in spiral_horizon

Hello!

I think I'm misunderstanding something. I have a table with 2 columns: a date column, and a count of events by day column. e.g.

image

Using the following:

`
spiral_initialize_by_time(xlim = range(df$date), padding = unit(2, "cm"), start = 90, flip = "horizontal")

spiral_track(height = 0.8, background=FALSE)

spiral_horizon(df$date, df$count, use_bars = TRUE)
`

I would expect a spiral with coloured bars representing counts on each day. Where my count is highest, the bars return the most vibrant colour.

However, I occasionally have bars where the bottom half is a dark colour, and the top half is a light colour. Considering the shape of my data I don't understand what this extra colour is representing. Please could you clarify?

Many thanks,

TRACK_META$xlim

it should return the value corresponding to data, e.g. genomic positions

Color phylogenetic tree branches according to species name

I am using spiralize package to visualize phylogenetic tree.
By reading the manual, I found the color_branches( ) function can color branches according to h or k parameters.

Here I want to know is there any function can color branches according to species name, which I think is very important information in phylogenetic analyses.

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.