<jupyter_start><jupyter_text>Quast results analysis Visualization of SPAdes assembly results<jupyter_code>library(dplyr)
library(ggplot2)
library(tidyr)
library(svglite)<jupyter_output>Warning message:
"package 'dplyr' was built under R version 3.4.4"
Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Warning message:
"package 'ggplot2' was built under R version 3.4.4"Warning message:
"package 'tidyr' was built under R version 3.4.4"Warning message:
"package 'svglite' was built under R version 3.4.4"<jupyter_text>Functions<jupyter_code>create_report <- function(df) {
  df <- df %>%
    rename(ctg_0_bp = X..contigs.....0.bp.,
           ctg_1000_bp = X..contigs.....1000.bp.,
           ctg_5000_bp = X..contigs.....5000.bp.,
           ctg_10000_bp = X..contigs.....10000.bp.,
           ctg_25000_bp = X..contigs.....25000.bp.,
           ctg_50000_bp = X..contigs.....50000.bp.,
           tot_len_0_bp = Total.length.....0.bp.,
           tot_len_1000_bp = Total.length.....1000.bp.,
           tot_len_5000_bp = Total.length.....5000.bp.,
           tot_len_10000_bp = Total.length.....10000.bp.,
           tot_len_25000_bp = Total.length.....25000.bp.,
           tot_len_50000_bp = Total.length.....50000.bp.,
           no_of_contigs = X..contigs,
           no_of_misassemblies = X..misassemblies,
           no_of_misassembled_ctg = X..misassembled.contigs,
           no_of_local_misassemblies = X..local.misassemblies,
           unaligned_contigs = X..unaligned.contigs,
           N_per_100kbp = X..N.s.per.100.kbp,
           mismatches_per_100kbp = X..mismatches.per.100.kbp,
           indels_per_100kbp = X..indels.per.100.kbp,
           no_of_genes = X..genes)
  return(df)
}

create_boxplot_report <- function(df) {
  df <- df %>%
    gather(key_contig,
           value_contig,
           ctg_0_bp,
           ctg_1000_bp,
           ctg_5000_bp,
           ctg_10000_bp,
           ctg_25000_bp,
           ctg_50000_bp) %>%
    gather(key_total,
           value_total,
           tot_len_0_bp,
           tot_len_1000_bp, 
           tot_len_5000_bp,
           tot_len_10000_bp,
           tot_len_25000_bp,
           tot_len_50000_bp) %>%
    gather(key_ng,
           value_ng,
           N50,
           NG50)
  return(df)
}<jupyter_output><empty_output><jupyter_text>Read data and wrangle<jupyter_code>raw_report <- read.delim("D:/R_Data/Quast/transposed_report.tsv",
                         sep = "\t",
                         header = TRUE,
                         stringsAsFactors = F)

clean_report <- create_report(raw_report)
boxplot_report <- create_boxplot_report(clean_report)<jupyter_output><empty_output><jupyter_text>Plotting  Number of contigs<jupyter_code>ggplot(clean_report, aes(Assembly, no_of_contigs))+
    geom_col(color = "black")+
    theme_classic()+
    labs(y = "# of contigs")+
    theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.3),
          axis.title.x = element_blank())<jupyter_output><empty_output><jupyter_text>Number of misassemblies<jupyter_code>ggplot(clean_report, aes(Assembly, no_of_misassemblies))+
    geom_col(color = "black")+
    theme_classic()+
    labs(title = "Misassembled contigs",
         y = "# of contigs")+
    theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.3),
          axis.title.x = element_blank())<jupyter_output><empty_output><jupyter_text>Ns per 100 kbp<jupyter_code>ggplot(clean_report, aes(Assembly, N_per_100kbp))+
    geom_col(color = "black")+
    theme_classic()+
    labs(title = "Ns per 100 kbp",
         y = "# of Ns")+
    theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.3),
          axis.title.x = element_blank())<jupyter_output><empty_output><jupyter_text>Assembly contigs<jupyter_code>cols <- c("#e7f0fa","#c9e2f6",
            "#95cbee","#0099dc",
            "#4ab04a", "#ffd73e",
            "#eec73a","#e29421",
            "#f05336","#ce472e")

ggplot(clean_report, aes(N50, Largest.contig, fill = no_of_contigs))+
    geom_point(pch = 21,
               size = 3)+
    scale_fill_gradientn(colors=cols,na.value="black",
                         limits=c(0,500),
                         guide=guide_colourbar(ticks=T,nbin=50,
                                               barheight=.5,label=T, 
                                               barwidth=10))+
    theme_classic()+
    labs(y = "Largest Contig",
         fill = "Number of Contigs")+
    theme(legend.position = "bottom")<jupyter_output><empty_output><jupyter_text>Number of contigs per size<jupyter_code>ggplot(boxplot_report, aes(key_contig, value_contig))+
    stat_boxplot(geom = "errorbar", width = 0.4)+
    geom_boxplot()+
    theme_classic()+
    labs(y = "# of contigs")+
    theme(axis.title.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1))<jupyter_output><empty_output><jupyter_text>Assembly contig sizes<jupyter_code>ggplot(boxplot_report, aes(key_total, value_total))+
    stat_boxplot(geom="errorbar", width = 0.4)+
    geom_boxplot()+
    theme_classic()+
    labs(y = "Total size of contigs")+
    theme(axis.title.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1))<jupyter_output><empty_output><jupyter_text>N50 / NG50<jupyter_code>ggplot(boxplot_report, aes(key_ng, value_ng))+
    stat_boxplot(geom = "errorbar", width = 0.4)+
    geom_boxplot()+
    theme_classic()+
    labs(y = "# of contigs")+
    theme(axis.title.x = element_blank(),
          axis.text.x = element_text(angle = 45, hjust = 1))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1342446547493866, 'fraction_numerical': 0.04696810375043813, 'mean_word_length': 2.6866925064599485, 'pattern_counts': {'":': 0, '<': 48, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '565695', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2062, 'n_words': 317, 'path': 'trim_testing/Quast results analysis.ipynb', 'repo_name': 'hkaspersen/qrec_wgs1', 'size': '5706'}