Wrapper around dplyr functions to normalize and standardize the count and intensity variables. It expects the output of summarize_per_region.

preprocess_per_region(region_df)

Arguments

region_df

region_based dataframe. Each row is a brain area ("my_grouping") per sample ("sample_id"), where corrected cell count ("cells_perthousand") and average maximum intensity of the protein of interest ("intensity") have been summarized. It can be output from summarize_per_region(). The data will be normalized according to "batch", and it will be scaled per unit ("cells_perthousand_box_scaled", "intensity_box_scaled"), as well as per brain area per unit ("cells_perthousand_box_scaled_ba", "intensity_box_scaled_ba")

Value

Examples

x <- data.frame( batch = rep(c(1,1,2,2), each = 5), group = rep(c("control", "exp", "exp", "control"), each = 5), sample_id = rep(c("a", "b", "c", "d"), each = 5), my_grouping = rep(c("CA1", "CA2", "CA3", "DG", "BLA"), 4), intensity = sample(10000, 20, replace = TRUE), cells_perthousand = abs(rnorm(20)) ) preprocess_per_region(x)
#> Error in region_df %>% dplyr::group_by(batch) %>% dplyr::mutate(cells_perthousand_box = normalize(cells_perthousand), intensity_box = normalize(intensity)) %>% dplyr::mutate(cells_perthousand_box_scaled = scale(cells_perthousand_box), intensity_box_scaled = scale(intensity_box)) %>% dplyr::ungroup() %>% dplyr::group_by(batch, my_grouping) %>% dplyr::mutate(cells_perthousand_box_scaled_ba = scale(cells_perthousand_box), intensity_box_scaled_ba = scale(intensity_box)) %>% dplyr::ungroup() %>% droplevels(): could not find function "%>%"