knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(SCseqtools)
A sample data frame from an experiment containing
sample
column)control
, drug1
, drug2
, combo
t_cell
, b_cell
, nk_cell
, monocyte
, macrophage
CD8A
, CD4
, IFNG
, GZMB
, ARG1
, NOS2
set.seed(123) dat <- data.frame( sample = factor( rep(c("control", "drug1", "drug2", "combo"), each=250), levels = c("control", "drug1", "drug2", "combo")), cluster= rep(c("t_cell", "b_cell", "nk_cell", "monocyte", "macrophage"), each=50), CD8A = sample(seq(0,1, by=0.2),1000, replace = T ), CD4 = sample(seq(0,1, by=0.2),1000, replace = T ), IFNG = rnorm(1000, 5, 5), GZMB = rnorm(1000, 5, 5), ARG1 = rnorm(1000, 5, 5), NOS2 = rnorm(1000, 5, 5)) dat[dat$sample == "drug1", 5:8 ] <- dat[dat$sample == "drug1", 5:8 ] + 1 dat[dat$sample == "drug2", 5:8 ] <- dat[dat$sample == "drug2", 5:8 ] + 3 dat[dat$sample == "combo", 5:8 ] <- dat[dat$sample == "combo", 5:8 ] + 15 head(dat)
t_cell
clustergene_grapher(dat, genes_to_plot = c("IFNG", "GZMB"), colors_to_use = c("orange", "gray", "red", "steelblue"), clusters_to_plot = "t_cell", image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
gene_grapher(dat, genes_to_plot = c("IFNG", "GZMB"), pos_marker = "CD8A",neg_marker = "CD4", colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
gene_grapher(dat, c("IFNG", "GZMB"), pos_marker = c("CD8A", "CD4"), colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
# Use regex matching to find genes in columns genes <- grep("cd4|arg", colnames(dat), ignore.case = T, value = T) gene_grapher(dat, genes_to_plot = genes, colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
gene_grapher(dat, genes_to_plot = c("ARG1", "NOS2"), plot_type = "box", comparisons = list(c("control", "drug1"), c("control", "drug2"), c("control", "combo")), colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
gene_grapher(dat, genes_to_plot = c("ARG1", "NOS2"), plot_type = "violin", colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
gene_grapher(dat, genes_to_plot = c("ARG1", "NOS2"), plot_type = "bar", colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
This could be helpful to track progress if a long lists of genes are being plotted. Also, it can help pinpoint where the plotting encounters a problem (e.g. nothing to plot with the current subsetting approach)
gene_grapher(dat, genes_to_plot = c("ARG1", "NOS2"), plot_type = "box",show_progress = T, colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F)
gene_grapher(dat, genes_to_plot = genes, colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F, show_stats = F)
gene_grapher(dat, x_variable = "cluster", genes_to_plot = genes, colors_to_use = c("orange", "gray", "red", "steelblue", "purple"), image_columns = 2, image_rows = 1, add_mean = T, mean_color = "white", add_median=F, show_stats = F)
suppressPackageStartupMessages(library(ggplot2)) gene_grapher(dat, genes_to_plot = c("ARG1", "NOS2"), plot_type = "violin", assign_global_plotlist = T, colors_to_use = c("orange", "gray", "red", "steelblue"), image_columns = 2, image_rows = 1, output_plot = F, add_mean = T, mean_color = "white", add_median=F) plot_list[[1]] + theme(axis.text.x = element_text(color = "red"), axis.text.y = element_text(color="blue")) + labs(title = paste(names(plot_list)[1], "New plot title"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.