knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

nobrainr

The goal of nobrainr is to provide a simple interface to plot plates from the Mouse Allen Brain Atlas.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("matiasandina/nobrainr")

Examples

Plot atlas plate based on AP

library(nobrainr)
## basic example code
plot_atlas(AP = 0,half = F)

You can also use the bw argument to get the bw version.

plot_atlas(AP = 0,half = F, bw = T)

Plot multiple atlas plates

A little bit of knowledge in R can help manipulate the resulting ggplot2 object. We can use verbose = FALSE to avoid all the user feedback.

# AP values need not be exact, they are rounded to correct plates
desired_AP <- seq(1, -6, -1)
plot_list <- 
purrr::map(
  desired_AP,
  ~plot_atlas(AP=.x, half=T, verbose=F) + 
    ggplot2::labs(title = glue::glue("AP = {.x} mm"))
)
cowplot::plot_grid(plotlist = plot_list)

Export

If you want to export the plots to an svg format for presentation you can use the ggsave function from the ggplot2 package.

p1 <- plot_atlas(0)
ggplot2::ggsave(filename = "plot_title.svg", 
                plot = p1) # <- will save to the local directory, check ?ggsave

Plot counts calculated elsewhere

This package comes with data that contains cell counts in different brain regions.

trial_df

You can plot the counts using plot_roi_counts().

plot_roi_counts(trial_df, AP=1.1, half=FALSE)

Mind that not all AP levels are present on this sample data. Within each AP, not all ROIs have data either. Because we can't plot nonexistent data, nobrainr will throw an error.

plot_roi_counts(count_df = trial_df, AP=1, half=FALSE)

Contribute

This is a preliminary release. Please file issues to improve the package.

Acknowledgements

This package contains data coming from wholebrain package.



matiasandina/nobrainr documentation built on Dec. 21, 2021, 2:53 p.m.