knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
# Load required packages library(CytoExploreR) library(CytoExploreRData) # Load Activation GatingSet gs <- cyto_load( system.file( "extdata/Activation-GatingSet", package = "CytoExploreRData" ) )
cyto_plot_save("Visualisations-11.png", height = 6, width = 12) cyto_plot_custom(c(1,2))
# 2D scatter plot cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4","CD8"), title = "2-D Scatter") # 1D density distribution cyto_plot(gs[[32]], parent = "T Cells", channels = "CD4", title = "1-D Histograms")
cyto_plot_complete()
knitr::include_graphics('Visualisations/Visualisations-11.png')
```{e, eval = FALSE, echo = FALSE} cyto_plot_save("Visualisations-16.png", height = 6, width = 6)
```r # Custom title cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD44","CD69"), title = "Custom Title", title_text_font = 2, title_text_size = 2, title_text_col = "blue")
knitr::include_graphics('Visualisations/Visualisations-16.png')
cyto_plot_save("Visualisations-6.png", height = 6, width = 6)
# Customise axes labels cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4", "CD8"), xlab = "CD4", ylab = "CD8", axes_label_text_font = 2, axes_label_text_size = 2, axes_label_text_col = "red", title = "Custom Axes Labels")
knitr::include_graphics('Visualisations/Visualisations-6.png')
cyto_plot_save("Visualisations-5.png", height = 6, width = 12)
# Pull transformers from GatingSet trans <- cyto_transformer_extract(gs) # Pull out T Cells flowSet T_Cells <- cyto_extract(gs, "T Cells") # Layout cyto_plot_custom(c(1,2)) # Axes on current scale cyto_plot(T_Cells[[32]], channels = c("CD4","CD8"), title = "Transformers Missing", layout = FALSE) # Axes appropriately transformed cyto_plot(T_Cells[[32]], channels = c("CD4","CD8"), axes_trans = trans, title = "Transformers Supplied", layout = FALSE)
cyto_plot_complete(c(1,1))
knitr::include_graphics('Visualisations/Visualisations-5.png')
cyto_plot_save("Visualisations-14.png", height = 6, width = 6)
# Customise axes_text cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4","CD8"), axes_text = c(TRUE, FALSE), # remove y axis text axes_text_font = 1, axes_text_size = 1.4, axes_text_col = "purple", title = "Custom Axes Text")
knitr::include_graphics('Visualisations/Visualisations-14.png')
cyto_plot_save("Visualisations-1.png", height = 6, width = 6)
# Machine axes limits cyto_plot(gs[[32]], parent = "T Cells", channels = c("Va2", "CD4"), axes_limits = "machine", title = "Machine Limits")
knitr::include_graphics('Visualisations/Visualisations-1.png')
cyto_plot_save("Visualisations-2.png", height = 6, width = 6)
# Data axes limits cyto_plot(gs[[32]], parent = "T Cells", channels = c("Va2", "CD4"), axes_limits = "data", title = "Data Limits")
knitr::include_graphics('Visualisations/Visualisations-2.png')
cyto_plot_save("Visualisations-3.png", height = 6, width = 6)
# Auto axes limits cyto_plot(gs[[32]], parent = "T Cells", channels = c("Va2", "CD4"), axes_limits = "auto", title = "Auto Limits")
knitr::include_graphics('Visualisations/Visualisations-3.png')
cyto_plot_save("Visualisations-4.png", height = 6, width = 6)
# Custom axes limits cyto_plot(gs[[32]], parent = "T Cells", channels = c("Va2", "CD4"), xlim = c(-10, 65000), ylim = c(-500, 10000), title = "Custom Axes Limits")
knitr::include_graphics('Visualisations/Visualisations-4.png')
cyto_plot_save("Visualisations-12.png", height = 12, width = 12) cyto_plot_custom(c(2,2))
# Display all events cyto_plot(gs[[32]], parent = "root", channels = c("FSC-A", "SSC-A"), display = 1, title = "All Events") # Display 5000 events cyto_plot(gs[[32]], parent = "root", channels = c("FSC-A", "SSC-A"), display = 5000, title = "5000 Events") # Display 20% of events cyto_plot(gs[[32]], parent = "root", channels = c("FSC-A", "SSC-A"), display = 0.2, title = "20% of Events") # Display default 25000 events cyto_plot(gs[[32]], parent = "root", channels = c("FSC-A", "SSC-A"), title = "Default 25000 Events")
cyto_plot_complete(c(1,1))
knitr::include_graphics('Visualisations/Visualisations-12.png')
cyto_plot_save("Visualisations-15.png", height = 6, width = 8)
# Custom legend cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4", "CD8"), overlay = "descendants", legend = TRUE, legend_text = c("T Cells", "CD8 T Cells", "CD69+ CD8 T Cells", # not required "CD4 T Cells", "CD69+ CD4 T Cells"), legend_text_font = 1, legend_text_size = 1, legend_text_col = "black", title = "Custom Legend")
knitr::include_graphics('Visualisations/Visualisations-15.png')
cyto_plot_save("Visualisations-13.png", height = 6, width = 6)
# Custom border cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4","CD8"), overlay = "descendants", border_fill = "black", border_fill_alpha = 1, border_line_type = 1, border_line_col = "red", border_line_width = 3, title = "Custom Borders")
knitr::include_graphics('Visualisations/Visualisations-13.png')
# Plot in popup window cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4","CD8"), popup = TRUE)
cyto_plot_save("Visualisations-18.png", height = 4.5, width = 13.5)
# Custom layout cyto_plot(gs[30:32], parent = "CD4 T Cells", channels = c("CD44", "CD69"), point_size = 3, contour_lines = 15, layout = c(1,3))
knitr::include_graphics('Visualisations/Visualisations-18.png')
cyto_plot_save("Visualisations-10.png", height = 6, width = 6)
# Point colour palette cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4","CD8"), overlay = "descendants", point_col = "black", # base layer - override density gradient point_cols = c("red", "orange", "yellow", "green", # upper layers "blue", "purple"), title = "Point Colour Palette")
knitr::include_graphics('Visualisations/Visualisations-10.png')
cyto_plot_save("Visualisations-9.png", height = 6, width = 6)
# Point colour scale cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4","CD8"), point_col_scale = c("black", "brown", "red", "orange", "yellow", "white"), title = "Point Colour Scale")
knitr::include_graphics('Visualisations/Visualisations-9.png')
cyto_plot_save("Visualisations-8.png", height = 6, width = 6)
# Customise points cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4", "CD8"), point_shape = ".", point_size = 3, point_col = "red", point_col_alpha = 0.4)
knitr::include_graphics('Visualisations/Visualisations-8.png')
cyto_plot_save("Visualisations-7.png", height = 6, width = 6)
# Contour lines cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD4", "CD8"), contour_lines = 25, contour_line_type = 1, contour_line_width = 1.2, contour_line_col = "black", contour_line_alpha = 0.8, title = "Contour Lines")
knitr::include_graphics('Visualisations/Visualisations-7.png')
cyto_plot_save("Visualisations-21.png", height = 6, width = 10)
# Density distributions cyto_plot(gs[25:32], parent = "T Cells", channels = "CD8", density_smooth = 0.4, density_layers = 4, # 4 samples per plot density_stack = 0.5, # 50% stacking density_modal = TRUE, density_fill = rep(c("red", "blue", "green", "magenta"), 2), density_fill_alpha = c(rep(0, 4), 0.2, 0.4, 0.8, 1), density_line_type = c(1,2,3,4,rep(1, 4)), density_line_width = c(rep(2, 4), rep(1, 4)), density_line_col = c("red", "blue", "green", "magenta", rep("black", 4)))
knitr::include_graphics('Visualisations/Visualisations-21.png')
cyto_plot_save("Visualisations-22.png", height = 6, width = 6)
# Plot gates cyto_plot(gs[[32]], parent = "T Cells", alias = "", # same as c("CD4 T Cells", "CD8 T Cells") channels = c("CD4", "CD8"), negate = TRUE, # statistic for events outside gates gate_line_type = 1, gate_line_width = 2, gate_line_col = "red", gate_fill = "white", gate_fill_alpha = 0)
knitr::include_graphics('Visualisations/Visualisations-22.png')
cyto_plot_save("Visualisations-23.png", height = 6, width = 6)
cyto_plot(gs[29:32], parent = "CD4 T Cells", alias = "CD69+ CD4 T Cells", channels = "CD69", density_stack = 0.7)
knitr::include_graphics('Visualisations/Visualisations-23.png')
cyto_plot_save("Visualisations-26.png", height = 6, width = 6)
# Labels cyto_plot(gs[29:32], parent = "CD4 T Cells", channels = "CD69", density_stack = 0.5, axes_limits = "machine", label_text = c("Label A", "Label B", "Label C", "Label D"), label_stat = rep("median", 4), label_text_x = rep(75000, 4), label_text_font = 2, label_text_size = 0.8, label_text_col = "red", label_fill = "white", label_fill_alpha = 0.6, title = "Custom Labels")
knitr::include_graphics('Visualisations/Visualisations-26.png')
cyto_plot_save("Visualisations-25.png", height = 6, width = 8)
# Overlay cyto_plot(gs[[32]], parent = "T Cells", overlay = "descendants", channels = c("CD44", "CD69"), legend = TRUE, title = "Overlays")
knitr::include_graphics('Visualisations/Visualisations-25.png')
cyto_plot_save("Visualisations-27.png", height = 6, width = 6)
# Extract unactivated sample naive <- cyto_extract(gs, parent = "CD4 T Cells")[[27]] # Manual overlays cyto_plot(gs[32], parent = "CD4 T Cells", overlay = naive, channels = c("CD44", "CD69"), point_size = 3)
knitr::include_graphics('Visualisations/Visualisations-27.png')
cyto_plot_save("Visualisations-24.png", height = 12, width = 12)
# Experiment variables (if not entered in cyto_setup) cyto_details(gs)$Treatment <- c(rep("Stim-A", 8), rep("Stim-B", 8), rep("Stim-C", 8), rep("Stim-D", 8), NA) cyto_details(gs)$OVAConc <- c(rep(c(0, 0, 5, 5, 50, 50, 500, 500), 4), 0) # Grouping cyto_plot(gs[1:32], parent = "CD4 T Cells", alias = "", channels = c("CD44","CD69"), group_by = c("Treatment", "OVAConc"), contour_lines = 15, label_text_y = 39000)
knitr::include_graphics('Visualisations/Visualisations-24.png')
cyto_plot_save("Visualisations-17.png", height = 6, width = 6)
# Available theme arguments cyto_plot_theme_args() # Custom cyto_plot theme cyto_plot_theme(contour_lines = 25, contour_line_col = "white", point_size = 3, point_col_scale = c("white", "yellow", "orange", "red", "darkred", "black"), border_fill = "black", border_line_col = "grey", title_text_col = "red", axes_text_col = "blue", axes_label_text_col = "purple", axes_limits = "machine") # Theme automatically inherited cyto_plot(gs[[32]], parent = "T Cells", channels = c("CD44", "CD69")) # Reset theme to default cyto_plot_theme_reset()
knitr::include_graphics('Visualisations/Visualisations-17.png')
# Call cyto_plot_save cyto_plot_save("Visualisations-19.png", height = 7, width = 7, units = "in", res = 300)
# Call cyto_plot_save cyto_plot_save("Plot.png", height = 7, width = 7, units = "in", res = 300) # cyto_plot call cyto_plot(gs[29:32], parent = "CD4 T Cells", alias = "CD69+ CD4 T Cells", channels = c("CD44", "CD69"), contour_lines = 15, title = c("0 nM OVA", "5 nM OVA", "50 nM OVA", "500 nM OVA"), point_size = 3, point_col = c("cyan", "deepskyblue", "blue", "navyblue"), point_col_alpha = 0.5, label_fill_alpha = 0, label_text_y = 39000, label_text_size = 0.7)
knitr::include_graphics('Visualisations/Visualisations-19.png')
cyto_plot_save("Visualisations-20.png")
# Call cyto_plot_save cyto_plot_save("Plot2.png") # Create custom layout cyto_plot_custom(layout = c(2,2)) # cyto_plot calls cyto_plot(gs[[32]], parent = "CD4 T Cells", alias = "CD69+ CD4 T Cells", channels = c("CD44", "CD69"), title = "CD4 T Cells", contour_lines = 15, label_text_size = 0.7, label_text_y = 39000, label_fill_alpha = 0) cyto_plot(gs[29:32], parent = "CD4 T Cells", alias = "CD69+ CD4 T Cells", channels = "CD69", density_stack = 0.5, title = "CD4 T Cells", label_text = NA) # remove text in labels cyto_plot(gs[[32]], parent = "CD8 T Cells", alias = "CD69+ CD8 T Cells", channels = c("CD44", "CD69"), title = "CD8 T Cells", contour_lines = 15, label_text_size = 0.7, label_text_y = 39000, label_fill_alpha = 0) cyto_plot(gs[29:32], parent = "CD8 T Cells", alias = "CD69+ CD8 T Cells", channels = "CD69", density_stack = 0.5, title = "CD8 T Cells", label_text = NA) # remove text in labels # Tell CytoExploreR plot is complete for saving & turn off custom plotting cyto_plot_complete()
knitr::include_graphics('Visualisations/Visualisations-20.png')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.