Skip to content

Commit

Permalink
Create hex sticker
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Dec 3, 2021
1 parent d146fac commit f5763e8
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 20 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Suggests:
covr,
testthat (>= 3.0.0),
badger,
hexSticker,
utils
RoxygenNote: 7.1.2
VignetteBuilder: knitr
Expand Down
29 changes: 15 additions & 14 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
```{r, echo=FALSE, include=FALSE}
pkg <- read.dcf("DESCRIPTION", fields = "Package")[1]
description <- read.dcf("DESCRIPTION", fields = "Description")[1]
hex_url <- paste0('https://github.com/RajLabMSSM/',pkg,'raw/master/inst/hex/',pkg,'.png')
```

---
title: "README"
title: "<img src='`r hex_url`' height='300'>"
author: "<h4>Author: <i>Brian M. Schilder</i></h4>"
date: "<h4>Updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
output:
github_document
---

```{r, echo=FALSE, include=FALSE}
pkg <- read.dcf("DESCRIPTION", fields = "Package")[1]
description <- read.dcf("DESCRIPTION", fields = "Description")[1]
```


<!-- badges: start -->
`r badger::badge_github_version(color = "black")`
`r badger::badge_github_actions(action = "R-CMD-check-bioc")`
Expand All @@ -20,25 +20,26 @@ description <- read.dcf("DESCRIPTION", fields = "Description")[1]
`r badger::badge_license()`
<!-- badges: end -->

# echoverse: ``r pkg``

## `r description`
## `r gsub("echoverse module: ","", description)`

If you use ``r pkg``, please cite:

