Last updated: 2022-07-05

Checks: 6 1

Knit directory: 20180328_Atkins_RatFracture/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20220705) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 4a20503. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/rawQC.Rmd
    Untracked:  analysis/trimQC.Rmd
    Untracked:  data/gmt/

Unstaged changes:
    Modified:   20180328_Atkins_RatFracture.Rproj
    Modified:   analysis/_site.yml
    Deleted:    analysis/about.Rmd
    Modified:   analysis/index.Rmd
    Deleted:    analysis/license.Rmd
    Modified:   code/runPipeline.sh
    Modified:   data/targets.csv

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


knitr::opts_chunk$set(
    message = FALSE, warning = FALSE,
    fig.height = 6, fig.width = 10
)
library(ngsReports)
library(tidyverse)
library(yaml)
library(scales)
library(pander)
library(glue)
library(cowplot)
library(plotly)
panderOptions("table.split.table", Inf)
panderOptions("big.mark", ",")
theme_set(theme_bw())
suffix <- "_L001_R1.fastq.gz"
pattern <- paste0("_CB2YGANXX_.+fastq.gz")
sp <- "Rnorvegicus"
samples <- "data/targets.csv" %>%
  here::here() %>%
  read_csv() %>% 
    mutate(
      Filename = paste0(File, suffix)
    )
group_cols <- hcl.colors(
  n = length(unique(samples$group)), 
  palette = "Zissou 1"
  ) %>%
  setNames(unique(samples$group))

Quality Assessment on Trimmed Data

In the workflow, trimming was performed using the tool AdapterRemoval with the settings:

  • Minimum length after trimming: 50
  • Minimum quality score to retain: 30

Overall Summary

rawFqc <- here::here("data/0_rawData/FastQC") %>%
  list.files(pattern = "zip", full.names = TRUE) %>%
  FastqcDataList() %>%
  .[fqName(.) %in% samples$Filename]
trimFqc <- here::here("data/1_trimmedData/FastQC") %>%
  list.files(pattern = "zip", full.names = TRUE) %>%
  FastqcDataList() %>%
  .[fqName(.) %in% samples$Filename]

After trimming, the library showing the highest level of possible adapter content contained 2.42% of reads as containing possible adapter sequences.

bind_rows(
  getSummary(rawFqc) %>% mutate(data = "Raw"),
  getSummary(trimFqc) %>% mutate(data = "Trimmed"),
) %>% 
  left_join(samples) %>% 
  ggplot(aes(Category, Rat, fill = Status)) +
  geom_tile() +
  facet_grid(data~.) +
  scale_fill_manual(values = getColours(pwf)[c("PASS", "WARN", "FAIL")]) +
  scale_x_discrete(expand = expansion(c(0, 0))) +
  scale_y_discrete(expand = expansion(c(0, 0))) +
  theme(
    axis.text.x = element_text(angle= 90, hjust = 1, vjust = 0.5),
    strip.text.y = element_text(angle = 0)
  )
*Comparison of FastQC summaries before and after trimming*

Comparison of FastQC summaries before and after trimming

Library Sizes

readTotals(rawFqc) %>%
  rename(Raw = Total_Sequences) %>%
  left_join(
    readTotals(trimFqc) %>%
      rename(Trimmed = Total_Sequences)
  ) %>%
  mutate(
    Remaining = Trimmed / Raw,
    Filename = str_remove_all(Filename, suffix)
  ) %>%
  summarise(
    across(c(Remaining, Trimmed), list(min = min, mean = mean, max = max))
  ) %>%
  pivot_longer(everything()) %>%
  separate(
    name, into = c("Type", "Summary Statistic")
  ) %>%
  pivot_wider(names_from = Type, values_from = value) %>%
  mutate(
    Remaining = percent(Remaining, accuracy = 0.1),
    `Summary Statistic` = str_to_title(`Summary Statistic`)
  ) %>%
  rename(Reads = Trimmed) %>%
  pander(
    caption = "*Summary statistics showing the results after trimming*"
  )
Summary statistics showing the results after trimming
Summary Statistic Remaining Reads
Min 99.2% 37,549,038
Mean 99.5% 40,560,914
Max 99.8% 44,761,237
readTotals(rawFqc) %>%
  rename(Raw = Total_Sequences) %>%
  left_join(
    readTotals(trimFqc) %>%
      rename(Retained = Total_Sequences),
    by = "Filename"
  ) %>% 
  left_join(samples, by = "Filename")%>% 
  mutate(Discarded = Raw - Retained) %>% 
  pivot_longer(
    cols = all_of(c("Retained", "Discarded")),
    names_to = "Status",
    values_to = "Reads"
  ) %>% 
  ggplot(aes(fct_rev(Rat), Reads/1e6, fill = Status)) + 
  geom_col() +
  facet_grid(group~. , scales = "free_y", space = "free_y") +
  scale_y_continuous(expand = expansion(c(0, 0.05))) +
  scale_fill_viridis_d(option = "cividis", direction = -1) +
  labs(
    x = "Sample", y = "Reads (millions)"
  ) +
  coord_flip()
