version

abc4d is a pipeline to preprocess and analyze whole-brain microscopy data (over time). You have identified your active cells and aligned them to an atlas and wonder “What next?”, abc4d is the place where to start.



abc4d has functions for: 1) quality control, 2) preprocessing, and 3) analyses from the macro- to micro- scale.

The resources offered within the package are in alignment of the Allen Brain Reference Atlas. However, for most functions these can be easily substituted.

Get started

You can install the released version of abc4d from github with:

#If you do not have devtools yet:
#install.packages("devtools")

devtools::install_github("valeriabonapersona/abc4d")

All dependencies will be automatically downloaded.

Cheatsheet



More thorough tutorials are available here. You can also see this repository for a thorough analysis example using the abc4d package.

Pipeline example

Example analysis from beginning to end.

Preparation

library(abc4d)

# load sample data
data("example")

# load 
data("atlas_tree")
data("atlas_estimation")

### Atlas preparation
# Preparation
## prepare atlases for your own needs
grouped_ba <- c("CA1", "DG", "BLA", "AAA")

# find all children of each grouped brain area
children_ls <- sapply(grouped_ba, function(x) c(x, find_all_children(atlas = atlas_tree, parent = x)))
## if you get a warning about AAA all is correct

# allen brain atlas adapted to own necessities
my_atlas <- reshape2::melt(children_ls, value.name = "acronym", level = "_parent") %>% 
rename(my_grouping = L_parent) %>% 
right_join(atlas_tree, by = "acronym")

# now prepare the estimation atlas
my_estimation_atlas <- adapt_estimation_atlas(atlas_estimation, my_atlas)

Preprocessing

# Preprocessing
## from coordinates (example dataset) to region-based dataset
region_raw <- summarize_per_region(example, my_estimation_atlas)

## add the meta information to your samples
meta <- data.frame(
sample_id = as.character(c(13:14, 16:20, 22:25, 27)),
batch = rep(c(1:3), each = 4),
group = c(0, 90, 180, 30, 180, 90, 30, 0, 90, 180, 0, 30)
)

region_raw <- region_raw %>% 
left_join(meta, by = "sample_id")

## preprocessing transformations (normalization, standardization, batch effects' corrections)
region_df <- preprocess_per_region(region_raw)

Analysis

## pairwaise comparisons of cfos+ cell counts per brain area
pairwise_res <- pairwise_activation(region_df)

# find most active brain areas
most_active <- find_most_active(region_df)

# time: order brain areas based on their activation
order_ba <- order_brain_areas(region_df, c(0, 30, 90, 180))

# categorize brain areas based on their strategy
strategy_ba <- categorize_strategy(region_df, "0", "lm")

# check whether strategy changes in the experimental groups
strategy_change <- find_changed_strategy(region_df, 2, "0", 2)

Tutorials

See ‘Articles’.

Project organization

This package was created with devtools and it follows the recommended organization.

.
├── .gitignore
├── CITATION.md
├── LICENSE.md
├── README.md
├── DESCRIPTION
├── NAMESPACE
├── R                     <- Source code of all functions
├── img                   <- Images for readme
├── man                   <- Automatically generated by roxygen2
├── tests                 <- Automatically generated by test_that
│   └── testthat          <- Tests to run on the functions
│   ├── final             <- The final, canonical data sets used for analyses. 
│   ├── raw               <- The original data, directly downloaded from the repository. 
│   └── temp              <- Intermediate data.
└── renv

Known bugs

Nothing so far!


License

This project is licensed under the terms of the MIT License.


Acknowledgements

  • Heike Schuler for her collaboration in determining quality control and preprocessing steps
  • Keving Kemna for suggesting making this package