Skip to contents

Generate a box plot

Usage

get_gene_expression_box_plot(
  x,
  samples = NULL,
  genes = NULL,
  group_replicates = FALSE,
  convert_log2 = TRUE
)

Arguments

x

an abject of class "parcutils". This is an output of the function run_deseq_analysis().

samples

a character vector denoting samples to plot in boxplot, default NULL. If set to NULL all samples are accounted.

genes

a character vector denoting genes to consider for boxplot, default NULL. If set to NULL all genes are accounted.

group_replicates

logical, default FALSE, whether to group replicates in individual plots.

convert_log2

logical, default TRUE, whether to plot log2(noralised expression + 1) or not.

Value

an object of class ggplot2

Examples

count_file <- system.file("extdata","toy_counts.txt" , package = "parcutils")
count_data <- readr::read_delim(count_file, delim = "\t")
#> Rows: 5000 Columns: 10
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (1): gene_id
#> dbl (9): control_rep1, control_rep2, control_rep3, treat1_rep1, treat1_rep2,...
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.

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"))
#>  Running DESeq2 ...
#> converting counts to integer mode
#> Warning: some variables in design formula are characters, converting to factors
#> estimating size factors
#> estimating dispersions
#> gene-wise dispersion estimates
#> mean-dispersion relationship
#> final dispersion estimates
#> fitting model and testing
#>  Done.
#>  Summarizing DEG ...
#>  Done.

get_gene_expression_box_plot(x = res ) %>% print()


get_gene_expression_box_plot(x = res , group_replicates = TRUE ) %>% print()