Skip to content

Commit

Permalink
Merge pull request #14 from bcbio/devel
Browse files Browse the repository at this point in the history
v0.1.1
  • Loading branch information
lpantano authored Apr 30, 2024
2 parents e147907 + 622fc1d commit 8efe765
Show file tree
Hide file tree
Showing 25 changed files with 737 additions and 78 deletions.
8 changes: 8 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
^\.github$
^README\.Rmd$
^LICENSE\.md$
^_pkgdown\.yml$
^docs$
^pkgdown$
^doc$
^Meta$
test/*
inst/*/*/*/*/*/*html
inst/*/*/*/*/*/*csv
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
*.Rproj
test/*
inst/*/*/*/*/*/*html
inst/*/*/*/*/*/*csv
inst/*/*/*/*/*/*csv
inst/doc
docs
/doc/
/Meta/
13 changes: 11 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bcbioR
Type: Package
Title: Templates and functions to guide downstream analysis and data interpretation
Version: 0.1.0
Version: 0.1.1
Authors@R: person("Pantano", "Lorena", , "[email protected]",
role = c("aut", "cre"))
Description: Collaborative code repository at the Harvard Chan Bioinformatics Core.
Expand All @@ -13,4 +13,13 @@ RoxygenNote: 7.3.1
Imports:
stringr,
ggplot2,
magrittr
magrittr,
hues,
ggprism,
grDevices,
R.utils
Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr
URL: http://bcb.io/bcbioR/
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Generated by roxygen2: do not edit by hand

export(bcbio_gitignore)
export(bcbio_set_project)
export(bcbio_start_project)
export(bcbio_templates)
export(cb_friendly_cols)
export(cb_friendly_pal)
export(list_cb_friendly_cols)
export(scale_color_cb_friendly)
export(scale_fill_cb_friendly)
import(R.utils)
import(ggplot2)
import(ggprism)
import(hues)
importFrom(grDevices,colorRampPalette)
importFrom(magrittr,"%>%")
importFrom(stringr,str_replace_all)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# bcbioR 0.1.1

* Add page to github
* Make CHECK to pass
* Add vignette
4 changes: 4 additions & 0 deletions R/bcbioR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
## usethis namespace: start
#' @importFrom magrittr %>%
#' @importFrom stringr str_replace_all
#' @importFrom grDevices colorRampPalette
## usethis namespace: end
#' @import ggplot2
#' @import hues
#' @import ggprism
#' @import R.utils
NULL
40 changes: 23 additions & 17 deletions R/cb_friendly.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' list of colorblind-friendly colors, developed by James and client
cb_friendly_colors <- c(
`blue` = "#2759F6",
`dark_purple` = "#402999",
`light_orange` = "#FFD37D",
`olive_green` = "olivedrab3",
`purple` = "#9176C8",
`pink` = "#E93380",
`sky_blue` = "#4FAEEB",
`blue_grey` = "#92A6BC",
`forest_green` = "#3C877B",
`pink` = "#E93380",
`olive_green` = "olivedrab3",
`yellow` = "yellow",
`light_orange` = "#FFD37D",
`dark_purple` = "#402999",
`dark_orange` = "#D5392C",
`army_green` = "#C3C380",
`black` = "black",
Expand All @@ -26,33 +26,37 @@ list_cb_friendly_cols <- function(){
}

#' fetch color from list by name
#'
#' @param ... list of color names
#'
#' @export
cb_friendly_cols <- function(...) {
cols <- c(...)

if (is.null(cols))
return (cb_friendly_colors)

cb_friendly_colors[cols]
}

#' define main colorblind-friendly palette as well as sub-palettes
cb_friendly_palettes <- list(
`main` = cb_friendly_cols("blue", "dark_purple", "purple", "sky_blue",
"blue_grey", "forest_green", "pink", "olive_green",
"yellow", "light_orange", "dark_orange",
"army_green", "black", "dark_grey", "light_blue",
"brown"),
`main` = cb_friendly_cols("blue", "purple", "sky_blue",
"blue_grey", "forest_green", "pink", "olive_green",
"yellow", "dark_purple", "dark_orange",
"army_green", "black", "dark_grey", "light_blue",
"brown","light_orange"),
`cool` = cb_friendly_cols("blue", "dark_purple", "purple", "sky_blue"),
`hot` = cb_friendly_cols("yellow", "light_orange", "dark_orange"),
`grey` = cb_friendly_cols("black", "dark_grey", "blue_grey"),
`heatmap` = cb_friendly_cols("blue", "white", "brown")
)

#' access cb friendly palette by name, reversing if necessary
#'
#'
#' @param palette name of the palette to be returned
#' @param reverse boolean, reverse order of colors in palette
#' @param ... pass to ggplot
#' @export
cb_friendly_pal <-function(palette = 'main', reverse = F, ...){
pal <- cb_friendly_palettes[[palette]]
Expand All @@ -61,14 +65,15 @@ cb_friendly_pal <-function(palette = 'main', reverse = F, ...){
}

#' use cb friendly colors as color aesthetic with ggplot
#'
#'
#' @param palette name of the palette to be returned
#' @param discrete boolean, whether to make palette discretely divided into colors or continuous
#' @param reverse boolean, reverse order of colors in palette
#' @param ... pass to ggplot
#' @export
scale_color_cb_friendly <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) {
pal <- cb_friendly_pal(palette = palette, reverse = reverse)

if (discrete) {
discrete_scale("colour", paste0("cb_friendly_", palette), palette = pal, ...)
} else {
Expand All @@ -77,17 +82,18 @@ scale_color_cb_friendly <- function(palette = "main", discrete = TRUE, reverse =
}

#' use cb friendly colors as fill aesthetic with ggplot
#'
#'
#' @param palette name of the palette to be returned
#' @param discrete boolean, whether to make palette discretely divided into colors or continuous
#' @param reverse boolean, reverse order of colors in palette
#' @param ... pass to ggplot
#' @export
scale_fill_cb_friendly <- function(palette = "main", discrete = TRUE, reverse = FALSE, ...) {
pal <- cb_friendly_pal(palette = palette, reverse = reverse)

if (discrete) {
discrete_scale("fill", paste0("cb_friendly_", palette), palette = pal, ...)
} else {
scale_fill_gradientn(colours = pal(256), ...)
}
}
}
7 changes: 3 additions & 4 deletions R/hello.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ bcbio_templates <- function(type="rnaseq", outpath){

fpath <- system.file("rmarkdown/templates/rnaseq", "skeleton", package="bcbioR")
#file.copy(fpath, outpath, recursive = T)
R.utils::copyDirectory(fpath, outpath)
copyDirectory(fpath, outpath)
},
scrnaseq={

fpath <- system.file("rmarkdown/templates/singlecell", "skeleton", package="bcbioR")
#file.copy(fpath, outpath, recursive = T)
R.utils::copyDirectory(fpath, outpath)
copyDirectory(fpath, outpath)
},
{
stop('project type not recognize, please choose: ', 'rnaseq', 'scrnaseq')
Expand Down Expand Up @@ -76,12 +76,11 @@ bcbio_set_project <- function() {
return(opts)
}

#' @export

bcbio_start_project <- function(options) {

}

#' @export
bcbio_gitignore <- function(options) {

}
Expand Down
4 changes: 4 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ This code will populate the folder with HCBC data structure guidelines and Rmd c
bcbio_templates(type="rnaseq", outpath="test_folder/reports")
```

### Discover more...

Go to the vignette to know more `vignette("bcbioR_quick_start,package="bcbioR")`

## How to Contribute

You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ and Rmd code:
bcbio_templates(type="rnaseq", outpath="test_folder/reports")
```

### Discover more…

Go to the vignette to know more
`vignette("bcbioR_quick_start,package="bcbioR")`

## How to Contribute

You’ll still need to render `README.Rmd` regularly, to keep `README.md`
Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: http://bcb.io/bcbioR/
template:
bootstrap: 5

Loading

0 comments on commit 8efe765

Please sign in to comment.