Can anyone suggest me how to generate the plot in B or C shown in the following paper in R. Thanks in advance

http://www.genomebiology.com/2013/14/2/R17/figure/F3?highres=y

Flower plot in R ?

6

Entering edit mode

7.5 years ago

dsarbashis
▴
60

Can anyone suggest me how to generate the plot in B or C shown in the following paper in R. Thanks in advance

http://www.genomebiology.com/2013/14/2/R17/figure/F3?highres=y

4

Entering edit mode

4.7 years ago

Zhilong Jia
★
2.1k

The code is from http://www.cnblogs.com/xudongliang/p/7884667.html with a minor update. the R package `plotrix`

is mainly used (ref this package to get parameter information).

```
flower_plot <- function(sample, value, start, a, b,
ellipse_col = rgb(135, 206, 235, 150, max = 255),
circle_col = rgb(0, 162, 214, max = 255),
circle_text_cex = 1, labels=labels) {
par( bty = "n", ann = F, xaxt = "n", yaxt = "n", mar = c(1,1,1,1))
plot(c(0,10),c(0,10),type="n")
n <- length(sample)
deg <- 360 / n
res <- lapply(1:n, function(t){
plotrix::draw.ellipse(x = 5 + cos((start + deg * (t - 1)) * pi / 180),
y = 5 + sin((start + deg * (t - 1)) * pi / 180),
col = ellipse_col,
border = ellipse_col,
a = a, b = b, angle = deg * (t - 1))
text(x = 5 + 2.5 * cos((start + deg * (t - 1)) * pi / 180),
y = 5 + 2.5 * sin((start + deg * (t - 1)) * pi / 180),
value[t]
)
if (deg * (t - 1) < 180 && deg * (t - 1) > 0 ) {
text(x = 5 + 3.3 * cos((start + deg * (t - 1)) * pi / 180),
y = 5 + 3.3 * sin((start + deg * (t - 1)) * pi / 180),
sample[t],
srt = deg * (t - 1) - start,
adj = 1,
cex = circle_text_cex
)
} else {
text(x = 5 + 3.3 * cos((start + deg * (t - 1)) * pi / 180),
y = 5 + 3.3 * sin((start + deg * (t - 1)) * pi / 180),
sample[t],
srt = deg * (t - 1) + start,
adj = 0,
cex = circle_text_cex
)
}
})
plotrix::draw.circle(x = 5, y = 5, r = 1.5, col = circle_col, border = circle_col)
text(x = 4.7, y = 5, labels=labels)
}
```

Example like this:

```
flower_plot(c("WSM419", "A321", "M1", "M2", "M22", "M58",
"M102", "M161", "KH36b", "KH36c", "KH36d", "KH53a", "KH53b"),
c(519, 556, 83, 62, 415, 425, 357, 441, 22, 41, 33, 44, 43), 90, 0.5, 2, labels="core")
```

Results will be:

0

Entering edit mode

Thanks for your answer your function gives exact output. But if I wish to draw an another circle within the circle with same center (i.e. two circle with same center but different radius), what modifications we need to do? I tried draw.circle function with reduced radius but it was giving two different circles.

0

Entering edit mode

Hi,

Sorry for not understanding much about codes. My questions are:

**(1)** The circle's label, whenever I plot the graph, seems to be a little bit to the left (not centralized), is there any way to fix that?

**(2)** How can I add a second line label just like the plot from the article (it is written S. medicae in the first line and 5036 in the second line)?

**(3)** Is there any way to change the colors and keep them transparent just like the figure from the article?

**(4)** Can I change the colors of each ellipse instead of making them all blue?

I am trying to make a flower plot similar to the one from figure 2 in this article: http://www.mdpi.com/1422-0067/17/8/1355/htm

Thanks in advance.

Alec Watanabe

2

Entering edit mode

