Skip to content

Instantly share code, notes, and snippets.

@richgillin
Created November 19, 2018 20:22
Show Gist options
  • Save richgillin/cb907a171ea135567200d1b45a432154 to your computer and use it in GitHub Desktop.
Save richgillin/cb907a171ea135567200d1b45a432154 to your computer and use it in GitHub Desktop.
Marques venn
---
title: "marques"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Assistance for A. Marques
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r VennDiagram, echo=FALSE}
if (!require(VennDiagram)) install.packages("VennDiagram"); library(VennDiagram)
```
### my data source: https://plus.google.com/104549605692757325251
```{r data, echo=FALSE}
frag1 <-
c(
"Luehea spp",
"Anadenanthera spp",
"Diptychandra aurantiaca",
"Dipteryx alata",
"Psidium sartorianum",
"Mabea fistulifera",
"Terminalia argentea",
"Agonandra brasiliensis",
"Copaifera langsdorffii",
"Pterodon spp",
"Jacaranda cuspidifolia",
"Machaerium acutifolium",
"Cordiera macrophylla",
"Alibertia edulis",
"Terminalia glabrescens",
"Qualea grandiflora",
"Magonia pubescens",
"Attalea apoda"
)
frag2 <-
c(
"Andira vermifuga",
"Erythroxylum suberosum",
"Cupania vernales",
"Psidium sartorianum",
"Ocotea corymbosa",
"Mabea fistulifera",
"Diospyros hispida",
"Tabebuia aurea",
"Roupala montana",
"Copaifera langsdorffii",
"Pouteria ramiflora",
"Handroanthus ochraceus",
"Styrax ferrugineus",
"Tabernaemontana hystrix",
"Hancornia speciosa",
"Guarea guidonia",
"Terminalia glabrescens",
"Aegiphylla sellowiana",
"Qualea parviflora",
"Tapirira guianensis",
"Caryocar brasiliense",
"Xylopia aromatica",
"Miconia burchellii"
)
```
## Including Plots
```{r default, echo=FALSE}
v2 <- venn.diagram(
list(bm1 = frag1, bm2 = frag2),
fill = c("red", "blue"),
alpha = c(0.5, 0.5),
cat.cex = 1.5,
cex = 1.5,
filename = NULL
)
```
You can also embed plots, for example:
```{r BM, echo=TRUE}
grid.newpage()
grid.draw(v2)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r }
w <- venn.diagram(
list(BM1 = frag1, BM2 = frag2),
fill = c("white", "white"),
alpha = c(0.4, 0.4),
cat.cex = 2.0,
cex = 1.0,
fontfamily = "serif",
fontface = "italic",
cat.pos = 0,
#### mover titulo
cat.dist = 0.03,
#### distância do titulo
cat.fontfamily = "serif",
#### fonte titulo
filename = NULL
)
```
## Over-write labels (7 to 10 chosen by manual check of labels)
#### frag1 only
```{r }
w[[6]]$label <- paste(setdiff(frag1, frag2), collapse = "\n")
```
#### in frag2 only
```{r }
w[[5]]$label <- paste(setdiff(frag2, frag1) , collapse = "\n")
```
#### intesection frag1 and frag2
```{r }
w[[7]]$label <- paste(intersect(frag1, frag2), collapse = "\n")
```
## plot TODO proper sizing for text inside venn
```{r vennBM}
# png(file="vennBM.png", width=1228, height=795)
svg(file="vennBM.svg", width=10, height=6.60)
grid.newpage()
grid.draw(w)
#dev.off()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment