-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
102 lines (77 loc) · 2.6 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ggpolar: Dots and Their Connections in Polar Coordinate System
[![ggpolar status badge](https://shixiangwang.r-universe.dev/badges/ggpolar)](https://shixiangwang.r-universe.dev)
[![CRAN
status](https://www.r-pkg.org/badges/version/ggpolar)](https://CRAN.R-project.org/package=ggpolar)
[![](https://cranlogs.r-pkg.org/badges/grand-total/ggpolar?color=blue)](https://cran.r-project.org/package=ggpolar)
`{ggpolar}` provides a very flexible way to create dots in coordinate system
for event list and connect the dots with segments based on [`{ggplot2}`](https://ggplot2.tidyverse.org/).
## Installation
You can install the released version of `{ggpolar}` from CRAN with:
``` r
install.packages("ggpolar")
```
You can install the development version of `{ggpolar}` from GitHub with:
``` r
remotes::install_github("ShixiangWang/polar")
```
## Example
### Init a polar plot
```{r example}
library(ggpolar)
data <- data.frame(x = LETTERS[1:7])
p1 <- polar_init(data, x = x)
p1
# Set aes value
p2 <- polar_init(data, x = x, size = 3, color = "red", alpha = 0.5)
p2
# Set aes mapping
set.seed(123L)
data1 <- data.frame(
x = LETTERS[1:7],
shape = c("r", "r", "r", "b", "b", "b", "b"),
color = c("r", "r", "r", "b", "b", "b", "b"),
size = abs(rnorm(7))
)
# Check https://ggplot2.tidyverse.org/reference/geom_point.html
# for how to use both stroke and color
p3 <- polar_init(data1, x = x, aes(size = size, color = color, shape = shape), alpha = 0.5)
p3
```
### Connect polar dots
```{r}
data2 <- data.frame(
x1 = LETTERS[1:7],
x2 = c("B", "C", "D", "E", "C", "A", "C"),
color = c("r", "r", "r", "b", "b", "b", "b")
)
p4 <- p3 + polar_connect(data2, x1, x2)
p4
# Unlike polar_init, mappings don't need to be included in aes()
p5 <- p3 + polar_connect(data2, x1, x2, color = color, alpha = 0.8, linetype = 2)
p5
# Use two different color scales
if (requireNamespace("ggnewscale")) {
library(ggnewscale)
p6 = p3 +
new_scale("color") +
polar_connect(data2, x1, x2, color = color, alpha = 0.8, linetype = 2)
print(p6 + scale_color_brewer())
print(p6 + scale_color_manual(values = c("darkgreen", "magenta")))
}
```
## Citation
If you use `{ggpolar}` in academic research, please cite the following paper along
with the GitHub repo.
*Antigen presentation and tumor immunogenicity in cancer immunotherapy response prediction*, __eLife__. https://doi.org/10.7554/eLife.49020.