> Brian M Schilder, Jack Humphrey, Towfique Raj, echolocatoR: an automated end-to-end statistical and functional genomic fine-mapping pipeline, Bioinformatics, 2021;, btab658, [https://doi.org/10.1093/bioinformatics/btab658](https://doi.org/10.1093/bioinformatics/btab658)
> Brian M Schilder, Jack Humphrey, Towfique Raj (2021)
echolocatoR: an automated end-to-end statistical and functional genomic
fine-mapping pipeline, *Bioinformatics*; btab658, [https://doi.org/10.1093/bioinformatics/btab658](https://doi.org/10.1093/bioinformatics/btab658)

## Installation

```R
if(!require("remotes")) install.packages("remotes")

remotes::install_github("RajLabMSSM/`r pkg`")
library(`r pkg`)
```
## Documentation


## [Documentation website](https://rajlabmssm.github.io/`r pkg`)
## [Getting started vignette](https://rajlabmssm.github.io/`r pkg`/articles/`r pkg`)
### [Website](https://rajlabmssm.github.io/`r pkg`)
### [Getting started](https://rajlabmssm.github.io/`r pkg`/articles/`r pkg`)

<hr>

Expand Down
256 changes: 256 additions & 0 deletions README.html

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ README
Author: <i>Brian M. Schilder</i>
</h4>
<h4>
Updated: <i>Dec-02-2021</i>
Updated: <i>Dec-03-2021</i>
</h4>

<!-- badges: start -->
Expand All @@ -24,21 +24,25 @@ GPL-3](https://img.shields.io/badge/license-GPL--3-blue.svg)](https://cran.r-pro

If you use `echoverseTemplate`, please cite:

> Brian M Schilder, Jack Humphrey, Towfique Raj, echolocatoR: an
> Brian M Schilder, Jack Humphrey, Towfique Raj (2021) echolocatoR: an
> automated end-to-end statistical and functional genomic fine-mapping
> pipeline, Bioinformatics, 2021;, btab658,
> pipeline, *Bioinformatics*; btab658,
> <https://doi.org/10.1093/bioinformatics/btab658>
## Installation

``` r
if(!require("remotes")) install.packages("remotes")

remotes::install_github("RajLabMSSM/echoverseTemplate")
library(echoverseTemplate)
```

## [Documentation website](https://rajlabmssm.github.io/echoverseTemplate)
## Documentation

### [Website](https://rajlabmssm.github.io/echoverseTemplate)

## [Getting started vignette](https://rajlabmssm.github.io/echoverseTemplate/articles/echoverseTemplate)
### [Getting started](https://rajlabmssm.github.io/echoverseTemplate/articles/echoverseTemplate)

<hr>

Expand Down
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
citHeader("To cite echodata in publications use:")
citHeader("To cite this echoverse package, please use:")

citEntry(
entry = "Article",
Expand Down
Binary file added inst/hex/echoverseTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions inst/hex/hexSticker.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: "hexSticker"
author: "<h4>Author: <i>Brian M. Schilder</i></h4>"
date: "<h4>Updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
output:
BiocStyle::html_document
vignette: >
%\VignetteIndexEntry{hexSticker}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, echo=FALSE, include=FALSE}
pkg <- read.dcf("DESCRIPTION", fields = "Package")[1]
description <- read.dcf("DESCRIPTION", fields = "Description")[1]
```

You can make awesome hex stickers for your R packages using:

- [hexSticker](https://github.com/GuangchuangYu/hexSticker)
- [ggimage](https://github.com/GuangchuangYu/ggimage)
lets you render images as data points.
- [ggpattern](https://coolbutuseless.github.io/package/ggpattern/)
lets you fill objects with patterns or images.
- [magick](https://cran.r-project.org/web/packages/magick/vignettes/intro.html)
modify PNGs.

# `r pkg`

```{r setup}
# If you're using R<4.1.1, need this version of rvcheck
# devtools::install_version('rvcheck',version='0.1.8')
library(hexSticker)
library(dplyr)
library(ggplot2)
library(ggimage)
# library(ggpattern)# remotes::install_github("coolbutuseless/ggpattern")
```

## File path

Create file path.

```{r}
filename <- here::here("inst/hex", paste0(pkg,".png"))
# filename <- file.path(tempdir(), paste0(pkg,".png"))
dir.create(dirname(filename), showWarnings = FALSE, recursive = TRUE)
```

## Bat logo

Download bat logo from the
[*Fine_Mapping*](https://github.com/RajLabMSSM/Fine_Mapping) GitHub repo.

```{r}
tmp <- tempfile()
#### Side view ####
URL <- "https://github.com/RajLabMSSM/Fine_Mapping/raw/master/echolocatoR/images/bat_silhouette.png"
#### Front view ####
# URL <- "https://github.com/RajLabMSSM/Fine_Mapping/raw/master/echolocatoR/images/bat_silhouette_front.png"
download.file(URL, tmp)
```

## Background

Create background with `ggplot2`.

```{r}
set.seed(1234)
n_bats <- 20
d <- data.frame(x = -rexp(n_bats, rate = 3),
y = rexp(n_bats, rate = 3)
) %>%
dplyr::mutate(image = URL,
bsize = abs(x*y^2)) %>%
dplyr::arrange(dplyr::desc(x), dplyr::desc(y))
qplot(d$x, d$y, size=d$bsize)
```


```{r}
gg_bats <- ggplot(d, aes(x = x, y = y, color=bsize, image=image)) +
geom_image(aes(size=I(bsize)), alpha=1) +
scale_color_gradient(low = "#194f68", high = "#56ffff") +
coord_cartesian(clip = "off") +
labs(title = "echoverse") +
theme_void() +
theme(plot.title = element_text(color = "#56ffff", size = 25,
hjust = .5, vjust = 5, family = "Aller_Rg"),
legend.position = "none")
print(gg_bats)
```

## hexSticker

```{r, eval=FALSE}
s_size = 1
stick <- hexSticker::sticker(
subplot = gg_bats,
#### Package name ####
package = pkg, p_size=14, p_y = 1.4,
#### Subplot #####
s_x=1, s_y=.8, s_height = s_size, s_width = s_size,
#### Fill & border ####
h_fill = "#25355c", h_color = "#41c6c8", #56ffff
#### Spotlight ####
spotlight = TRUE, l_alpha = .3, l_width = 10,
#### File output ####
filename = filename, dpi = 300)
print(stick)
```


# Session Info

<details>

```{r Session Info}
utils::sessionInfo()
```

</details>

0 comments on commit f5763e8

Please sign in to comment.