counts_boxplot: Quickly plot a boxplot of counts

Description Usage Arguments Details Value Examples

View source: R/quick_plots.R

Description

'counts_boxplot()' generates a boxplot of counts given count data.

Usage

1
2
3
4
5
6
7
counts_boxplot(
  count_df,
  metadata,
  sample_var,
  facet_var = NULL,
  .y_intercept = 2e+06
)

Arguments

count_df

cleaned dataframe of counts, rows should be gene IDs, columns should be samples, cells should only contain counts. Also accepts a 'DGEList' object

metadata

cleaned metadata for RNAseq data

sample_var

variable of sample ids

facet_var

variable to facet plots by

.y_intercept

default 2000000, setting to NULL removes horizontal line

Details

Like any other ggplot object, you can customize the theme of the plot. Note that this function generates a fairly generic boxplot, and thus is intended for quick exploratory purposes (much like the intention behind 'qplot()').

Value

a boxplot of RNAseq counts (ggplot object)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
counts <- readr::read_delim("data/GSE60450_Lactation-GenewiseCounts.txt", delim = "\t")
meta <- readr::read_delim("data/SampleInfo_Corrected.txt", delim = "\t") %>%
  mutate(FileName = stringr::str_replace(FileName, "\\.", "-"))
mycount <- check_sample_names(counts, c(1,2), meta, FileName) %>%
  purrr::pluck("mod_count")
mymeta <- check_sample_names(counts, c(1,2), meta, FileName) %>%
  purrr::pluck("meta")

# View total raw counts
counts_boxplot(mycount, mymeta, SampleName)

# View filtered counts and also facet by variable
id <- as.character(counts$EntrezGeneID)
mycount %>%
  filter_genes(., id, "edgeR") %>%
  counts_boxplot(., mymeta, SampleName, CellType)

# As an EDA step within a pipeline of functions
my_design <- check_sample_names(counts, c(1,2), meta, FileName) %>%
  purrr::pluck("meta") %>%
  make_design_matrix(., c("Status"))

check_sample_names(counts, c(1,2), meta, FileName) %>%
  purrr::pluck("mod_count") %>%
  filter_genes(., id, "edgeR") %T>%
  {print(counts_boxplot(., check_sample_names(counts, c(1,2), meta, FileName) %>%
    purrr::pluck("meta"), SampleName))} %>%
  make_voom(., my_design) %>%
  model_limma() %>%
  make_contrasts(design_matrix = my_design, Statuspregnant, Statusvirgin) %>%
  model_bayes()

latlio/tidyde documentation built on Dec. 21, 2021, 9:40 a.m.