Report breakdown by ID

library(amplican)
library(ggplot2)
alignments <- data.table::fread(params$alignments)
data.table::setDF(alignments)
config <- data.frame(data.table::fread(params$config_summary))
height <- plot_height(length(unique(config$ID)))

Description


Read distribution plot - plot shows number of reads assigned during read grouping
Filtered Reads - plot shows percentage of assigned reads that have been recognized as PRIMER DIMERS or filtered based on low alignment score
Edit rates - plot gives overview of percentage of reads (not filtered as PRIMER DIMER) that have edits
Frameshift - plot shows what percentage of reads that have frameshift
Read heterogeneity plot - shows what is the share of each of the unique reads in total count of all reads. The more yellow each row, the less heterogeneity in the reads, more black means reads don't repeat often and are unique
Deletions plot - shows summary of deletions detected after alignments with distinction for forward (top plot) and reverse (bottom) reads, blue dotted lines represent primers as black dotted line represents cut site box, for deletions overlapping with cut site box there is distinction in color
Mismatches plot - shows summary of mismatches detected after alignments split by forward (top plot) and reverse (bottom) reads, mismatches are colored in the same manner as amplicon
Insertions plot - shows summary of insertions detected after alignments split by forward (top plot) and reverse (bottom) reads, insertion is shown as right-angled triangle where size of the insertion corresponds to the width of the triangle, size and transparency of triangle reflect on the frequency of the insertion


ID Summary


Read distribution

ggplot(data = config, aes(x = as.factor(ID), y = log10(Reads + 1), order = ID)) +
  geom_bar(stat='identity') +
  ylab('Number of reads + 1, log10 scaled')  +
  xlab('ID') +
  theme(legend.position = 'none',
        axis.text = element_text(size = 12),
        axis.title = element_text(size = 14, face = 'bold')) +
  coord_flip() +
  geom_text(aes(x = as.factor(ID), y = log10(Reads + 1), label = Reads), hjust = -1)

Filtered reads

config$PRIMER_DIMER <- config$PRIMER_DIMER * 100/config$Reads
config$PRIMER_DIMER[is.nan(config$PRIMER_DIMER)] <- 0  
config$Low_Score <- config$Low_Score * 100/config$Reads
config$Low_Score[is.nan(config$Low_Score)] <- 0  

config_melt <- data.table::melt(data.table::as.data.table(config), id.vars = "ID", 
                                measure.vars = c("PRIMER_DIMER", "Low_Score"))
ggplot(data = config_melt, 
       aes(x = as.factor(ID), y = value, fill = variable, order = ID)) +
  geom_bar(stat='identity') +
  ylab('Percentage of filtered reads')  +
  xlab('ID') +
  theme(legend.position = 'top',
        axis.text = element_text(size = 12),
        axis.title = element_text(size = 14, face = 'bold')) +
  coord_flip() +
  labs(fill = "")

Edit rates

config$edit_percentage <- config$Reads_Edited * 100/config$Reads_Filtered
config$edit_percentage[is.nan(config$edit_percentage)] <- 0  

ggplot(data = config, aes(x = as.factor(ID), y = edit_percentage, order = ID)) +
  geom_bar(stat='identity') +
  ylab('Percentage of reads (not filtered) that have edits')  +
  xlab('ID') +
  theme(legend.position = 'none',
        axis.text = element_text(size = 12),
        axis.title = element_text(size = 14, face = 'bold')) +
  coord_flip() +
  geom_text(aes(x = as.factor(ID), y = edit_percentage, label = Reads_Edited), hjust = -1)

Frameshift

config$frameshift_percentage <- config$Reads_Frameshifted * 100/config$Reads_Filtered
config$frameshift_percentage[is.nan(config$frameshift_percentage)] <- 0  

ggplot(data = config, aes(x = as.factor(ID), y = frameshift_percentage, order = ID)) +
  geom_bar(stat='identity') +
  ylab('Percentage of reads (not filtered) that have frameshift')  +
  xlab('ID') +
  theme(legend.position = 'none',
        axis.text = element_text(size = 12),
        axis.title = element_text(size = 14, face = 'bold')) +
  coord_flip() +
  geom_text(aes(x = as.factor(ID), y = frameshift_percentage, label = Reads_Frameshifted), hjust = -1)

Heterogeneity of reads

plot_heterogeneity(alignments, config)

Alignments plots


alignments_cons <- alignments[alignments$consensus & alignments$overlaps, ]
src = sapply(config$ID, function(i) {
  knitr::knit_expand(text = c(
    "## {{i}}  \n", 
    "### Deletions  \n", 
    paste('```r}, echo = F, results = "asis", ',
          'fig.width=25, message=F, warning=F}', collapse = ''), 
    paste('p <- amplican::plot_deletions(alignments, config, "{{i}}",',
          ' params$cut_buffer, params$xlab_spacing)', collapse = ''), 
    '```\n',
    "### Insertions  \n", 
    paste('```r}, echo = F, results = "asis", ',
          'fig.width=25, message=F, warning=F}', collapse = ''), 
    paste('p <- amplican::plot_insertions(alignments, config, "{{i}}",',
          ' params$cut_buffer, params$xlab_spacing)', collapse = ''), 
    '```\n', 
    "### Mismatches  \n", 
    paste('```r}, echo = F, results = "asis", ',
          'fig.width=25, message=F, warning=F}', collapse = ''), 
    paste('p <- amplican::plot_mismatches(alignments, config, "{{i}}",',
          ' params$cut_buffer, params$xlab_spacing)', collapse = ''), 
    '```\n', 
    "### Variants  \n", 
    paste('```r}, echo = F, message=F, results = "asis", ',
          'message=F, warning=F}', collapse = ''),
    paste('p <- amplican::plot_variants(alignments_cons, config, "{{i}}", ',
          ' params$cut_buffer)', collapse = ''),
    '```\n'))
})
# knit the source
res = knitr::knit_child(text = src, quiet = TRUE)
cat(res, sep = '\n')


Try the amplican package in your browser

Any scripts or data that you put into this service are public.

amplican documentation built on Nov. 8, 2020, 11:10 p.m.