ggseg atlases live in their own R packages, distributed through the ggsegverse r-universe. This provides a single place for all ggseg-compatible packages, whether hosted on GitHub, GitLab, or elsewhere.
If you have a working atlas and want it available through r-universe, follow these steps.
R CMD check without errors.Since setting up a data package can be tricky, we provide a function to get you started. It includes tests and the general structure we expect from a ggseg-atlas package. If you already make R packages comfortably, skip this step.
To create a ggseg repo, use the RStudio New Project creation GUI and
look for the ggseg icon. Or call setup_atlas_repo()
directly:
The DESCRIPTION file contains important metadata about your package. You need to edit it for several reasons:
Description: section to reflect your package
contents.URL: and BugReports to point to
your remote repository. If your host doesn’t support issues, delete
BugReports entirely.Run the script in data-raw/create-atlas.R. This walks
you through the atlas creation pipeline and saves the result as internal
package data in R/sysdata.rda.
The pipeline produces a ggseg_atlas object validated by
is_ggseg_atlas().
Atlas packages store their data as internal objects accessed through exported functions. This avoids lazy-loading issues and gives you full control over how the atlas is loaded.
The pattern looks like this:
R/data.R – the exported accessor
function:
#' My Atlas
#'
#' @references
#' Author A, Author B (Year). Title. *Journal*. doi
#'
#' @return A [ggseg.formats::ggseg_atlas] object.
#' @export
#' @family ggseg_atlases
myatlas <- function() .myatlasdata-raw/create-atlas.R – saves the
atlas as internal data:
This creates R/sysdata.rda containing the dot-prefixed
object .myatlas. The exported function
myatlas() returns it. Users call myatlas()
(with parentheses) to access the atlas.
Do not use LazyData: true or place
.rda files in data/.
Edit R/data.R to describe your atlas. Pay particular
attention to:
@references tag: cite the original publication for
the parcellation.@return tag: specify the atlas type (cortical,
subcortical, tract).@family ggseg_atlases tag: this is required for the
pkgdown documentation site to work.After editing, regenerate documentation:
Once data is saved and documentation is updated, run the tests:
There will likely be failures. Try to resolve them by reading the error messages.
Common things to check:
atlas$region. Palettes are stored in
atlas$palette as a named character vector. Names should
match region labels and values should be hexadecimal colour codes.Let us know if you struggle. We would love to improve this tutorial with the issues you encounter.
If your package contains multiple atlases (e.g. yeo7 and
yeo17), create one accessor function per atlas:
#' Yeo 7-Network Atlas
#' @return A [ggseg.formats::ggseg_atlas] object.
#' @export
#' @family ggseg_atlases
yeo7 <- function() .yeo7
#' Yeo 17-Network Atlas
#' @return A [ggseg.formats::ggseg_atlas] object.
#' @export
#' @family ggseg_atlases
yeo17 <- function() .yeo17Save all objects together in one call:
Once all tests pass, run package checks:
This attempts to build your package and verify everything works.
Read error messages carefully and try to resolve them.
Common things to check:
usethis::use_mit_license("Your Name Here").If everything passes, push to your remote repository.
Once your package is ready and hosted publicly, submit it to the ggsegverse r-universe.
Go to source repository for r-universe setup and fork the repository.
The packages.json file lists all packages in the
ggsegverse r-universe. Add an entry for your package:
[
{
"package": "ggsegYeo2011",
"url": "https://github.com/ggsegverse/ggsegYeo2011"
},
{
"package": "yourpackage",
"url": "https://github.com/yourusername/yourpackage"
}
]Each entry needs:
package: The exact package name (must match your
DESCRIPTION file).url: The URL to your repository.For packages not on GitHub, you can also specify a
branch or use other URL schemes:
Commit your changes and open a pull request to the ggseg/universe repository. Include a brief description of your atlas and a link to any relevant publication.
We will check that:
R CMD checkOnce merged, r-universe automatically builds your package. It typically appears within an hour at ggsegverse.r-universe.dev.
Users can then install your atlas with:
Or use the ggseg.extra helper:
When you push updates to your repository, r-universe automatically rebuilds the package. No action needed on your part after the initial setup.
If you move the repository to a different URL, submit a pull request
to update packages.json.