View source: R/plot_batch_effect.R
plot_batch | R Documentation |
Plots batch effect using UMAP and clustering markers
plot_batch( files_before_norm, files_after_norm, batch_labels = NULL, batch_pattern = NULL, cores = 1, out_dir = NULL, clustering_markers = "CD|HLA|IgD|PD|BAFF|TCR", arcsine_transform = TRUE, manual_colors = NULL, cells_total = 1000, transform_list = NULL, n_neighbors = length(files_before_norm) )
files_before_norm |
Character, full path to the unnormalized fcs_files. |
files_after_norm |
Character, full path to the normalized fcs_files. |
batch_pattern |
Character, batch pattern to be match in the fcs file name. |
cores |
Number of cores to be used |
out_dir |
Character, pathway to where the files should be saved, if NULL (default) files will be saved to file.path(getwd(), CytoNormed). |
clustering_markers |
Character vector, marker names to be used for clustering, can be full marker name e.g. "CD45" or "CD" if all CD-markers needs to be plotted. These markers are used for building and plotting UMAP. |
arcsine_transform |
Logical, if the data should be transformed with arcsine transformation and cofactor 5, default is set to TRUE. |
manual_colors |
Character, vector of the colors to be used, the number of colors needs to be equal to the length of batch_pattern. |
cells_total |
Number of cells to plot per each file. |
transform_list |
Transformation list to pass to the flowCore transform function, see flowCore::transformList(), if different transformation than arcsine is needed. Only if arcsine_transform is FALSE. If NULL and arcsine_transform = FALSE no transformation will be applied. |
n_neighbors |
The size of local neighborhood in UMAP analysis, default set to 15, as in uwot::umap(). It is recommended to set it to the number of files in each batch. |
save plots for batch effect in the out_dir
# Define files before normalization gate_dir <- file.path(dir, "Gated") files_before_norm <- list.files(gate_dir, pattern = ".fcs", full.names = T) # Define files after normalization norm_dir <- file.path(dir, "CytoNormed") files_after_norm <- list.files(norm_dir, pattern = ".fcs", full.names = T) # files needs to be in the same order, check and order if needed test_match_order(x = basename(gsub("Norm_","",files_after_norm)), basename(files_before_norm)) batch_labels <- stringr::str_match(basename(files_before_norm), "day[0-9]*")[,1] # Plot batch effect set.seed(789) plot_batch(files_before_norm = files_before_norm, files_after_norm = files_after_norm, batch_labels = batch_labels, cores = 1, out_dir = norm_dir, clustering_markers = c("CD", "IgD", "HLA"), manual_colors = c("darkorchid4", "darkorange", "chartreuse4"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.