get_fold_change_scatter_plot: Compare log2 fold change between two sample comparisons.

View source: R/rnaseq_related.R

get_fold_change_scatter_plotR Documentation

Compare log2 fold change between two sample comparisons.

Description

This function generates a scatter plot of log2 fold change values for two different comparisons.

Usage

get_fold_change_scatter_plot(
  x,
  sample_comparisons,
  labels = NULL,
  point_size = 2,
  label_size = 2,
  color_label = "both",
  col_up = "#a40000",
  col_down = "#16317d",
  show_diagonal_line = TRUE,
  show_correlation = TRUE,
  repair_genes = TRUE
)

Arguments

x

an object of class parcutils.

sample_comparisons

a character vector of length 2 denoting sample comparisons to plot.

labels

a character vector of genes to label. Default NULL, no labels.

point_size

a numeric, default 2, denoting size of the points.

label_size

a numeric, default 2, denoting size of the labels.

color_label

a character string one of the "both", #both_down, or "both_up". Default both.

col_up

a character string, default ⁠#a40000⁠, a valid color code for common up regulated genes.

col_down

a character string, default ⁠#16317d⁠, a valid color code for common down regulated genes.

show_diagonal_line

a logical, default TRUE, denoting whether to show a diagonal line.

show_correlation

a logical, default TRUE, denoting whether to show Pearson correlation value.

repair_genes

a logical, default TRUE, denotes whether to repair gene names or not, If TRUE string prior to : will be removed from the gene names.

Value

an object of ggplot2.

Examples

count_file <- system.file("extdata","toy_counts.txt" , package = "parcutils")
count_data <- readr::read_delim(count_file, delim = "\t")

sample_info <- count_data %>% colnames() %>% .[-1]  %>%
 tibble::tibble(samples = . , groups = rep(c("control" ,"treatment1" , "treatment2"), each = 3) )


res <- run_deseq_analysis(counts = count_data ,
                         sample_info = sample_info,
                         column_geneid = "gene_id" ,
                         group_numerator = c("treatment1", "treatment2") ,
                         group_denominator = c("control"))
# show common up and common down
get_fold_change_scatter_plot(x = res,
sample_comparisons = c("treatment1_VS_control",
"treatment2_VS_control"),label_size = 3)

# show common up

get_fold_change_scatter_plot(x = res,
sample_comparisons = c("treatment1_VS_control",
"treatment2_VS_control"),
color_label = "both_up",label_size = 4)

 # show common down
get_fold_change_scatter_plot(x = res,
sample_comparisons = c("treatment1_VS_control",
"treatment2_VS_control"),
color_label = "both_down",label_size = 4, point_size = 4)


cparsania/parcutils documentation built on Oct. 27, 2024, 4:55 a.m.