```
flower_plot2 <- function(sample, value, start, a, b,
ellipse_col = rgb(135, 206, 235, 150, max = 255),
circle_col = rgb(0, 162, 214, max = 255),
circle_text_cex = 1, labels=labels) {
par( bty = "n", ann = F, xaxt = "n", yaxt = "n", mar = c(1,1,1,1))
plot(c(0,10),c(0,10),type="n")
n <- length(sample)
deg <- 360 / n
res <- lapply(1:n, function(t){
ellipse_col <- ellipse_col[t]
plotrix::draw.ellipse(x = 5 + cos((start + deg * (t - 1)) * pi / 180),
y = 5 + sin((start + deg * (t - 1)) * pi / 180),
col = ellipse_col,
border = ellipse_col,
a = a, b = b, angle = deg * (t - 1))
text(x = 5 + 2.5 * cos((start + deg * (t - 1)) * pi / 180),
y = 5 + 2.5 * sin((start + deg * (t - 1)) * pi / 180),
value[t]
)
if (deg * (t - 1) < 180 && deg * (t - 1) > 0 ) {
text(x = 5 + 3.3 * cos((start + deg * (t - 1)) * pi / 180),
y = 5 + 3.3 * sin((start + deg * (t - 1)) * pi / 180),
sample[t],
srt = deg * (t - 1) - start,
adj = 1,
cex = circle_text_cex
)
} else {
text(x = 5 + 3.3 * cos((start + deg * (t - 1)) * pi / 180),
y = 5 + 3.3 * sin((start + deg * (t - 1)) * pi / 180),
sample[t],
srt = deg * (t - 1) + start,
adj = 0,
cex = circle_text_cex
)
}
})
plotrix::draw.circle(x = 5, y = 5, r = 1.5, col = circle_col, border = circle_col )
# tune location by x and y.
text(x = 4.7, y = 5, labels=labels)
}
flower_plot2 (c("WSM419\nAAA", "A321", "M1", "M2", "M22", "M58",
"M102", "M161", "KH36b", "KH36c", "KH36d", "KH53a", "KH53b"),
c(519, 556, 83, 62, 415, 425, 357, 441, 22, 41, 33, 44, 43), 90, 0.5, 2, labels="core",
ellipse_col = topo.colors(13, alpha = 0.3),
circle_col = topo.colors(1, alpha = 0.7) )
```

1) tune `x, y`

in the last line of the function `flower_plot`

code as annotated.
2) I did not get your idea. maybe like "WSM419\nAAA".
3) input the transparented color will solve it.
4) parameter `ellipse_col`

.

2

Entering edit mode

12 months ago

roder.thomas
▴
20

I developed a small Python script to do this:

Similar Posts

Loading Similar Posts

Traffic: 1490 users visited in the last hour

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

I don't know of a library that produces such plots.

That said, I don't find those plots very informative. What does the plot add over a table? What story is the plot meant to show? Does the plot accurately portray the data?

It's likely that those were made in Adobe Illustrator or powerpoint. As Sean Davis said, those sorts of plots should be replaced with tables, which are easier to interpret.

As an alternative, you might consider an UpSet plot as described here:

http://www.caleydo.org/tools/upset/

https://cran.r-project.org/web/packages/UpSetR/vignettes/basic.usage.html

https://github.com/hms-dbmi/UpSetR

Hi Sean,

Thank you for your response. Representing common and unique value between large number of data sets this is one of the good approach and better than a long table with numeric numbers.

I fully agree that a good plot is better than a table, but plots B and C are not good plots. They are misleading and not quantitative. To be more constructive, If there are overlaps between the groups, consider using a 2-d representation such as a heatmap with each cell representing the overlap between pairs of "petals". If there are no overlaps, consider a bar plot of the "petals" or simply use a table.

I realize you asked for R, but if you can't find an R script, maybe you can use this:

http://matplotlib.org/examples/pylab_examples/ellipse_rotated.html

http://matplotlib.org/gallery.html

Thank you all for the helpful responses.

Isn't this just Venn diagram with many many entries? Just guessing.

It looks like one, but it isn't.

I didn't look too closely; just remembered seeing it at some point. :)

Dear dsarbashis, Did you find out how to plot these figures? I'm also trying to do it. Thanks!

Dear dsarbashis, Did you find out how to plot these figures? I'm also trying to build them but not able to find a proper library in R or Python. Thanks in advance

I would suggest to be careful with this kind of plot, which is prone to ambiguities and misinterpreation. See a paper on the closely-related petal plot for reference.