Comparison of library sizes before and after trimming.

Comparison of library sizes before and after trimming.

Sequence Length Distribution

ggplotly(
  getModule(trimFqc, "Sequence_Length") %>%
    group_by(Filename) %>%
    mutate(
      `Cumulative Total` = cumsum(Count),
      `Cumulative Percent` = percent(`Cumulative Total` / max(`Cumulative Total`))
    ) %>%
    ungroup() %>%
    left_join(samples, by = "Filename") %>%
    rename_all(str_to_title) %>% 
  arrange(Lower) %>% 
  mutate(Length = fct_inorder(Length)) %>%
    ggplot(aes(Length, `Cumulative Total`, group = Filename, label = `Cumulative Percent`)) +
    geom_line(aes(colour = Group), size = 1/4) +
    scale_y_continuous(label = comma) +
    scale_colour_manual(
      values = group_cols
    ) 
)

Distribution of read lengths after trimming

GC Content

plotGcContent(
  x = trimFqc, 
  pattern = pattern, 
  species = sp, 
  plotType = "line",
  gcType = "Trans",
  usePlotly = TRUE,
  dendrogram = TRUE,
  cluster = TRUE
  )

GC content shown as the % above and below the theoretical GC content for the Rnorvegicus transcriptome. The peaks at 62% and 71% are strongly suggestive of incomplete rRNA removal

Sequence Content

plotly::ggplotly(
  getModule(trimFqc, module = "Per_base_sequence_content") %>% 
    mutate(Base = fct_inorder(Base)) %>%
    group_by(Base) %>% 
    mutate(
      across(c("A", "C", "G", "T"), function(x){x - mean(x)}) 
    ) %>% 
    pivot_longer(
      cols = c("A", "C", "G", "T"), 
      names_to = "Nuc", 
      values_to = "resid"
    ) %>%
    left_join(samples, by = "Filename") %>%
    ggplot(
      aes(Base, resid, group = Filename, colour = group)
    ) + 
    geom_line() +
    facet_wrap(~Nuc) + 
    scale_colour_manual(values = group_cols) +
    labs(
      x = "Read Position", y = "Residual", colour = "Group"
    ) +
    theme(
      axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)
    )
)

Base and Position specific residuals for each sample. The mean base content at each position was calculated for each nucleotide, and the sample-specific residuals calculated.

R version 4.2.0 (2022-04-22)

Platform: x86_64-pc-linux-gnu (64-bit)

locale: LC_CTYPE=en_AU.UTF-8, LC_NUMERIC=C, LC_TIME=en_AU.UTF-8, LC_COLLATE=en_AU.UTF-8, LC_MONETARY=en_AU.UTF-8, LC_MESSAGES=en_AU.UTF-8, LC_PAPER=en_AU.UTF-8, LC_NAME=C, LC_ADDRESS=C, LC_TELEPHONE=C, LC_MEASUREMENT=en_AU.UTF-8 and LC_IDENTIFICATION=C

attached base packages: stats, graphics, grDevices, utils, datasets, methods and base

other attached packages: plotly(v.4.10.0), cowplot(v.1.1.1), glue(v.1.6.2), pander(v.0.6.5), scales(v.1.2.0), yaml(v.2.3.5), forcats(v.0.5.1), stringr(v.1.4.0), dplyr(v.1.0.9), purrr(v.0.3.4), readr(v.2.1.2), tidyr(v.1.2.0), tidyverse(v.1.3.1), ngsReports(v.1.13.0), tibble(v.3.1.7), ggplot2(v.3.3.6), BiocGenerics(v.0.42.0) and workflowr(v.1.7.0)

