---
title: "Analyse HGT_vs_DUP JS data"
author: "Bram van Dijk"
date: "12/08/2020"
output:
  html_document:
    df_print: paged
---

```{r setup, include=FALSE}

# The code below is not necessary, but can improve graphical quality on certain windows 10 implementations
 trace(grDevices:::png, quote({
   if (missing(type) && missing(antialias)) {
     type <- "cairo-png"
     antialias <- "subpixel"
   }
 }), print = FALSE)

knitr::opts_chunk$set(echo = TRUE)


cols <- rep(c("dodgerblue2","#E31A1C", # red
              "green4",
              "#6A3D9A", # purple
              "#FF7F00", # orange
              "black","steelblue4",
              "skyblue2","#FB9A99", # lt pink
              "palegreen2",
              "#CAB2D6", # lt purple
              "#FDBF6F", # lt orange
              "gray70", "khaki2",
              "maroon","orchid1","deeppink1","blue1","gold1",
              "darkturquoise","green1","yellow4","yellow3",
              "darkorange4","brown"),20)


library(ggplot2)
library(dplyr)
library(tidyverse)

```


### Analyse data from HGT_vs_DUP (javascript implementation)
There are two types of output. Averages over time, and the raw data. This document plots histograms of the raw data fow now. Below, give the output file generated by the code <seed>_raw.txt, and it plots ... something. 


```{r cars}

setwd('../Desktop/Programming shizzle/HGT_vs_DUP/Output/');
file <- "../Output/100_raw.txt"
data <- read.table(file,sep=",");

# Renaming the first two columns, which are the timepoint and the variable-names
names(data)[1] <- "time"
names(data)[2] <- "variable"

# gathering the data into a long-format data frame structured:
# <timepoint,variable,value>
data <- gather(data, key,value,-c(time,variable)) %>% select(time,variable,value)
# <timepoint,variable,poptype,value>
data <- data %>% separate(variable, c("variable", "poptype"), "_")
```

## Including Plots

Here, some distributions are drawn using violin plots:

```{r pressure, echo=FALSE}

data %>% filter(time %in% c(300000)) %>% ggplot(aes(x=NA,y=value,fill=poptype)) + geom_violin(draw_quantiles = c(0.25,0.5,0.75)) + facet_wrap(time~variable,scale="free_y") + scale_color_ma

```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
