From 9f73fd1bec11df723c4449c0acd6f788b9002707 Mon Sep 17 00:00:00 2001 From: Charles Plessy Date: Fri, 21 Jun 2024 15:04:47 +0900 Subject: [PATCH] Initial commit --- .Rbuildignore | 3 + .gitignore | 7 +++ DESCRIPTION | 12 ++++ NAMESPACE | 2 + dev/01_create_pkg.R | 72 ++++++++++++++++++++++ dev/02_git_github_setup.R | 58 ++++++++++++++++++ dev/03_core_files.R | 125 ++++++++++++++++++++++++++++++++++++++ dev/04_update.R | 31 ++++++++++ 8 files changed, 310 insertions(+) create mode 100644 .Rbuildignore create mode 100644 .gitignore create mode 100644 DESCRIPTION create mode 100644 NAMESPACE create mode 100644 dev/01_create_pkg.R create mode 100644 dev/02_git_github_setup.R create mode 100644 dev/03_core_files.R create mode 100644 dev/04_update.R diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..725c359 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,3 @@ +^changchang\.Rproj$ +^\.Rproj\.user$ +^dev$ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6cec4c --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.Rproj.user +*.Rproj +.Rhistory +.Rdata +.httr-oauth +.DS_Store +.quarto diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..13b7ed4 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,12 @@ +Package: changchang +Title: What the Package Does (One Line, Title Case) +Version: 0.0.0.9000 +Authors@R: + person("First", "Last", , "first.last@example.com", role = c("aut", "cre"), + comment = c(ORCID = "YOUR-ORCID-ID")) +Description: What the package does (one paragraph). +License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a + license +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..6ae9268 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,2 @@ +# Generated by roxygen2: do not edit by hand + diff --git a/dev/01_create_pkg.R b/dev/01_create_pkg.R new file mode 100644 index 0000000..e608ded --- /dev/null +++ b/dev/01_create_pkg.R @@ -0,0 +1,72 @@ +## ******************** +## Create the R package +## ******************** + +## To get started, install R from https://cran.r-project.org/ +## and RStudio Desktop https://rstudio.com/products/rstudio/download/#download +## You can install both of them for free. + +## Next, open RStudio as the code that will run benefits from running inside +## RStudio for interactivity purposes. + +## Next, you might need to install several R packages that you can install with +## the following code: +if (!requireNamespace("remotes", quietly = TRUE)) { + install.packages("remotes") +} +remotes::install_cran( + c( + "available", + "BiocManager", + "biocthis", + "devtools", + "knitr", + "pkgdown", + "RefManageR", + "rmarkdown", + "rstudioapi", + "sessioninfo", + "styler", + "usethis" + ) +) +if (!requireNamespace("BiocStyle", quietly = TRUE)) { + BiocManager::install("BiocStyle") +} +## In case you want the development version of biocthis from GitHub +# BiocManager::install("lcolladotor/biocthis") + +## Here's a very quick summary of why these packages are useful: +## * available: to check the name of your package +## * BiocManager: to install Bioconductor packages +## * BiocStyle: for styling your vignette and linking to other packages +## * devtools: to develop R packages +## * knitr: for making your vignette +## * pkgdown: for creating beautiful documentation websites +## * RefManageR: for citing utilities in your package vignette +## * rmarkdown: for making the README.md and processing your vignette +## * remotes: for installing R packages from several locations +## * rstudioapi: for navigating across files in RStudio +## * sessioninfo: for detailed R session information useful to you and your users +## * usethis: for creating templates that will jump start your R package work + + +## Package names have some properties. You can also use: +available::available("changchang") +## to check that your package name is not taken and that it doesn't have +## a meaning that you might not be aware of. + +usethis::create_package("changchang") +## This opens a new window in RStudio + +## Note: If you create packages frequently, check the help file for +## usethis::use_description() for more information on how to set some R author +## defaults. + +## Add package development files from biocthis +biocthis::use_bioc_pkg_templates() + +## Move to the next step: setting up Git and GitHub for your package +rstudioapi::navigateToFile(usethis::proj_path("dev", "02_git_github_setup.R")) + +## This template was made using https://lcolladotor.github.io/biocthis/ diff --git a/dev/02_git_github_setup.R b/dev/02_git_github_setup.R new file mode 100644 index 0000000..86f5d7b --- /dev/null +++ b/dev/02_git_github_setup.R @@ -0,0 +1,58 @@ +## Did you miss the previous step? The one about creating your package +rstudioapi::navigateToFile(usethis::proj_path("dev", "01_create_pkg.R")) + +## ******************** +## Setup Git and GitHub +## ******************** + +## Note that Bioconductor doesn't allow *.Rproj files +## So we have to ignore it before anything else +usethis::use_git_ignore("*.Rproj") +usethis::use_git() ## Choose the option to make the commit, then to restart RStudio +## If you don't have git installed, you will likely benefit from reading +## "Happy Git and GitHub for the useR" at https://happygitwithr.com/. + +## After the restart, we next need to change the default Git branch to "devel" +## as this is the new standard at Bioconductor. You can choose to ignore +## this step, but will have to deal with more complicated commands later down +## the road. So we highly recommend that you use the "devel" Git branch! +usethis::git_default_branch_rename(to = "devel") + +## Next we continue by connecting your local git repository to +## GitHub. You might want to use the `organisation` and `private` arguments +args(usethis::use_github) + +## If this is your first time running use_github(), you might have to also run: +usethis::gh_token_help() +## The above command will suggest that you read more at +## https://usethis.r-lib.org/articles/articles/git-credentials.html +## which contains the latest recommendations by the usethis authors for +## configuring your R to GitHub connection. +usethis::create_github_token() +gitcreds::gitcreds_set() +## Type your GitHub token, not your password! Otherwise you might run into this +## problem: /~https://github.com/r-lib/usethis/issues/1347 + +## In some situations, gitcreds::gitcreds_set() might not work. For example, +## gitcreds::gitcreds_set() is not supported on Linux as discussed at +## /~https://github.com/r-lib/gitcreds/issues/29. In these situations, +## you have to rely on the old workflow of editing your +## .Renviron file with contents like (note the empty line at the end!): +# GITHUB_PAT=YOUR_40_CHARACTERS_TOKEN +# +usethis::edit_r_environ() +## Then re-start your R session. +rstudioapi::restartSession() +## Editing the .Renviron is strongly discouraged now since it stores as +## simple text your GitHub personal access token (PAT) instead of the +## more secure approach provided by gitcreds. + +## Now run use_github() +usethis::use_github() +## Follow any prompts, such as running on the terminal: +## git push --set-upstream origin devel + +## Move to the next step: setting up your package core files +rstudioapi::navigateToFile(usethis::proj_path("dev", "03_core_files.R")) + +## This template was made using https://lcolladotor.github.io/biocthis/ diff --git a/dev/03_core_files.R b/dev/03_core_files.R new file mode 100644 index 0000000..8e9cf6d --- /dev/null +++ b/dev/03_core_files.R @@ -0,0 +1,125 @@ +## Did you miss the previous step? The one about setting up Git and GitHub +rstudioapi::navigateToFile(usethis::proj_path("dev", "02_git_github_setup.R")) + +## *********************************************************** +## Setup the core files for your Bioconductor-friendly package +## *********************************************************** + +## Edit your package DESCRIPTION file +## Check http://r-pkgs.had.co.nz/description.html for details +## as well as http://contributions.bioconductor.org/description.html + +## Check /~https://github.com/lcolladotor/biocthis/blob/devel/DESCRIPTION +## for an example. + +## You'll at least want to edit the version to 0.99.0 (or lower) since that's +## the version number you will need to use with Bioconductor. + +## You will also want to add the biocViews field, for example: +## biocViews: Software + +## Many Bioconductor packages use the following license: +## license: Artistic-2.0 + +## You might want to add the Date field as well, which is used when creating +## the package citation information. Use the YYYY-MM-DD format. For example: +## Date: 2020-04-29 + +## This function sets all these defaults for you +biocthis::use_bioc_description() +## However, you still need to edit parts of it manually +rstudioapi::navigateToFile(usethis::proj_path("DESCRIPTION")) + +## Create your README.Rmd file +biocthis::use_bioc_readme_rmd() +devtools::build_readme() + +## Edit accordingly. You might want to install your package also using +## devtools::build() or the RStudio keyboard shortcut: +## macoS: command + shift + B +## Windows: control + shift + B + +## Click on the `knit` button on your README.Rmd file to create the README.md +## file. + +## Add a NEWS.md file +## See http://bioconductor.org/developers/package-guidelines/#news for more +## details about Bioconductor news files. +biocthis::use_bioc_news_md() + +## Add information for users and contributors +biocthis::use_bioc_coc() +usethis::use_tidy_contributing() +biocthis::use_bioc_support() +biocthis::use_bioc_issue_template() +biocthis::use_bioc_feature_request_template() +biocthis::use_bioc_citation() + +## Add badges to the README.Rmd file +usethis::use_lifecycle_badge("Experimental") +biocthis::use_bioc_badges() +## NOTE: If your Bioconductor package is an experiment, annotation or workflow +## package, you will need to edit the resulting badge! +usethis::use_github_actions_badge("check-bioc.yml") + +## Enable using tests +usethis::use_testthat() +usethis::use_test("example_test") ## You need at least one test to run covr +usethis::use_coverage() + +## Re-knit your README.Rmd file to update your README.md file +devtools::build_readme() + +## Add a vignette template +pkg <- basename(usethis::proj_get()) +biocthis::use_bioc_vignette(pkg, paste("Introduction to", pkg)) + +## Add a Bioconductor-friendly GitHub actions workflow to check your package +biocthis::use_bioc_github_action() +## You will need to go to /~https://github.com//settings/actions +## to and enable: +## > Workflow permissions > Read and write permissions +## Then click save before you can continue with the instructions in this script. + +## While biocthis::use_bioc_github_action() has arguments for all these options, +## if you missed them, and: +## * your package doesn't have testthat tests, use: has_testthat = 'false' +## * you don't want to run the covr step, use: run_covr = 'false' +## * you don't want to use pkgdown, use: run_pkgdown = 'false' +## * you don't want to build a docker image, use: run_docker = 'false' +rstudioapi::navigateToFile(usethis::proj_path(".github", "workflows", "check-bioc.yml")) + +## Setup up your global git config +usethis::edit_git_config() +## Use the information that matches your GitHub account +## Example contents (4 space indentation): +# [user] +# name = Your Full Name +# email = your.email@somewhere.com +# + +## Setup your pkgdown css file +biocthis::use_bioc_pkgdown_css() + +## Install your package locally before building the documentation website +devtools::install() + +## ************************* WARNING START ********************************* +## WARNING: git commit before running this next function! +## Otherwise you can lose your work!!! +## ************************* WARNING END *********************************** +## +## Deploy with pkgdown at least once locally such that the automatic updates +## from GitHub actions will work. This creates the gh-pages branch in your +## GitHub repository in such a way that pkgdown will recognize it and be +## able to use it later. +pkgdown::deploy_to_branch() ## Check the WARNING above before running this! + +## For more details about package development, check: +## * http://contributions.bioconductor.org/ +## * https://r-pkgs.org/ + +## Move to the next step: updating your package code before a "git commit" +rstudioapi::navigateToFile(usethis::proj_path("dev", "04_update.R")) + +## This template was made using https://lcolladotor.github.io/biocthis/ diff --git a/dev/04_update.R b/dev/04_update.R new file mode 100644 index 0000000..2dbaf25 --- /dev/null +++ b/dev/04_update.R @@ -0,0 +1,31 @@ +## Did you miss the previous step? The one about setting up the R package core +## files. +rstudioapi::navigateToFile(usethis::proj_path("dev", "03_core_files.R")) + +## ******************************************** +## Update your package code before a git commit +## ******************************************** + +## Automatically re-style the code in your package to a Bioconductor-friendly +## format +## Note that you can pair this function with the RStudio "Reformat code" +## button on the magic wand drop down menu. The keyboard shortcut is +## macOS: shift + command + A +## Windows: shift + control + A +styler::style_pkg(transformers = biocthis::bioc_style()) +styler::style_dir(usethis::proj_path("dev"), transformers = biocthis::bioc_style()) +styler::style_dir( + usethis::proj_path("vignettes"), + transformers = biocthis::bioc_style(), + filetype = "Rmd" +) +styler::style_file(usethis::proj_path("README.Rmd"), transformers = biocthis::bioc_style()) + +## Re-make the documentation files +devtools::document() + +## You might also need to update the README.md by re-rendering the README.Rmd +## file. +devtools::build_readme() + +## This template was made using https://lcolladotor.github.io/biocthis/