loaded via a namespace (and not attached): bitops(v.1.0-7), fs(v.1.5.2), bit64(v.4.0.5), lubridate(v.1.8.0), RColorBrewer(v.1.1-3), httr(v.1.4.3), rprojroot(v.2.0.3), GenomeInfoDb(v.1.32.1), tools(v.4.2.0), backports(v.1.4.1), bslib(v.0.3.1), utf8(v.1.2.2), R6(v.2.5.1), DT(v.0.22), DBI(v.1.1.2), lazyeval(v.0.2.2), colorspace(v.2.0-3), withr(v.2.5.0), tidyselect(v.1.1.2), processx(v.3.5.3), bit(v.4.0.4), compiler(v.4.2.0), git2r(v.0.30.1), rvest(v.1.0.2), cli(v.3.3.0), xml2(v.1.3.3), ggdendro(v.0.1.23), labeling(v.0.4.2), sass(v.0.4.1), callr(v.3.7.0), digest(v.0.6.29), rmarkdown(v.2.14), XVector(v.0.36.0), pkgconfig(v.2.0.3), htmltools(v.0.5.2), highr(v.0.9), dbplyr(v.2.1.1), fastmap(v.1.1.0), htmlwidgets(v.1.5.4), rlang(v.1.0.2), readxl(v.1.4.0), rstudioapi(v.0.13), farver(v.2.1.0), jquerylib(v.0.1.4), generics(v.0.1.2), zoo(v.1.8-10), jsonlite(v.1.8.0), crosstalk(v.1.2.0), vroom(v.1.5.7), RCurl(v.1.98-1.6), magrittr(v.2.0.3), GenomeInfoDbData(v.1.2.8), Rcpp(v.1.0.8.3), munsell(v.0.5.0), S4Vectors(v.0.34.0), fansi(v.1.0.3), lifecycle(v.1.0.1), stringi(v.1.7.6), whisker(v.0.4), MASS(v.7.3-57), zlibbioc(v.1.42.0), grid(v.4.2.0), parallel(v.4.2.0), promises(v.1.2.0.1), crayon(v.1.5.1), lattice(v.0.20-45), Biostrings(v.2.64.0), haven(v.2.5.0), hms(v.1.1.1), knitr(v.1.39), ps(v.1.7.0), pillar(v.1.7.0), stats4(v.4.2.0), reprex(v.2.0.1), evaluate(v.0.15), getPass(v.0.2-2), data.table(v.1.14.2), modelr(v.0.1.8), vctrs(v.0.4.1), tzdb(v.0.3.0), httpuv(v.1.6.5), cellranger(v.1.1.0), gtable(v.0.3.0), assertthat(v.0.2.1), xfun(v.0.30), broom(v.0.8.0), later(v.1.3.0), viridisLite(v.0.4.0), IRanges(v.2.30.0), ellipsis(v.0.3.2) and here(v.1.0.1)


sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
 [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
 [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] plotly_4.10.0       cowplot_1.1.1       glue_1.6.2         
 [4] pander_0.6.5        scales_1.2.0        yaml_2.3.5         
 [7] forcats_0.5.1       stringr_1.4.0       dplyr_1.0.9        
[10] purrr_0.3.4         readr_2.1.2         tidyr_1.2.0        
[13] tidyverse_1.3.1     ngsReports_1.13.0   tibble_3.1.7       
[16] ggplot2_3.3.6       BiocGenerics_0.42.0 workflowr_1.7.0    

loaded via a namespace (and not attached):
 [1] bitops_1.0-7           fs_1.5.2               bit64_4.0.5           
 [4] lubridate_1.8.0        RColorBrewer_1.1-3     httr_1.4.3            
 [7] rprojroot_2.0.3        GenomeInfoDb_1.32.1    tools_4.2.0           
[10] backports_1.4.1        bslib_0.3.1            utf8_1.2.2            
[13] R6_2.5.1               DT_0.22                DBI_1.1.2             
[16] lazyeval_0.2.2         colorspace_2.0-3       withr_2.5.0           
[19] tidyselect_1.1.2       processx_3.5.3         bit_4.0.4             
[22] compiler_4.2.0         git2r_0.30.1           rvest_1.0.2           
[25] cli_3.3.0              xml2_1.3.3             ggdendro_0.1.23       
[28] labeling_0.4.2         sass_0.4.1             callr_3.7.0           
[31] digest_0.6.29          rmarkdown_2.14         XVector_0.36.0        
[34] pkgconfig_2.0.3        htmltools_0.5.2        highr_0.9             
[37] dbplyr_2.1.1           fastmap_1.1.0          htmlwidgets_1.5.4     
[40] rlang_1.0.2            readxl_1.4.0           rstudioapi_0.13       
[43] farver_2.1.0           jquerylib_0.1.4        generics_0.1.2        
[46] zoo_1.8-10             jsonlite_1.8.0         crosstalk_1.2.0       
[49] vroom_1.5.7            RCurl_1.98-1.6         magrittr_2.0.3        
[52] GenomeInfoDbData_1.2.8 Rcpp_1.0.8.3           munsell_0.5.0         
[55] S4Vectors_0.34.0       fansi_1.0.3            lifecycle_1.0.1       
[58] stringi_1.7.6          whisker_0.4            MASS_7.3-57           
[61] zlibbioc_1.42.0        grid_4.2.0             parallel_4.2.0        
[64] promises_1.2.0.1       crayon_1.5.1           lattice_0.20-45       
[67] Biostrings_2.64.0      haven_2.5.0            hms_1.1.1             
[70] knitr_1.39             ps_1.7.0               pillar_1.7.0          
[73] stats4_4.2.0           reprex_2.0.1           evaluate_0.15         
[76] getPass_0.2-2          data.table_1.14.2      modelr_0.1.8          
[79] vctrs_0.4.1            tzdb_0.3.0             httpuv_1.6.5          
[82] cellranger_1.1.0       gtable_0.3.0           assertthat_0.2.1      
[85] xfun_0.30              broom_0.8.0            later_1.3.0           
[88] viridisLite_0.4.0      IRanges_2.30.0         ellipsis_0.3.2        
[91] here_1.0.1