gene_grapher: gene_grapher

View source: R/gene_grapher.R

gene_grapherR Documentation

gene_grapher

Description

A function to generate gene expression plots from data frames derived from single cell RNAseq data.

Usage

gene_grapher(
  exprs,
  genes_to_plot,
  x_variable = "sample",
  clusters_to_plot = NULL,
  pos_marker = NULL,
  neg_marker = NULL,
  plot_type = "box",
  add_jitter = T,
  add_point = F,
  point_size = 0.2,
  point_alpha = 0.2,
  add_mean = T,
  mean_color = "red",
  add_median = T,
  median_color = "blue",
  sort_plots = F,
  colors_to_use = NULL,
  show_stats = T,
  comparisons = NULL,
  stat_method = "wilcox.test",
  p_adj_method = "holm",
  y_expand_low = 0,
  y_expand_high = 0.2,
  pval_y_offset = 5/6,
  save_pdf = F,
  append_to_filename = "",
  output_plot = T,
  assign_global_plotlist = F,
  show_progress = F,
  image_columns = 4,
  image_rows = 4,
  ...
)

Arguments

exprs

An expression data frame. Easily generated using HTtools::df_extractor() function. Two columns should be present named "sample", and "cluster". The other columns contain gene names and normalized expression values

genes_to_plot

Character vector of gene names

x_variable

What to show on axis. It can be "sample" (default), "cluster"

clusters_to_plot

Character vector of clusters to include in the plots

pos_marker

Character vector of gene names for positively gating cells. Cells expressing zero counts will be excluded

neg_marker

Character vector of gene names for negatively gating cells. Cells expressing these genes (>0) will be excluded.

plot_type

The appearance of plots. Can be one of the following: "box", "violin", "bar"

add_jitter

Show transparent jitter points (logical)

add_point

Shot aligned points (instead of jitter)

point_size

Size of the jitter points

point_alpha

Transparency of the jitter points

add_mean

Logical. Set it to TRUE if you would like to show mean per group

mean_color

Color of the mean point

add_median

Logical. Set it to TRUE if you would like to median per group

median_color

Color of the median point

sort_plots

Logical. Set it to TRUE to alphabetically sort graphs based on gene name

colors_to_use

Character vector of colors per sample. Default is rainbow palette.

show_stats

Calculate statistical tests and display on graph

comparisons

A list of pairs of character vectors to show comparisons for. list(c(wt, ko1), c("wt", "ko2")). By default, all pairwise comparisons are calculated and plotted.

stat_method

Which statistical test to use. Select one of "wilcox.text" (default) or "t.test".

p_adj_method

How to adjust for multiple comparisons. Possible values are "holm" (default), "hochberg", "hommel", "bonferroni", "BH", "BY","fdr", "none")

y_expand_low

Expand low y-limit as a multiplicative factor (see mult argument of expand_scale())

y_expand_high

Expand high y-limit as a multiplicative factor (see mult argument of expand_scale())

pval_y_offset

Offset factor for determining y-coordinate of p values shown on the plot. It is a multiplicative factor y_max

save_pdf

Save results as a pdf file in the work directory

append_to_filename

String to append to the pdf filename for organizational purposes

output_plot

Logical. Set it to FALSE if you would like to suppress graphical output. Could be helpful for creating pdf files.

assign_global_plotlist

Logical. Creates a global plot_list object to allow further graphical manipulations

show_progress

Logical. Creates a message output to the console to let you know which gene is being analyzed and plotted

image_columns

Controls the number of figure columns on one output page (default is 4)

image_rows

Controls the number of figure rows on one output page (defaul is 4)

...

other parameters to pass to gg

Value

Graphical outputs showing gene expression per sample or cluster

See Also

[df_extractor()]

Examples


# Run function on exprs_df data frame
gene_grapher(exprs = exprs_df,
x_variable = "sample",
genes_to_plot = c("Ifng", "Gzmb", "Pdcd1"),
clusters_to_plot = "T cells",
pos_marker = NULL,
neg_marker = NULL ,
plot_type = "box",
add_jitter = T,
add_mean = T,
mean_color = "black",
add_median = F ,
sort_plots = T,
colors_to_use = cols,
show_stats = T,
comparisons = list(c("Sample1", "Sample2"),
                  c("Sample1", "Sample3")),
stat_method = "wilcox" ,
p_adj_method = "holm" ,
save_pdf = T,
append_to_filename = "_Tcell_genes" ,
output_plot = T,
assign_global_plotlist = F,
show_progress = F,
image_columns = 4,
image_rows = 4,
pval_y_offset = 4/5,
y_expand_high = 0.2)





atakanekiz/SCseqtools documentation built on April 18, 2023, 12:55 a.m.