---
title: "RACE-Seq. Changes of 3' tails of _LINE1_ after _XRN1_, _DCP2_ and _XRN1/DCP2_ knock-out. "
output:
  html_document:
    code_folding: hide
    toc: true
    number_sections: true
  pdf_document: default
---

```{r setup, include=FALSE} 
library(knitr)
knitr::opts_chunk$set(warning = FALSE, message = FALSE, echo = FALSE) 
```

```{r include=FALSE}
library(sqldf)
library(ggplot2)
library(dplyr)
library(stringr)
library(ggpubr)
library(RColorBrewer)
library(ggridges)
```

```{r include=FALSE}
#load functions
source(file.path('03_visualization_functions_D2X1KO.R'))
```

```{r include=FALSE}
#load data
gene_biotype <- read.csv("RACE_infos.csv", sep = "\t")

path_to_files = "/path/to/files"

X1KO_14 = read_and_merge_file(paste(path_to_files,"L1_X1_14_S5_L1NGS4.softclips.parsed.all.csv",sep=""))
X1KO_16 = read_and_merge_file(paste(path_to_files,"L1_X1_16_S6_L1NGS4.softclips.parsed.all.csv",sep=""))
X1KO_18 = read_and_merge_file(paste(path_to_files,"L1_X1_18_S7_L1NGS4.softclips.parsed.all.csv",sep=""))

WT_10 = read_and_merge_file(paste(path_to_files,"L1_WT_10_S2_L1NGS4.softclips.parsed.all.csv",sep=""))
WT_12 = read_and_merge_file(paste(path_to_files,"L1_WT_12_S3_L1NGS4.softclips.parsed.all.csv",sep=""))
WT_13 = read_and_merge_file(paste(path_to_files,"L1_WT_13_S4_L1NGS4.softclips.parsed.all.csv",sep=""))

D2KO_19 = read_and_merge_file(paste(path_to_files,"L1_D2_19_S8_L1NGS4.softclips.parsed.all.csv",sep=""))
D2KO_20 = read_and_merge_file(paste(path_to_files,"L1_D2_20_S9_L1NGS4.softclips.parsed.all.csv",sep=""))
D2KO_21 = read_and_merge_file(paste(path_to_files,"L1_D2_21_S10_L1NGS4.softclips.parsed.all.csv",sep=""))

D2X1KO_22 = read_and_merge_file(paste(path_to_files,"L1_XD_22_S11_L1NGS4.softclips.parsed.all.csv",sep=""))
D2X1KO_23 = read_and_merge_file(paste(path_to_files,"L1_XD_23_S12_L1NGS4.softclips.parsed.all.csv",sep=""))
D2X1KO_24 = read_and_merge_file(paste(path_to_files,"L1_XD_24_S13_L1NGS4.softclips.parsed.all.csv",sep=""))
```

```{r}
#Tail lengths
LINE1_NGS4X1KO_14 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),X1KO_14)
LINE1_NGS4X1KO_16 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),X1KO_16)
LINE1_NGS4X1KO_18 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),X1KO_18)

LINE1_NGS4WT_10 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),WT_10)
LINE1_NGS4WT_12 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),WT_12)
LINE1_NGS4WT_13 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),WT_13)

LINE1_NGS4D2KO_19 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),D2KO_19)
LINE1_NGS4D2KO_20 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),D2KO_20)
LINE1_NGS4D2KO_21 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),D2KO_21)

LINE1_NGS4D2X1KO_22 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),D2X1KO_22)
LINE1_NGS4D2X1KO_23 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),D2X1KO_23)
LINE1_NGS4D2X1KO_24 = tail_analysis_for_genes_0t(c("LINE1_NGS4"),D2X1KO_24)
```

```{r}
##all samples
len_LINE1_NGS4_14 = LINE1_NGS4X1KO_14[LINE1_NGS4X1KO_14$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_14$sample = "X1KO_14"
len_LINE1_NGS4_16 = LINE1_NGS4X1KO_16[LINE1_NGS4X1KO_16$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_16$sample = "X1KO_16"
len_LINE1_NGS4_18 = LINE1_NGS4X1KO_18[LINE1_NGS4X1KO_18$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_18$sample = "X1KO_18"

len_LINE1_NGS4_10 = LINE1_NGS4WT_10[LINE1_NGS4WT_10$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_10$sample = "WT_10"
len_LINE1_NGS4_12 = LINE1_NGS4WT_12[LINE1_NGS4WT_12$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_12$sample = "WT_12"
len_LINE1_NGS4_13 = LINE1_NGS4WT_13[LINE1_NGS4WT_13$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_13$sample = "WT_13"

len_LINE1_NGS4_19 = LINE1_NGS4D2KO_19[LINE1_NGS4D2KO_19$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_19$sample = "D2KO_19"
len_LINE1_NGS4_20 = LINE1_NGS4D2KO_20[LINE1_NGS4D2KO_20$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_20$sample = "D2KO_20"
len_LINE1_NGS4_21 = LINE1_NGS4D2KO_21[LINE1_NGS4D2KO_21$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_21$sample = "D2KO_21"

len_LINE1_NGS4_22 = LINE1_NGS4D2X1KO_22[LINE1_NGS4D2X1KO_22$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_22$sample = "D2X1KO_22"
len_LINE1_NGS4_23 = LINE1_NGS4D2X1KO_23[LINE1_NGS4D2X1KO_23$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_23$sample = "D2X1KO_23"
len_LINE1_NGS4_24 = LINE1_NGS4D2X1KO_24[LINE1_NGS4D2X1KO_24$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_24$sample = "D2X1KO_24"

len_LINE1_NGS4 = rbind(len_LINE1_NGS4_14,len_LINE1_NGS4_16,len_LINE1_NGS4_18,
                       len_LINE1_NGS4_10,len_LINE1_NGS4_12,len_LINE1_NGS4_13,
                       len_LINE1_NGS4_19,len_LINE1_NGS4_20,len_LINE1_NGS4_21,
                       len_LINE1_NGS4_22,len_LINE1_NGS4_23,len_LINE1_NGS4_24)

##means
len_LINE1_NGS4_mean_14 = LINE1_NGS4X1KO_14[LINE1_NGS4X1KO_14$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_14$sample = "X1KO"
len_LINE1_NGS4_mean_16 = LINE1_NGS4X1KO_16[LINE1_NGS4X1KO_16$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_16$sample = "X1KO"
len_LINE1_NGS4_mean_18 = LINE1_NGS4X1KO_18[LINE1_NGS4X1KO_18$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_18$sample = "X1KO"

len_LINE1_NGS4_mean_10 = LINE1_NGS4WT_10[LINE1_NGS4WT_10$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_10$sample = "WT"
len_LINE1_NGS4_mean_12 = LINE1_NGS4WT_12[LINE1_NGS4WT_12$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_12$sample = "WT"
len_LINE1_NGS4_mean_13 = LINE1_NGS4WT_13[LINE1_NGS4WT_13$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_13$sample = "WT"

len_LINE1_NGS4_mean_19 = LINE1_NGS4D2KO_19[LINE1_NGS4D2KO_19$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_19$sample = "D2KO"
len_LINE1_NGS4_mean_20 = LINE1_NGS4D2KO_20[LINE1_NGS4D2KO_20$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_20$sample = "D2KO"
len_LINE1_NGS4_mean_21 = LINE1_NGS4D2KO_21[LINE1_NGS4D2KO_21$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_21$sample = "D2KO"

len_LINE1_NGS4_mean_22 = LINE1_NGS4D2X1KO_22[LINE1_NGS4D2X1KO_22$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_22$sample = "D2X1KO"
len_LINE1_NGS4_mean_23 = LINE1_NGS4D2X1KO_23[LINE1_NGS4D2X1KO_23$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_23$sample = "D2X1KO"
len_LINE1_NGS4_mean_24 = LINE1_NGS4D2X1KO_24[LINE1_NGS4D2X1KO_24$clip3_tail %in% c("1001","1002","1003"),]
len_LINE1_NGS4_mean_24$sample = "D2X1KO"

len_LINE1_NGS4_mean = rbind(len_LINE1_NGS4_mean_14,len_LINE1_NGS4_mean_16,len_LINE1_NGS4_mean_18,
                            len_LINE1_NGS4_mean_10,len_LINE1_NGS4_mean_12,len_LINE1_NGS4_mean_13,
                            len_LINE1_NGS4_mean_19,len_LINE1_NGS4_mean_20,len_LINE1_NGS4_mean_21,
                            len_LINE1_NGS4_mean_22,len_LINE1_NGS4_mean_23,len_LINE1_NGS4_mean_24)
```

# Tail lengths violin plots {.tabset}

## LINE1_NGS4
```{r}
ggplot(len_LINE1_NGS4, aes(x=clip3_tail_len_decoded, y=clip3_tail_len, fill=factor(sample, levels = c("WT_10","WT_12","WT_13","X1KO_14","X1KO_16","X1KO_18","D2KO_19","D2KO_20","D2KO_21","D2X1KO_22","D2X1KO_23","D2X1KO_24")))) +
  scale_x_discrete(labels=c("poliA in reads and shorter reads" = "poliA", "poliAU in reads and shorter reads" = "poliAU", "poliU in reads and shorter reads" = "poliU")) +
  geom_violin() +
  ggtitle("LINE1_NGS4") +
  ylab("tail length") +
  theme(axis.title.x = element_blank(),
        axis.title=element_text(size=14),
        axis.text=element_text(size=12),
        legend.title=element_text(size=14),
        legend.text=element_text(size=12)) +
  geom_boxplot(width=0.1, position=position_dodge(0.9), outlier.size = 0.5, alpha = 0.1) +
  scale_fill_discrete(name = "Sample")
```

# Tail lengths density plots and bar plots {.tabset}

## LINE1_NGS4 {.tabset}

### poly(A)
```{r fig.height=6, fig.width=7}
tail_length_fun("1002","LINE1_NGS4","polyA")
```

### poly(AU)
```{r fig.height=6, fig.width=7}
tail_length_fun("1003","LINE1_NGS4","polyAU")
```

### poly(U)
```{r fig.height=6, fig.width=7}
tail_length_fun("1001","LINE1_NGS4","polyU")
```

# Tails length statistics {.tabset}

For every sample mean length of 3' tails is calculated. Statistical significance in 3' tail length difference is calculated by comparing means with Wilcoxon test

## LINE1_NGS4
```{r}
#polyA
w1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_10" & len_LINE1_NGS4$clip3_tail == "1002",]
w2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_12" & len_LINE1_NGS4$clip3_tail == "1002",]
w3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_13" & len_LINE1_NGS4$clip3_tail == "1002",]

x1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_14" & len_LINE1_NGS4$clip3_tail == "1002",]
x2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_16" & len_LINE1_NGS4$clip3_tail == "1002",]
x3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_18" & len_LINE1_NGS4$clip3_tail == "1002",]

d1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_19" & len_LINE1_NGS4$clip3_tail == "1002",]
d2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_20" & len_LINE1_NGS4$clip3_tail == "1002",]
d3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_21" & len_LINE1_NGS4$clip3_tail == "1002",]

xd1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_22" & len_LINE1_NGS4$clip3_tail == "1002",]
xd2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_23" & len_LINE1_NGS4$clip3_tail == "1002",]
xd3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_24" & len_LINE1_NGS4$clip3_tail == "1002",]

wA = c(mean(w1$clip3_tail_len),mean(w2$clip3_tail_len),mean(w3$clip3_tail_len))
xA = c(mean(x1$clip3_tail_len),mean(x2$clip3_tail_len),mean(x3$clip3_tail_len))
dA = c(mean(d1$clip3_tail_len),mean(d2$clip3_tail_len),mean(d3$clip3_tail_len))
xdA = c(mean(xd1$clip3_tail_len),mean(xd2$clip3_tail_len),mean(xd3$clip3_tail_len))

#polyAU
w1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_10" & len_LINE1_NGS4$clip3_tail == "1003",]
w2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_12" & len_LINE1_NGS4$clip3_tail == "1003",]
w3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_13" & len_LINE1_NGS4$clip3_tail == "1003",]

x1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_14" & len_LINE1_NGS4$clip3_tail == "1003",]
x2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_16" & len_LINE1_NGS4$clip3_tail == "1003",]
x3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_18" & len_LINE1_NGS4$clip3_tail == "1003",]

d1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_19" & len_LINE1_NGS4$clip3_tail == "1003",]
d2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_20" & len_LINE1_NGS4$clip3_tail == "1003",]
d3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_21" & len_LINE1_NGS4$clip3_tail == "1003",]

xd1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_22" & len_LINE1_NGS4$clip3_tail == "1003",]
xd2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_23" & len_LINE1_NGS4$clip3_tail == "1003",]
xd3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_24" & len_LINE1_NGS4$clip3_tail == "1003",]

wAU = c(mean(w1$clip3_tail_len),mean(w2$clip3_tail_len),mean(w3$clip3_tail_len))
xAU = c(mean(x1$clip3_tail_len),mean(x2$clip3_tail_len),mean(x3$clip3_tail_len))
dAU = c(mean(d1$clip3_tail_len),mean(d2$clip3_tail_len),mean(d3$clip3_tail_len))
xdAU = c(mean(xd1$clip3_tail_len),mean(xd2$clip3_tail_len),mean(xd3$clip3_tail_len))

#polyU
w1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_10" & len_LINE1_NGS4$clip3_tail == "1001",]
w2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_12" & len_LINE1_NGS4$clip3_tail == "1001",]
w3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "WT_13" & len_LINE1_NGS4$clip3_tail == "1001",]

x1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_14" & len_LINE1_NGS4$clip3_tail == "1001",]
x2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_16" & len_LINE1_NGS4$clip3_tail == "1001",]
x3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "X1KO_18" & len_LINE1_NGS4$clip3_tail == "1001",]

d1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_19" & len_LINE1_NGS4$clip3_tail == "1001",]
d2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_20" & len_LINE1_NGS4$clip3_tail == "1001",]
d3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2KO_21" & len_LINE1_NGS4$clip3_tail == "1001",]

xd1 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_22" & len_LINE1_NGS4$clip3_tail == "1001",]
xd2 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_23" & len_LINE1_NGS4$clip3_tail == "1001",]
xd3 = len_LINE1_NGS4[len_LINE1_NGS4$sample == "D2X1KO_24" & len_LINE1_NGS4$clip3_tail == "1001",]

wU = c(mean(w1$clip3_tail_len),mean(w2$clip3_tail_len),mean(w3$clip3_tail_len))
xU = c(mean(x1$clip3_tail_len),mean(x2$clip3_tail_len),mean(x3$clip3_tail_len))
dU = c(mean(d1$clip3_tail_len),mean(d2$clip3_tail_len),mean(d3$clip3_tail_len))
xdU = c(mean(xd1$clip3_tail_len),mean(xd2$clip3_tail_len),mean(xd3$clip3_tail_len))
```

polyA (WT vs X1-KO)
```{r}
wilcox.test(wA,xA)
```

polyAU (WT vs X1-KO)
```{r}
wilcox.test(wAU,xAU)
```

polyU (WT vs X1-KO)
```{r}
wilcox.test(wU,xU)
```

polyA (WT vs D2-KO)
```{r}
wilcox.test(wA,dA)
```

polyAU (WT vs D2-KO)
```{r}
wilcox.test(wAU,dAU)
```

polyU (WT vs D2-KO)
```{r}
wilcox.test(wU,dU)
```

polyA (WT vs D2X1-KO)
```{r}
wilcox.test(wA,xdA)
```

polyAU (WT vs D2X1-KO)
```{r}
wilcox.test(wAU,xdAU)
```

polyU (WT vs D2X1-KO)
```{r}
wilcox.test(wU,xdU)
```

# Tail lengths violin plots (mean)  {.tabset}

## LINE1_NGS4
```{r}
ggplot(len_LINE1_NGS4_mean, aes(x=clip3_tail_len_decoded, y=clip3_tail_len, fill=factor(sample, levels = c("WT","X1KO","D2KO","D2X1KO")))) +
  scale_x_discrete(labels=c("poliA in reads and shorter reads" = "poliA", "poliAU in reads and shorter reads" = "poliAU", "poliU in reads and shorter reads" = "poliU")) +
  geom_violin() +
  ggtitle("LINE1_NGS4") +
  ylab("tail length") +
  theme(axis.title.x = element_blank(),
        axis.title=element_text(size=14),
        axis.text=element_text(size=12),
        legend.title=element_text(size=14),
        legend.text=element_text(size=12)) +
  #stat_compare_means(method = "t.test") +
  geom_boxplot(width=0.1, position=position_dodge(0.9), outlier.size = 0.5, alpha = 0.1) +
  scale_fill_manual(values=c("#28C8CC", "#F88B84", "#28CC2C", "#CC28C8"), limits = c("WT","X1KO","D2KO","D2X1KO"), name = "Sample")
```

# Tail lengths density plots and bar plots (mean) {.tabset}

## LINE1_NGS4 {.tabset}

### poly(A)
```{r fig.height=6, fig.width=7}
tail_length_mean_fun("1002","LINE1_NGS4","polyA")
```

### poly(AU)
```{r fig.height=6, fig.width=7}
tail_length_mean_fun("1003","LINE1_NGS4","polyAU")
```

### poly(U)
```{r fig.height=6, fig.width=7}
tail_length_mean_fun("1001","LINE1_NGS4","polyU")
```

# Percentage of tails

## LINE1_NGS4
```{r}
percent_LINE1_NGS4WT_10 = percents_fun(LINE1_NGS4WT_10,"WT_10")
nreads_LINE1_NGS4WT_10 = nreads_fun(LINE1_NGS4WT_10)
percent_LINE1_NGS4WT_12 = percents_fun(LINE1_NGS4WT_12,"WT_12")
nreads_LINE1_NGS4WT_12 = nreads_fun(LINE1_NGS4WT_12)
percent_LINE1_NGS4WT_13 = percents_fun(LINE1_NGS4WT_13,"WT_13")
nreads_LINE1_NGS4WT_13 = nreads_fun(LINE1_NGS4WT_13)

percent_LINE1_NGS4X1KO_14 = percents_fun(LINE1_NGS4X1KO_14,"X1KO_14")
nreads_LINE1_NGS4X1KO_14 = nreads_fun(LINE1_NGS4X1KO_14)
percent_LINE1_NGS4X1KO_16 = percents_fun(LINE1_NGS4X1KO_16,"X1KO_16")
nreads_LINE1_NGS4X1KO_16 = nreads_fun(LINE1_NGS4X1KO_16)
percent_LINE1_NGS4X1KO_18 = percents_fun(LINE1_NGS4X1KO_18,"X1KO_18")
nreads_LINE1_NGS4X1KO_18 = nreads_fun(LINE1_NGS4X1KO_18)

percent_LINE1_NGS4D2KO_19 = percents_fun(LINE1_NGS4D2KO_19,"D2KO_19")
nreads_LINE1_NGS4D2KO_19 = nreads_fun(LINE1_NGS4D2KO_19)
percent_LINE1_NGS4D2KO_20 = percents_fun(LINE1_NGS4D2KO_20,"D2KO_20")
nreads_LINE1_NGS4D2KO_20 = nreads_fun(LINE1_NGS4D2KO_20)
percent_LINE1_NGS4D2KO_21 = percents_fun(LINE1_NGS4D2KO_21,"D2KO_21")
nreads_LINE1_NGS4D2KO_21 = nreads_fun(LINE1_NGS4D2KO_21)

percent_LINE1_NGS4D2X1KO_22 = percents_fun(LINE1_NGS4D2X1KO_22,"D2X1KO_22")
nreads_LINE1_NGS4D2X1KO_22 = nreads_fun(LINE1_NGS4D2X1KO_22)
percent_LINE1_NGS4D2X1KO_23 = percents_fun(LINE1_NGS4D2X1KO_23,"D2X1KO_23")
nreads_LINE1_NGS4D2X1KO_23 = nreads_fun(LINE1_NGS4D2X1KO_23)
percent_LINE1_NGS4D2X1KO_24 = percents_fun(LINE1_NGS4D2X1KO_24,"D2X1KO_24")
nreads_LINE1_NGS4D2X1KO_24 = nreads_fun(LINE1_NGS4D2X1KO_24)

percent_LINE1_NGS4 = rbind(percent_LINE1_NGS4WT_10, percent_LINE1_NGS4WT_12, percent_LINE1_NGS4WT_13, 
                           percent_LINE1_NGS4X1KO_14, percent_LINE1_NGS4X1KO_16, percent_LINE1_NGS4X1KO_18, 
                           percent_LINE1_NGS4D2KO_19, percent_LINE1_NGS4D2KO_20, percent_LINE1_NGS4D2KO_21, 
                           percent_LINE1_NGS4D2X1KO_22, percent_LINE1_NGS4D2X1KO_23, percent_LINE1_NGS4D2X1KO_24)
```

```{r fig.height=6, fig.width=7}
ggplot(percent_LINE1_NGS4, aes(fill=tail, y=percent, x=factor(sample, levels = c("WT_10","WT_12","WT_13","X1KO_14","X1KO_16","X1KO_18","D2KO_19","D2KO_20","D2KO_21","D2X1KO_22","D2X1KO_23","D2X1KO_24")))) + 
    geom_bar(position="stack", stat="identity") +
    ggtitle("LINE1_NGS4") + 
    theme(axis.text.x=element_text(angle=45, hjust=1),
        axis.title=element_text(size=14),
        axis.text=element_text(size=12),
        legend.title=element_text(size=14),
        legend.text=element_text(size=12)) +
    scale_fill_manual(values=c("A tail" = "#74C476", "AU tail" = "#FD8D3C", "no tail" = "#969696", "U tail" = "#A50F15")) +
    scale_x_discrete(name = "sample")
```

### number of reads with specific tails in each sample {.tabset}

#### WT_10
```{r}
t(nreads_LINE1_NGS4WT_10)
```

#### WT_12
```{r}
t(nreads_LINE1_NGS4WT_12)
```

#### WT_13
```{r}
t(nreads_LINE1_NGS4WT_13)
```

#### X1KO_14
```{r}
t(nreads_LINE1_NGS4X1KO_14)
```

#### X1KO_16
```{r}
t(nreads_LINE1_NGS4X1KO_16)
```

#### X1KO_18
```{r}
t(nreads_LINE1_NGS4X1KO_18)
```

#### D2KO_19
```{r}
t(nreads_LINE1_NGS4D2KO_19)
```

#### D2KO_20
```{r}
t(nreads_LINE1_NGS4D2KO_20)
```

#### D2KO_21
```{r}
t(nreads_LINE1_NGS4D2KO_21)
```

#### D2X1KO_22
```{r}
t(nreads_LINE1_NGS4D2X1KO_22)
```

#### D2X1KO_23
```{r}
t(nreads_LINE1_NGS4D2X1KO_23)
```

#### D2X1KO_24
```{r}
t(nreads_LINE1_NGS4D2X1KO_24)
```

### statistics  {.tabset}
```{r include=FALSE}
percent_LINE1_NGS4_stat = percent_LINE1_NGS4

percent_LINE1_NGS4_stat$sample <- gsub('WT_10', 'WT', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('WT_12', 'WT', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('WT_13', 'WT', percent_LINE1_NGS4_stat$sample)

percent_LINE1_NGS4_stat$sample <- gsub('X1KO_14', 'X1KO', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('X1KO_16', 'X1KO', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('X1KO_18', 'X1KO', percent_LINE1_NGS4_stat$sample)

percent_LINE1_NGS4_stat$sample <- gsub('D2KO_19', 'D2KO', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('D2KO_20', 'D2KO', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('D2KO_21', 'D2KO', percent_LINE1_NGS4_stat$sample)

percent_LINE1_NGS4_stat$sample <- gsub('D2X1KO_22', 'D2X1KO', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('D2X1KO_23', 'D2X1KO', percent_LINE1_NGS4_stat$sample)
percent_LINE1_NGS4_stat$sample <- gsub('D2X1KO_24', 'D2X1KO', percent_LINE1_NGS4_stat$sample)

stat = compare_means(percent ~ sample, percent_LINE1_NGS4_stat, group.by = "tail", method="t.test", p.adjust.method="BH")
```

#### WT vs all KOs
```{r echo=FALSE}
stat
```

# Percentage of tails (mean) {.tabset}

## LINE1_NGS4
```{r}
wU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "U tail"),]
wU = wU[with(wU, sample == c("WT_10","WT_12","WT_13")),]

wA = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "A tail"),]
wA = wA[with(wA, sample == c("WT_10","WT_12","WT_13")),]

wAU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "AU tail"),]
wAU = wAU[with(wAU, sample == c("WT_10","WT_12","WT_13")),]

wno = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "no tail"),]
wno = wno[with(wno, sample == c("WT_10","WT_12","WT_13")),]

percent_mean_LINE1_NGS4WT <- data.frame(percent=c(mean(wU$percent),mean(wA$percent),mean(wAU$percent),mean(wno$percent)),
                               tail=c("U tail","A tail","AU tail","no tail"),
                               sample=c(rep("WT",4)))

xU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "U tail"),]
xU = xU[with(xU, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "A tail"),]
xA = xA[with(xA, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "AU tail"),]
xAU = xAU[with(xAU, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xno = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "no tail"),]
xno = xno[with(xno, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

percent_mean_LINE1_NGS4X1KO <- data.frame(percent=c(mean(xU$percent),mean(xA$percent),mean(xAU$percent),mean(xno$percent)),
                               tail=c("U tail","A tail","AU tail","no tail"),
                               sample=c(rep("X1KO",4)))

dU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "U tail"),]
dU = dU[with(dU, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

dA = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "A tail"),]
dA = dA[with(dA, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

dAU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "AU tail"),]
dAU = dAU[with(dAU, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

dno = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "no tail"),]
dno = dno[with(dno, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

percent_mean_LINE1_NGS4D2KO <- data.frame(percent=c(mean(dU$percent),mean(dA$percent),mean(dAU$percent),mean(dno$percent)),
                               tail=c("U tail","A tail","AU tail","no tail"),
                               sample=c(rep("D2KO",4)))

dxU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "U tail"),]
dxU = dxU[with(dxU, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

dxA = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "A tail"),]
dxA = dxA[with(dxA, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

dxAU = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "AU tail"),]
dxAU = dxAU[with(dxAU, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

dxno = percent_LINE1_NGS4[with(percent_LINE1_NGS4, tail == "no tail"),]
dxno = dxno[with(dxno, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

percent_mean_LINE1_NGS4D2X1KO <- data.frame(percent=c(mean(dxU$percent),mean(dxA$percent),mean(dxAU$percent),mean(dxno$percent)),
                               tail=c("U tail","A tail","AU tail","no tail"),
                               sample=c(rep("D2X1KO",4)))

percent_mean_LINE1_NGS4 = rbind(percent_mean_LINE1_NGS4WT, percent_mean_LINE1_NGS4X1KO, percent_mean_LINE1_NGS4D2KO, percent_mean_LINE1_NGS4D2X1KO)
```

```{r fig.height=6, fig.width=4}
ggplot(percent_mean_LINE1_NGS4, aes(fill=tail, y=percent, x=factor(sample, levels = c("WT","X1KO","D2KO","D2X1KO")))) + 
    geom_bar(position="fill", stat="identity") + 
    ggtitle("LINE1_NGS4") + 
    theme(axis.text.x=element_text(angle=45, hjust=1),
        axis.title=element_text(size=14),
        axis.text=element_text(size=12),
        legend.title=element_text(size=14),
        legend.text=element_text(size=12)) +
    scale_fill_manual(values=c("A tail" = "#74C476", "AU tail" = "#FD8D3C", "no tail" = "#969696", "U tail" = "#A50F15")) +
    scale_x_discrete(name = "sample")
```

# Percentage of tails in length range

## LINE1_NGS4
```{r}
percent_LINE1_NGS4WT_10_bins = percents_bins_fun(LINE1_NGS4WT_10,"WT_10")
nreads_LINE1_NGS4WT_10_bins = nreads_bins_fun(LINE1_NGS4WT_10,"WT_10")
percent_LINE1_NGS4WT_12_bins = percents_bins_fun(LINE1_NGS4WT_12,"WT_12")
nreads_LINE1_NGS4WT_12_bins = nreads_bins_fun(LINE1_NGS4WT_12,"WT_12")
percent_LINE1_NGS4WT_13_bins = percents_bins_fun(LINE1_NGS4WT_13,"WT_13")
nreads_LINE1_NGS4WT_13_bins = nreads_bins_fun(LINE1_NGS4WT_13,"WT_13")

percent_LINE1_NGS4X1KO_14_bins = percents_bins_fun(LINE1_NGS4X1KO_14,"X1KO_14")
nreads_LINE1_NGS4X1KO_14_bins = nreads_bins_fun(LINE1_NGS4X1KO_14,"X1KO_14")
percent_LINE1_NGS4X1KO_16_bins = percents_bins_fun(LINE1_NGS4X1KO_16,"X1KO_16")
nreads_LINE1_NGS4X1KO_16_bins = nreads_bins_fun(LINE1_NGS4X1KO_16,"X1KO_16")
percent_LINE1_NGS4X1KO_18_bins = percents_bins_fun(LINE1_NGS4X1KO_18,"X1KO_18")
nreads_LINE1_NGS4X1KO_18_bins = nreads_bins_fun(LINE1_NGS4X1KO_18,"X1KO_18")

percent_LINE1_NGS4D2KO_19_bins = percents_bins_fun(LINE1_NGS4D2KO_19,"D2KO_19")
nreads_LINE1_NGS4D2KO_19_bins = nreads_bins_fun(LINE1_NGS4D2KO_19,"D2KO_19")
percent_LINE1_NGS4D2KO_20_bins = percents_bins_fun(LINE1_NGS4D2KO_20,"D2KO_20")
nreads_LINE1_NGS4D2KO_20_bins = nreads_bins_fun(LINE1_NGS4D2KO_20,"D2KO_20")
percent_LINE1_NGS4D2KO_21_bins = percents_bins_fun(LINE1_NGS4D2KO_21,"D2KO_21")
nreads_LINE1_NGS4D2KO_21_bins = nreads_bins_fun(LINE1_NGS4D2KO_21,"D2KO_21")

percent_LINE1_NGS4D2X1KO_22_bins = percents_bins_fun(LINE1_NGS4D2X1KO_22,"D2X1KO_22")
nreads_LINE1_NGS4D2X1KO_22_bins = nreads_bins_fun(LINE1_NGS4D2X1KO_22,"D2X1KO_22")
percent_LINE1_NGS4D2X1KO_23_bins = percents_bins_fun(LINE1_NGS4D2X1KO_23,"D2X1KO_23")
nreads_LINE1_NGS4D2X1KO_23_bins = nreads_bins_fun(LINE1_NGS4D2X1KO_23,"D2X1KO_23")
percent_LINE1_NGS4D2X1KO_24_bins = percents_bins_fun(LINE1_NGS4D2X1KO_24,"D2X1KO_24")
nreads_LINE1_NGS4D2X1KO_24_bins = nreads_bins_fun(LINE1_NGS4D2X1KO_24,"D2X1KO_24")

nreads_LINE1_NGS4WT_bins = cbind(nreads_LINE1_NGS4WT_10_bins, nreads_LINE1_NGS4WT_12_bins, nreads_LINE1_NGS4WT_13_bins)
nreads_LINE1_NGS4WT_bins = as.data.frame(nreads_LINE1_NGS4WT_bins)
nreads_LINE1_NGS4WT_bins[rowMeans(nreads_LINE1_NGS4WT_bins) < 1,] = 0

nreads_LINE1_NGS4X1_bins = cbind(nreads_LINE1_NGS4X1KO_14_bins, nreads_LINE1_NGS4X1KO_16_bins, nreads_LINE1_NGS4X1KO_18_bins)
nreads_LINE1_NGS4X1_bins = as.data.frame(nreads_LINE1_NGS4X1_bins)
nreads_LINE1_NGS4X1_bins[rowMeans(nreads_LINE1_NGS4X1_bins) < 1,] = 0

nreads_LINE1_NGS4D2_bins = cbind(nreads_LINE1_NGS4D2KO_19_bins, nreads_LINE1_NGS4D2KO_20_bins, nreads_LINE1_NGS4D2KO_21_bins)
nreads_LINE1_NGS4D2_bins = as.data.frame(nreads_LINE1_NGS4D2_bins)
nreads_LINE1_NGS4D2_bins[rowMeans(nreads_LINE1_NGS4D2_bins) < 1,] = 0

nreads_LINE1_NGS4D2X1_bins = cbind(nreads_LINE1_NGS4D2X1KO_22_bins, nreads_LINE1_NGS4D2X1KO_23_bins, nreads_LINE1_NGS4D2X1KO_24_bins)
nreads_LINE1_NGS4D2X1_bins = as.data.frame(nreads_LINE1_NGS4D2X1_bins)
nreads_LINE1_NGS4D2X1_bins[rowMeans(nreads_LINE1_NGS4D2X1_bins) < 1,] = 0

percent_LINE1_NGS4_bins = rbind(percent_LINE1_NGS4WT_10_bins, percent_LINE1_NGS4WT_12_bins, percent_LINE1_NGS4WT_13_bins, 
                                percent_LINE1_NGS4X1KO_14_bins, percent_LINE1_NGS4X1KO_16_bins, percent_LINE1_NGS4X1KO_18_bins, 
                                percent_LINE1_NGS4D2KO_19_bins, percent_LINE1_NGS4D2KO_20_bins, percent_LINE1_NGS4D2KO_21_bins, 
                                percent_LINE1_NGS4D2X1KO_22_bins, percent_LINE1_NGS4D2X1KO_23_bins, percent_LINE1_NGS4D2X1KO_24_bins)
```

```{r fig.height=10, fig.width=10}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")

ggplot(percent_LINE1_NGS4_bins, aes(fill=tail, y=percent, x=range)) + 
    geom_bar(position="stack", stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT_10","WT_12","WT_13","X1KO_14","X1KO_16","X1KO_18","D2KO_19","D2KO_20","D2KO_21","D2X1KO_22","D2X1KO_23","D2X1KO_24")), ncol = 3) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) +
    scale_fill_manual(values=c("A tail" = "#74C476", "AU tail" = "#FD8D3C", "U tail" = "#A50F15")) +
    scale_x_discrete(limits = order)
```

### statistics  {.tabset}
```{r include=FALSE}
percent_LINE1_NGS4_stat2 = percent_LINE1_NGS4_bins

percent_LINE1_NGS4_stat2$sample <- gsub('WT_10', 'WT', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('WT_12', 'WT', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('WT_13', 'WT', percent_LINE1_NGS4_stat2$sample)

percent_LINE1_NGS4_stat2$sample <- gsub('X1KO_14', 'X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('X1KO_16', 'X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('X1KO_18', 'X1KO', percent_LINE1_NGS4_stat2$sample)

percent_LINE1_NGS4_stat2$sample <- gsub('D2KO_19', 'D2KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2KO_20', 'D2KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2KO_21', 'D2KO', percent_LINE1_NGS4_stat2$sample)

percent_LINE1_NGS4_stat2$sample <- gsub('D2X1KO_22', 'D2X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2X1KO_23', 'D2X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2X1KO_24', 'D2X1KO', percent_LINE1_NGS4_stat2$sample)

stat1_10 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "1-10",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat11_20 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "11-20",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat21_30 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "21-30",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat31_40 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "31-40",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat41_50 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "41-50",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat51_60 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "51-60",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat61 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "61+",], group.by = "tail", method="t.test", p.adjust.method="BH")
```

#### range 1-10 
```{r}
stat1_10
```

#### range 11-20
```{r}
stat11_20
```

#### range 21-30
```{r}
stat21_30
```

#### range 31-40
```{r}
stat31_40
```

#### range 41-50
```{r}
stat41_50
```

#### range 51-60
```{r}
stat51_60
```

#### range 61+
```{r}
stat61
```

### number of reads with specific tails in each sample {.tabset}

#### WT_10
```{r}
nreads_LINE1_NGS4WT_10_bins
```

#### WT_12
```{r}
nreads_LINE1_NGS4WT_12_bins
```

#### WT_13
```{r}
nreads_LINE1_NGS4WT_13_bins
```

#### X1KO_14
```{r}
nreads_LINE1_NGS4X1KO_14_bins
```

#### X1KO_16
```{r}
nreads_LINE1_NGS4X1KO_16_bins
```

#### X1KO_18
```{r}
nreads_LINE1_NGS4X1KO_18_bins
```

#### D2KO_19
```{r}
nreads_LINE1_NGS4D2KO_19_bins
```

#### D2KO_20
```{r}
nreads_LINE1_NGS4D2KO_20_bins
```

#### D2KO_21
```{r}
nreads_LINE1_NGS4D2KO_21_bins
```

#### D2X1KO_22
```{r}
nreads_LINE1_NGS4D2X1KO_22_bins
```

#### D2X1KO_23
```{r}
nreads_LINE1_NGS4D2X1KO_23_bins
```

#### D2X1KO_24
```{r}
nreads_LINE1_NGS4D2X1KO_24_bins
```

# Percentage of tails in length range (mean) {.tabset}

## LINE1_NGS4
```{r}
xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("WT_10","WT_12","WT_13")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("WT_10","WT_12","WT_13")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("WT_10","WT_12","WT_13")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("WT_10","WT_12","WT_13")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("WT_10","WT_12","WT_13")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("WT_10","WT_12","WT_13")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("WT_10","WT_12","WT_13")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("WT_10","WT_12","WT_13")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("WT_10","WT_12","WT_13")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("WT_10","WT_12","WT_13")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("WT_10","WT_12","WT_13")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("WT_10","WT_12","WT_13")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("WT_10","WT_12","WT_13")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("WT_10","WT_12","WT_13")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("WT_10","WT_12","WT_13")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("WT_10","WT_12","WT_13")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("WT_10","WT_12","WT_13")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("WT_10","WT_12","WT_13")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("WT_10","WT_12","WT_13")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("WT_10","WT_12","WT_13")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("WT_10","WT_12","WT_13")),]

percent_mean_LINE1_NGS4WT <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("WT",21)))


xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

percent_mean_LINE1_NGS4X1 <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("X1KO",21)))


xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

percent_mean_LINE1_NGS4D2 <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("D2KO",21)))

xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

percent_mean_LINE1_NGS4D2X1 <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("D2X1KO",21)))

percent_mean_LINE1_NGS4 = rbind(percent_mean_LINE1_NGS4WT, percent_mean_LINE1_NGS4X1, percent_mean_LINE1_NGS4D2, percent_mean_LINE1_NGS4D2X1)
```

```{r fig.height=7, fig.width=7}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")
ggplot(percent_mean_LINE1_NGS4, aes(fill=tail, y=percent, x=range)) + 
    geom_bar(position="fill", stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT","X1KO","D2KO","D2X1KO"))) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12)) +
    scale_x_discrete(limits = order) +
    scale_fill_manual(values=c("A tail" = "#74C476", "AU tail" = "#FD8D3C", "U tail" = "#A50F15")) +
    scale_x_discrete(limits = order)
```

# Percentage of tails in length range; filtered reads {.tabset}

If mean number of reads in group (e.g. WT) is less than 1 this reads are treated as 0

## LINE1_NGS4
```{r}
percent_poliU_1_10 <- nreads_LINE1_NGS4WT_bins[15,1]*100/((nreads_LINE1_NGS4WT_bins[1,1])+(nreads_LINE1_NGS4WT_bins[8,1])+(nreads_LINE1_NGS4WT_bins[15,1]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4WT_bins[1,1]*100/((nreads_LINE1_NGS4WT_bins[1,1])+(nreads_LINE1_NGS4WT_bins[8,1])+(nreads_LINE1_NGS4WT_bins[15,1]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4WT_bins[8,1]*100/((nreads_LINE1_NGS4WT_bins[1,1])+(nreads_LINE1_NGS4WT_bins[8,1])+(nreads_LINE1_NGS4WT_bins[15,1]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4WT_bins[16,1]*100/((nreads_LINE1_NGS4WT_bins[2,1])+(nreads_LINE1_NGS4WT_bins[9,1])+(nreads_LINE1_NGS4WT_bins[16,1]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4WT_bins[2,1]*100/((nreads_LINE1_NGS4WT_bins[2,1])+(nreads_LINE1_NGS4WT_bins[9,1])+(nreads_LINE1_NGS4WT_bins[16,1]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4WT_bins[9,1]*100/((nreads_LINE1_NGS4WT_bins[2,1])+(nreads_LINE1_NGS4WT_bins[9,1])+(nreads_LINE1_NGS4WT_bins[16,1]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4WT_bins[17,1]*100/((nreads_LINE1_NGS4WT_bins[3,1])+(nreads_LINE1_NGS4WT_bins[10,1])+(nreads_LINE1_NGS4WT_bins[17,1]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4WT_bins[3,1]*100/((nreads_LINE1_NGS4WT_bins[3,1])+(nreads_LINE1_NGS4WT_bins[10,1])+(nreads_LINE1_NGS4WT_bins[17,1]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4WT_bins[10,1]*100/((nreads_LINE1_NGS4WT_bins[3,1])+(nreads_LINE1_NGS4WT_bins[10,1])+(nreads_LINE1_NGS4WT_bins[17,1]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4WT_bins[18,1]*100/((nreads_LINE1_NGS4WT_bins[4,1])+(nreads_LINE1_NGS4WT_bins[11,1])+(nreads_LINE1_NGS4WT_bins[18,1]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4WT_bins[4,1]*100/((nreads_LINE1_NGS4WT_bins[4,1])+(nreads_LINE1_NGS4WT_bins[11,1])+(nreads_LINE1_NGS4WT_bins[18,1]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4WT_bins[11,1]*100/((nreads_LINE1_NGS4WT_bins[4,1])+(nreads_LINE1_NGS4WT_bins[11,1])+(nreads_LINE1_NGS4WT_bins[18,1]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4WT_bins[19,1]*100/((nreads_LINE1_NGS4WT_bins[5,1])+(nreads_LINE1_NGS4WT_bins[12,1])+(nreads_LINE1_NGS4WT_bins[19,1]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4WT_bins[5,1]*100/((nreads_LINE1_NGS4WT_bins[5,1])+(nreads_LINE1_NGS4WT_bins[12,1])+(nreads_LINE1_NGS4WT_bins[19,1]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4WT_bins[12,1]*100/((nreads_LINE1_NGS4WT_bins[5,1])+(nreads_LINE1_NGS4WT_bins[12,1])+(nreads_LINE1_NGS4WT_bins[19,1]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4WT_bins[20,1]*100/((nreads_LINE1_NGS4WT_bins[6,1])+(nreads_LINE1_NGS4WT_bins[13,1])+(nreads_LINE1_NGS4WT_bins[20,1]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4WT_bins[6,1]*100/((nreads_LINE1_NGS4WT_bins[6,1])+(nreads_LINE1_NGS4WT_bins[13,1])+(nreads_LINE1_NGS4WT_bins[20,1]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4WT_bins[13,1]*100/((nreads_LINE1_NGS4WT_bins[6,1])+(nreads_LINE1_NGS4WT_bins[13,1])+(nreads_LINE1_NGS4WT_bins[20,1]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4WT_bins[21,1]*100/((nreads_LINE1_NGS4WT_bins[7,1])+(nreads_LINE1_NGS4WT_bins[14,1])+(nreads_LINE1_NGS4WT_bins[21,1]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4WT_bins[7,1]*100/((nreads_LINE1_NGS4WT_bins[7,1])+(nreads_LINE1_NGS4WT_bins[14,1])+(nreads_LINE1_NGS4WT_bins[21,1]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4WT_bins[14,1]*100/((nreads_LINE1_NGS4WT_bins[7,1])+(nreads_LINE1_NGS4WT_bins[14,1])+(nreads_LINE1_NGS4WT_bins[21,1]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4WT_10 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("WT_10",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4WT_bins[15,2]*100/((nreads_LINE1_NGS4WT_bins[1,2])+(nreads_LINE1_NGS4WT_bins[8,2])+(nreads_LINE1_NGS4WT_bins[15,2]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4WT_bins[1,2]*100/((nreads_LINE1_NGS4WT_bins[1,2])+(nreads_LINE1_NGS4WT_bins[8,2])+(nreads_LINE1_NGS4WT_bins[15,2]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4WT_bins[8,2]*100/((nreads_LINE1_NGS4WT_bins[1,2])+(nreads_LINE1_NGS4WT_bins[8,2])+(nreads_LINE1_NGS4WT_bins[15,2]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4WT_bins[16,2]*100/((nreads_LINE1_NGS4WT_bins[2,2])+(nreads_LINE1_NGS4WT_bins[9,2])+(nreads_LINE1_NGS4WT_bins[16,2]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4WT_bins[2,2]*100/((nreads_LINE1_NGS4WT_bins[2,2])+(nreads_LINE1_NGS4WT_bins[9,2])+(nreads_LINE1_NGS4WT_bins[16,2]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4WT_bins[9,2]*100/((nreads_LINE1_NGS4WT_bins[2,2])+(nreads_LINE1_NGS4WT_bins[9,2])+(nreads_LINE1_NGS4WT_bins[16,2]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4WT_bins[17,2]*100/((nreads_LINE1_NGS4WT_bins[3,2])+(nreads_LINE1_NGS4WT_bins[10,2])+(nreads_LINE1_NGS4WT_bins[17,2]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4WT_bins[3,2]*100/((nreads_LINE1_NGS4WT_bins[3,2])+(nreads_LINE1_NGS4WT_bins[10,2])+(nreads_LINE1_NGS4WT_bins[17,2]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4WT_bins[10,2]*100/((nreads_LINE1_NGS4WT_bins[3,2])+(nreads_LINE1_NGS4WT_bins[10,2])+(nreads_LINE1_NGS4WT_bins[17,2]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4WT_bins[18,2]*100/((nreads_LINE1_NGS4WT_bins[4,2])+(nreads_LINE1_NGS4WT_bins[11,2])+(nreads_LINE1_NGS4WT_bins[18,2]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4WT_bins[4,2]*100/((nreads_LINE1_NGS4WT_bins[4,2])+(nreads_LINE1_NGS4WT_bins[11,2])+(nreads_LINE1_NGS4WT_bins[18,2]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4WT_bins[11,2]*100/((nreads_LINE1_NGS4WT_bins[4,2])+(nreads_LINE1_NGS4WT_bins[11,2])+(nreads_LINE1_NGS4WT_bins[18,2]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4WT_bins[19,2]*100/((nreads_LINE1_NGS4WT_bins[5,2])+(nreads_LINE1_NGS4WT_bins[12,2])+(nreads_LINE1_NGS4WT_bins[19,2]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4WT_bins[5,2]*100/((nreads_LINE1_NGS4WT_bins[5,2])+(nreads_LINE1_NGS4WT_bins[12,2])+(nreads_LINE1_NGS4WT_bins[19,2]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4WT_bins[12,2]*100/((nreads_LINE1_NGS4WT_bins[5,2])+(nreads_LINE1_NGS4WT_bins[12,2])+(nreads_LINE1_NGS4WT_bins[19,2]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4WT_bins[20,2]*100/((nreads_LINE1_NGS4WT_bins[6,2])+(nreads_LINE1_NGS4WT_bins[13,2])+(nreads_LINE1_NGS4WT_bins[20,2]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4WT_bins[6,2]*100/((nreads_LINE1_NGS4WT_bins[6,2])+(nreads_LINE1_NGS4WT_bins[13,2])+(nreads_LINE1_NGS4WT_bins[20,2]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4WT_bins[13,2]*100/((nreads_LINE1_NGS4WT_bins[6,2])+(nreads_LINE1_NGS4WT_bins[13,2])+(nreads_LINE1_NGS4WT_bins[20,2]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4WT_bins[21,2]*100/((nreads_LINE1_NGS4WT_bins[7,2])+(nreads_LINE1_NGS4WT_bins[14,2])+(nreads_LINE1_NGS4WT_bins[21,2]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4WT_bins[7,2]*100/((nreads_LINE1_NGS4WT_bins[7,2])+(nreads_LINE1_NGS4WT_bins[14,2])+(nreads_LINE1_NGS4WT_bins[21,2]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4WT_bins[14,2]*100/((nreads_LINE1_NGS4WT_bins[7,2])+(nreads_LINE1_NGS4WT_bins[14,2])+(nreads_LINE1_NGS4WT_bins[21,2]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4WT_12 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("WT_12",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4WT_bins[15,3]*100/((nreads_LINE1_NGS4WT_bins[1,3])+(nreads_LINE1_NGS4WT_bins[8,3])+(nreads_LINE1_NGS4WT_bins[15,3]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4WT_bins[1,3]*100/((nreads_LINE1_NGS4WT_bins[1,3])+(nreads_LINE1_NGS4WT_bins[8,3])+(nreads_LINE1_NGS4WT_bins[15,3]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4WT_bins[8,3]*100/((nreads_LINE1_NGS4WT_bins[1,3])+(nreads_LINE1_NGS4WT_bins[8,3])+(nreads_LINE1_NGS4WT_bins[15,3]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4WT_bins[16,3]*100/((nreads_LINE1_NGS4WT_bins[2,3])+(nreads_LINE1_NGS4WT_bins[9,3])+(nreads_LINE1_NGS4WT_bins[16,3]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4WT_bins[2,3]*100/((nreads_LINE1_NGS4WT_bins[2,3])+(nreads_LINE1_NGS4WT_bins[9,3])+(nreads_LINE1_NGS4WT_bins[16,3]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4WT_bins[9,3]*100/((nreads_LINE1_NGS4WT_bins[2,3])+(nreads_LINE1_NGS4WT_bins[9,3])+(nreads_LINE1_NGS4WT_bins[16,3]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4WT_bins[17,3]*100/((nreads_LINE1_NGS4WT_bins[3,3])+(nreads_LINE1_NGS4WT_bins[10,3])+(nreads_LINE1_NGS4WT_bins[17,3]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4WT_bins[3,3]*100/((nreads_LINE1_NGS4WT_bins[3,3])+(nreads_LINE1_NGS4WT_bins[10,3])+(nreads_LINE1_NGS4WT_bins[17,3]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4WT_bins[10,3]*100/((nreads_LINE1_NGS4WT_bins[3,3])+(nreads_LINE1_NGS4WT_bins[10,3])+(nreads_LINE1_NGS4WT_bins[17,3]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4WT_bins[18,3]*100/((nreads_LINE1_NGS4WT_bins[4,3])+(nreads_LINE1_NGS4WT_bins[11,3])+(nreads_LINE1_NGS4WT_bins[18,3]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4WT_bins[4,3]*100/((nreads_LINE1_NGS4WT_bins[4,3])+(nreads_LINE1_NGS4WT_bins[11,3])+(nreads_LINE1_NGS4WT_bins[18,3]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4WT_bins[11,3]*100/((nreads_LINE1_NGS4WT_bins[4,3])+(nreads_LINE1_NGS4WT_bins[11,3])+(nreads_LINE1_NGS4WT_bins[18,3]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4WT_bins[19,3]*100/((nreads_LINE1_NGS4WT_bins[5,3])+(nreads_LINE1_NGS4WT_bins[12,3])+(nreads_LINE1_NGS4WT_bins[19,3]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4WT_bins[5,3]*100/((nreads_LINE1_NGS4WT_bins[5,3])+(nreads_LINE1_NGS4WT_bins[12,3])+(nreads_LINE1_NGS4WT_bins[19,3]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4WT_bins[12,3]*100/((nreads_LINE1_NGS4WT_bins[5,3])+(nreads_LINE1_NGS4WT_bins[12,3])+(nreads_LINE1_NGS4WT_bins[19,3]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4WT_bins[20,3]*100/((nreads_LINE1_NGS4WT_bins[6,3])+(nreads_LINE1_NGS4WT_bins[13,3])+(nreads_LINE1_NGS4WT_bins[20,3]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4WT_bins[6,3]*100/((nreads_LINE1_NGS4WT_bins[6,3])+(nreads_LINE1_NGS4WT_bins[13,3])+(nreads_LINE1_NGS4WT_bins[20,3]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4WT_bins[13,3]*100/((nreads_LINE1_NGS4WT_bins[6,3])+(nreads_LINE1_NGS4WT_bins[13,3])+(nreads_LINE1_NGS4WT_bins[20,3]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4WT_bins[21,3]*100/((nreads_LINE1_NGS4WT_bins[7,3])+(nreads_LINE1_NGS4WT_bins[14,3])+(nreads_LINE1_NGS4WT_bins[21,3]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4WT_bins[7,3]*100/((nreads_LINE1_NGS4WT_bins[7,3])+(nreads_LINE1_NGS4WT_bins[14,3])+(nreads_LINE1_NGS4WT_bins[21,3]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4WT_bins[14,3]*100/((nreads_LINE1_NGS4WT_bins[7,3])+(nreads_LINE1_NGS4WT_bins[14,3])+(nreads_LINE1_NGS4WT_bins[21,3]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4WT_13 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("WT_13",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4X1_bins[15,1]*100/((nreads_LINE1_NGS4X1_bins[1,1])+(nreads_LINE1_NGS4X1_bins[8,1])+(nreads_LINE1_NGS4X1_bins[15,1]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4X1_bins[1,1]*100/((nreads_LINE1_NGS4X1_bins[1,1])+(nreads_LINE1_NGS4X1_bins[8,1])+(nreads_LINE1_NGS4X1_bins[15,1]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4X1_bins[8,1]*100/((nreads_LINE1_NGS4X1_bins[1,1])+(nreads_LINE1_NGS4X1_bins[8,1])+(nreads_LINE1_NGS4X1_bins[15,1]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4X1_bins[16,1]*100/((nreads_LINE1_NGS4X1_bins[2,1])+(nreads_LINE1_NGS4X1_bins[9,1])+(nreads_LINE1_NGS4X1_bins[16,1]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4X1_bins[2,1]*100/((nreads_LINE1_NGS4X1_bins[2,1])+(nreads_LINE1_NGS4X1_bins[9,1])+(nreads_LINE1_NGS4X1_bins[16,1]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4X1_bins[9,1]*100/((nreads_LINE1_NGS4X1_bins[2,1])+(nreads_LINE1_NGS4X1_bins[9,1])+(nreads_LINE1_NGS4X1_bins[16,1]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4X1_bins[17,1]*100/((nreads_LINE1_NGS4X1_bins[3,1])+(nreads_LINE1_NGS4X1_bins[10,1])+(nreads_LINE1_NGS4X1_bins[17,1]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4X1_bins[3,1]*100/((nreads_LINE1_NGS4X1_bins[3,1])+(nreads_LINE1_NGS4X1_bins[10,1])+(nreads_LINE1_NGS4X1_bins[17,1]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4X1_bins[10,1]*100/((nreads_LINE1_NGS4X1_bins[3,1])+(nreads_LINE1_NGS4X1_bins[10,1])+(nreads_LINE1_NGS4X1_bins[17,1]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4X1_bins[18,1]*100/((nreads_LINE1_NGS4X1_bins[4,1])+(nreads_LINE1_NGS4X1_bins[11,1])+(nreads_LINE1_NGS4X1_bins[18,1]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4X1_bins[4,1]*100/((nreads_LINE1_NGS4X1_bins[4,1])+(nreads_LINE1_NGS4X1_bins[11,1])+(nreads_LINE1_NGS4X1_bins[18,1]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4X1_bins[11,1]*100/((nreads_LINE1_NGS4X1_bins[4,1])+(nreads_LINE1_NGS4X1_bins[11,1])+(nreads_LINE1_NGS4X1_bins[18,1]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4X1_bins[19,1]*100/((nreads_LINE1_NGS4X1_bins[5,1])+(nreads_LINE1_NGS4X1_bins[12,1])+(nreads_LINE1_NGS4X1_bins[19,1]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4X1_bins[5,1]*100/((nreads_LINE1_NGS4X1_bins[5,1])+(nreads_LINE1_NGS4X1_bins[12,1])+(nreads_LINE1_NGS4X1_bins[19,1]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4X1_bins[12,1]*100/((nreads_LINE1_NGS4X1_bins[5,1])+(nreads_LINE1_NGS4X1_bins[12,1])+(nreads_LINE1_NGS4X1_bins[19,1]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4X1_bins[20,1]*100/((nreads_LINE1_NGS4X1_bins[6,1])+(nreads_LINE1_NGS4X1_bins[13,1])+(nreads_LINE1_NGS4X1_bins[20,1]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4X1_bins[6,1]*100/((nreads_LINE1_NGS4X1_bins[6,1])+(nreads_LINE1_NGS4X1_bins[13,1])+(nreads_LINE1_NGS4X1_bins[20,1]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4X1_bins[13,1]*100/((nreads_LINE1_NGS4X1_bins[6,1])+(nreads_LINE1_NGS4X1_bins[13,1])+(nreads_LINE1_NGS4X1_bins[20,1]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4X1_bins[21,1]*100/((nreads_LINE1_NGS4X1_bins[7,1])+(nreads_LINE1_NGS4X1_bins[14,1])+(nreads_LINE1_NGS4X1_bins[21,1]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4X1_bins[7,1]*100/((nreads_LINE1_NGS4X1_bins[7,1])+(nreads_LINE1_NGS4X1_bins[14,1])+(nreads_LINE1_NGS4X1_bins[21,1]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4X1_bins[14,1]*100/((nreads_LINE1_NGS4X1_bins[7,1])+(nreads_LINE1_NGS4X1_bins[14,1])+(nreads_LINE1_NGS4X1_bins[21,1]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4X1KO_14 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("X1KO_14",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4X1_bins[15,2]*100/((nreads_LINE1_NGS4X1_bins[1,2])+(nreads_LINE1_NGS4X1_bins[8,2])+(nreads_LINE1_NGS4X1_bins[15,2]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4X1_bins[1,2]*100/((nreads_LINE1_NGS4X1_bins[1,2])+(nreads_LINE1_NGS4X1_bins[8,2])+(nreads_LINE1_NGS4X1_bins[15,2]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4X1_bins[8,2]*100/((nreads_LINE1_NGS4X1_bins[1,2])+(nreads_LINE1_NGS4X1_bins[8,2])+(nreads_LINE1_NGS4X1_bins[15,2]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4X1_bins[16,2]*100/((nreads_LINE1_NGS4X1_bins[2,2])+(nreads_LINE1_NGS4X1_bins[9,2])+(nreads_LINE1_NGS4X1_bins[16,2]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4X1_bins[2,2]*100/((nreads_LINE1_NGS4X1_bins[2,2])+(nreads_LINE1_NGS4X1_bins[9,2])+(nreads_LINE1_NGS4X1_bins[16,2]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4X1_bins[9,2]*100/((nreads_LINE1_NGS4X1_bins[2,2])+(nreads_LINE1_NGS4X1_bins[9,2])+(nreads_LINE1_NGS4X1_bins[16,2]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4X1_bins[17,2]*100/((nreads_LINE1_NGS4X1_bins[3,2])+(nreads_LINE1_NGS4X1_bins[10,2])+(nreads_LINE1_NGS4X1_bins[17,2]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4X1_bins[3,2]*100/((nreads_LINE1_NGS4X1_bins[3,2])+(nreads_LINE1_NGS4X1_bins[10,2])+(nreads_LINE1_NGS4X1_bins[17,2]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4X1_bins[10,2]*100/((nreads_LINE1_NGS4X1_bins[3,2])+(nreads_LINE1_NGS4X1_bins[10,2])+(nreads_LINE1_NGS4X1_bins[17,2]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4X1_bins[18,2]*100/((nreads_LINE1_NGS4X1_bins[4,2])+(nreads_LINE1_NGS4X1_bins[11,2])+(nreads_LINE1_NGS4X1_bins[18,2]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4X1_bins[4,2]*100/((nreads_LINE1_NGS4X1_bins[4,2])+(nreads_LINE1_NGS4X1_bins[11,2])+(nreads_LINE1_NGS4X1_bins[18,2]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4X1_bins[11,2]*100/((nreads_LINE1_NGS4X1_bins[4,2])+(nreads_LINE1_NGS4X1_bins[11,2])+(nreads_LINE1_NGS4X1_bins[18,2]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4X1_bins[19,2]*100/((nreads_LINE1_NGS4X1_bins[5,2])+(nreads_LINE1_NGS4X1_bins[12,2])+(nreads_LINE1_NGS4X1_bins[19,2]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4X1_bins[5,2]*100/((nreads_LINE1_NGS4X1_bins[5,2])+(nreads_LINE1_NGS4X1_bins[12,2])+(nreads_LINE1_NGS4X1_bins[19,2]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4X1_bins[12,2]*100/((nreads_LINE1_NGS4X1_bins[5,2])+(nreads_LINE1_NGS4X1_bins[12,2])+(nreads_LINE1_NGS4X1_bins[19,2]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4X1_bins[20,2]*100/((nreads_LINE1_NGS4X1_bins[6,2])+(nreads_LINE1_NGS4X1_bins[13,2])+(nreads_LINE1_NGS4X1_bins[20,2]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4X1_bins[6,2]*100/((nreads_LINE1_NGS4X1_bins[6,2])+(nreads_LINE1_NGS4X1_bins[13,2])+(nreads_LINE1_NGS4X1_bins[20,2]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4X1_bins[13,2]*100/((nreads_LINE1_NGS4X1_bins[6,2])+(nreads_LINE1_NGS4X1_bins[13,2])+(nreads_LINE1_NGS4X1_bins[20,2]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4X1_bins[21,2]*100/((nreads_LINE1_NGS4X1_bins[7,2])+(nreads_LINE1_NGS4X1_bins[14,2])+(nreads_LINE1_NGS4X1_bins[21,2]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4X1_bins[7,2]*100/((nreads_LINE1_NGS4X1_bins[7,2])+(nreads_LINE1_NGS4X1_bins[14,2])+(nreads_LINE1_NGS4X1_bins[21,2]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4X1_bins[14,2]*100/((nreads_LINE1_NGS4X1_bins[7,2])+(nreads_LINE1_NGS4X1_bins[14,2])+(nreads_LINE1_NGS4X1_bins[21,2]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4X1KO_16 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("X1KO_16",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4X1_bins[15,3]*100/((nreads_LINE1_NGS4X1_bins[1,3])+(nreads_LINE1_NGS4X1_bins[8,3])+(nreads_LINE1_NGS4X1_bins[15,3]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4X1_bins[1,3]*100/((nreads_LINE1_NGS4X1_bins[1,3])+(nreads_LINE1_NGS4X1_bins[8,3])+(nreads_LINE1_NGS4X1_bins[15,3]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4X1_bins[8,3]*100/((nreads_LINE1_NGS4X1_bins[1,3])+(nreads_LINE1_NGS4X1_bins[8,3])+(nreads_LINE1_NGS4X1_bins[15,3]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4X1_bins[16,3]*100/((nreads_LINE1_NGS4X1_bins[2,3])+(nreads_LINE1_NGS4X1_bins[9,3])+(nreads_LINE1_NGS4X1_bins[16,3]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4X1_bins[2,3]*100/((nreads_LINE1_NGS4X1_bins[2,3])+(nreads_LINE1_NGS4X1_bins[9,3])+(nreads_LINE1_NGS4X1_bins[16,3]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4X1_bins[9,3]*100/((nreads_LINE1_NGS4X1_bins[2,3])+(nreads_LINE1_NGS4X1_bins[9,3])+(nreads_LINE1_NGS4X1_bins[16,3]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4X1_bins[17,3]*100/((nreads_LINE1_NGS4X1_bins[3,3])+(nreads_LINE1_NGS4X1_bins[10,3])+(nreads_LINE1_NGS4X1_bins[17,3]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4X1_bins[3,3]*100/((nreads_LINE1_NGS4X1_bins[3,3])+(nreads_LINE1_NGS4X1_bins[10,3])+(nreads_LINE1_NGS4X1_bins[17,3]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4X1_bins[10,3]*100/((nreads_LINE1_NGS4X1_bins[3,3])+(nreads_LINE1_NGS4X1_bins[10,3])+(nreads_LINE1_NGS4X1_bins[17,3]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4X1_bins[18,3]*100/((nreads_LINE1_NGS4X1_bins[4,3])+(nreads_LINE1_NGS4X1_bins[11,3])+(nreads_LINE1_NGS4X1_bins[18,3]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4X1_bins[4,3]*100/((nreads_LINE1_NGS4X1_bins[4,3])+(nreads_LINE1_NGS4X1_bins[11,3])+(nreads_LINE1_NGS4X1_bins[18,3]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4X1_bins[11,3]*100/((nreads_LINE1_NGS4X1_bins[4,3])+(nreads_LINE1_NGS4X1_bins[11,3])+(nreads_LINE1_NGS4X1_bins[18,3]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4X1_bins[19,3]*100/((nreads_LINE1_NGS4X1_bins[5,3])+(nreads_LINE1_NGS4X1_bins[12,3])+(nreads_LINE1_NGS4X1_bins[19,3]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4X1_bins[5,3]*100/((nreads_LINE1_NGS4X1_bins[5,3])+(nreads_LINE1_NGS4X1_bins[12,3])+(nreads_LINE1_NGS4X1_bins[19,3]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4X1_bins[12,3]*100/((nreads_LINE1_NGS4X1_bins[5,3])+(nreads_LINE1_NGS4X1_bins[12,3])+(nreads_LINE1_NGS4X1_bins[19,3]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4X1_bins[20,3]*100/((nreads_LINE1_NGS4X1_bins[6,3])+(nreads_LINE1_NGS4X1_bins[13,3])+(nreads_LINE1_NGS4X1_bins[20,3]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4X1_bins[6,3]*100/((nreads_LINE1_NGS4X1_bins[6,3])+(nreads_LINE1_NGS4X1_bins[13,3])+(nreads_LINE1_NGS4X1_bins[20,3]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4X1_bins[13,3]*100/((nreads_LINE1_NGS4X1_bins[6,3])+(nreads_LINE1_NGS4X1_bins[13,3])+(nreads_LINE1_NGS4X1_bins[20,3]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4X1_bins[21,3]*100/((nreads_LINE1_NGS4X1_bins[7,3])+(nreads_LINE1_NGS4X1_bins[14,3])+(nreads_LINE1_NGS4X1_bins[21,3]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4X1_bins[7,3]*100/((nreads_LINE1_NGS4X1_bins[7,3])+(nreads_LINE1_NGS4X1_bins[14,3])+(nreads_LINE1_NGS4X1_bins[21,3]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4X1_bins[14,3]*100/((nreads_LINE1_NGS4X1_bins[7,3])+(nreads_LINE1_NGS4X1_bins[14,3])+(nreads_LINE1_NGS4X1_bins[21,3]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4X1KO_18 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("X1KO_18",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4D2_bins[15,1]*100/((nreads_LINE1_NGS4D2_bins[1,1])+(nreads_LINE1_NGS4D2_bins[8,1])+(nreads_LINE1_NGS4D2_bins[15,1]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4D2_bins[1,1]*100/((nreads_LINE1_NGS4D2_bins[1,1])+(nreads_LINE1_NGS4D2_bins[8,1])+(nreads_LINE1_NGS4D2_bins[15,1]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4D2_bins[8,1]*100/((nreads_LINE1_NGS4D2_bins[1,1])+(nreads_LINE1_NGS4D2_bins[8,1])+(nreads_LINE1_NGS4D2_bins[15,1]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4D2_bins[16,1]*100/((nreads_LINE1_NGS4D2_bins[2,1])+(nreads_LINE1_NGS4D2_bins[9,1])+(nreads_LINE1_NGS4D2_bins[16,1]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4D2_bins[2,1]*100/((nreads_LINE1_NGS4D2_bins[2,1])+(nreads_LINE1_NGS4D2_bins[9,1])+(nreads_LINE1_NGS4D2_bins[16,1]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4D2_bins[9,1]*100/((nreads_LINE1_NGS4D2_bins[2,1])+(nreads_LINE1_NGS4D2_bins[9,1])+(nreads_LINE1_NGS4D2_bins[16,1]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4D2_bins[17,1]*100/((nreads_LINE1_NGS4D2_bins[3,1])+(nreads_LINE1_NGS4D2_bins[10,1])+(nreads_LINE1_NGS4D2_bins[17,1]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4D2_bins[3,1]*100/((nreads_LINE1_NGS4D2_bins[3,1])+(nreads_LINE1_NGS4D2_bins[10,1])+(nreads_LINE1_NGS4D2_bins[17,1]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4D2_bins[10,1]*100/((nreads_LINE1_NGS4D2_bins[3,1])+(nreads_LINE1_NGS4D2_bins[10,1])+(nreads_LINE1_NGS4D2_bins[17,1]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4D2_bins[18,1]*100/((nreads_LINE1_NGS4D2_bins[4,1])+(nreads_LINE1_NGS4D2_bins[11,1])+(nreads_LINE1_NGS4D2_bins[18,1]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4D2_bins[4,1]*100/((nreads_LINE1_NGS4D2_bins[4,1])+(nreads_LINE1_NGS4D2_bins[11,1])+(nreads_LINE1_NGS4D2_bins[18,1]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4D2_bins[11,1]*100/((nreads_LINE1_NGS4D2_bins[4,1])+(nreads_LINE1_NGS4D2_bins[11,1])+(nreads_LINE1_NGS4D2_bins[18,1]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4D2_bins[19,1]*100/((nreads_LINE1_NGS4D2_bins[5,1])+(nreads_LINE1_NGS4D2_bins[12,1])+(nreads_LINE1_NGS4D2_bins[19,1]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4D2_bins[5,1]*100/((nreads_LINE1_NGS4D2_bins[5,1])+(nreads_LINE1_NGS4D2_bins[12,1])+(nreads_LINE1_NGS4D2_bins[19,1]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4D2_bins[12,1]*100/((nreads_LINE1_NGS4D2_bins[5,1])+(nreads_LINE1_NGS4D2_bins[12,1])+(nreads_LINE1_NGS4D2_bins[19,1]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4D2_bins[20,1]*100/((nreads_LINE1_NGS4D2_bins[6,1])+(nreads_LINE1_NGS4D2_bins[13,1])+(nreads_LINE1_NGS4D2_bins[20,1]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4D2_bins[6,1]*100/((nreads_LINE1_NGS4D2_bins[6,1])+(nreads_LINE1_NGS4D2_bins[13,1])+(nreads_LINE1_NGS4D2_bins[20,1]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4D2_bins[13,1]*100/((nreads_LINE1_NGS4D2_bins[6,1])+(nreads_LINE1_NGS4D2_bins[13,1])+(nreads_LINE1_NGS4D2_bins[20,1]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4D2_bins[21,1]*100/((nreads_LINE1_NGS4D2_bins[7,1])+(nreads_LINE1_NGS4D2_bins[14,1])+(nreads_LINE1_NGS4D2_bins[21,1]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4D2_bins[7,1]*100/((nreads_LINE1_NGS4D2_bins[7,1])+(nreads_LINE1_NGS4D2_bins[14,1])+(nreads_LINE1_NGS4D2_bins[21,1]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4D2_bins[14,1]*100/((nreads_LINE1_NGS4D2_bins[7,1])+(nreads_LINE1_NGS4D2_bins[14,1])+(nreads_LINE1_NGS4D2_bins[21,1]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4D2KO_19 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("D2KO_19",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4D2_bins[15,2]*100/((nreads_LINE1_NGS4D2_bins[1,2])+(nreads_LINE1_NGS4D2_bins[8,2])+(nreads_LINE1_NGS4D2_bins[15,2]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4D2_bins[1,2]*100/((nreads_LINE1_NGS4D2_bins[1,2])+(nreads_LINE1_NGS4D2_bins[8,2])+(nreads_LINE1_NGS4D2_bins[15,2]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4D2_bins[8,2]*100/((nreads_LINE1_NGS4D2_bins[1,2])+(nreads_LINE1_NGS4D2_bins[8,2])+(nreads_LINE1_NGS4D2_bins[15,2]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4D2_bins[16,2]*100/((nreads_LINE1_NGS4D2_bins[2,2])+(nreads_LINE1_NGS4D2_bins[9,2])+(nreads_LINE1_NGS4D2_bins[16,2]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4D2_bins[2,2]*100/((nreads_LINE1_NGS4D2_bins[2,2])+(nreads_LINE1_NGS4D2_bins[9,2])+(nreads_LINE1_NGS4D2_bins[16,2]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4D2_bins[9,2]*100/((nreads_LINE1_NGS4D2_bins[2,2])+(nreads_LINE1_NGS4D2_bins[9,2])+(nreads_LINE1_NGS4D2_bins[16,2]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4D2_bins[17,2]*100/((nreads_LINE1_NGS4D2_bins[3,2])+(nreads_LINE1_NGS4D2_bins[10,2])+(nreads_LINE1_NGS4D2_bins[17,2]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4D2_bins[3,2]*100/((nreads_LINE1_NGS4D2_bins[3,2])+(nreads_LINE1_NGS4D2_bins[10,2])+(nreads_LINE1_NGS4D2_bins[17,2]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4D2_bins[10,2]*100/((nreads_LINE1_NGS4D2_bins[3,2])+(nreads_LINE1_NGS4D2_bins[10,2])+(nreads_LINE1_NGS4D2_bins[17,2]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4D2_bins[18,2]*100/((nreads_LINE1_NGS4D2_bins[4,2])+(nreads_LINE1_NGS4D2_bins[11,2])+(nreads_LINE1_NGS4D2_bins[18,2]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4D2_bins[4,2]*100/((nreads_LINE1_NGS4D2_bins[4,2])+(nreads_LINE1_NGS4D2_bins[11,2])+(nreads_LINE1_NGS4D2_bins[18,2]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4D2_bins[11,2]*100/((nreads_LINE1_NGS4D2_bins[4,2])+(nreads_LINE1_NGS4D2_bins[11,2])+(nreads_LINE1_NGS4D2_bins[18,2]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4D2_bins[19,2]*100/((nreads_LINE1_NGS4D2_bins[5,2])+(nreads_LINE1_NGS4D2_bins[12,2])+(nreads_LINE1_NGS4D2_bins[19,2]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4D2_bins[5,2]*100/((nreads_LINE1_NGS4D2_bins[5,2])+(nreads_LINE1_NGS4D2_bins[12,2])+(nreads_LINE1_NGS4D2_bins[19,2]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4D2_bins[12,2]*100/((nreads_LINE1_NGS4D2_bins[5,2])+(nreads_LINE1_NGS4D2_bins[12,2])+(nreads_LINE1_NGS4D2_bins[19,2]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4D2_bins[20,2]*100/((nreads_LINE1_NGS4D2_bins[6,2])+(nreads_LINE1_NGS4D2_bins[13,2])+(nreads_LINE1_NGS4D2_bins[20,2]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4D2_bins[6,2]*100/((nreads_LINE1_NGS4D2_bins[6,2])+(nreads_LINE1_NGS4D2_bins[13,2])+(nreads_LINE1_NGS4D2_bins[20,2]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4D2_bins[13,2]*100/((nreads_LINE1_NGS4D2_bins[6,2])+(nreads_LINE1_NGS4D2_bins[13,2])+(nreads_LINE1_NGS4D2_bins[20,2]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4D2_bins[21,2]*100/((nreads_LINE1_NGS4D2_bins[7,2])+(nreads_LINE1_NGS4D2_bins[14,2])+(nreads_LINE1_NGS4D2_bins[21,2]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4D2_bins[7,2]*100/((nreads_LINE1_NGS4D2_bins[7,2])+(nreads_LINE1_NGS4D2_bins[14,2])+(nreads_LINE1_NGS4D2_bins[21,2]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4D2_bins[14,2]*100/((nreads_LINE1_NGS4D2_bins[7,2])+(nreads_LINE1_NGS4D2_bins[14,2])+(nreads_LINE1_NGS4D2_bins[21,2]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4D2KO_20 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("D2KO_20",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4D2_bins[15,3]*100/((nreads_LINE1_NGS4D2_bins[1,3])+(nreads_LINE1_NGS4D2_bins[8,3])+(nreads_LINE1_NGS4D2_bins[15,3]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4D2_bins[1,3]*100/((nreads_LINE1_NGS4D2_bins[1,3])+(nreads_LINE1_NGS4D2_bins[8,3])+(nreads_LINE1_NGS4D2_bins[15,3]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4D2_bins[8,3]*100/((nreads_LINE1_NGS4D2_bins[1,3])+(nreads_LINE1_NGS4D2_bins[8,3])+(nreads_LINE1_NGS4D2_bins[15,3]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4D2_bins[16,3]*100/((nreads_LINE1_NGS4D2_bins[2,3])+(nreads_LINE1_NGS4D2_bins[9,3])+(nreads_LINE1_NGS4D2_bins[16,3]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4D2_bins[2,3]*100/((nreads_LINE1_NGS4D2_bins[2,3])+(nreads_LINE1_NGS4D2_bins[9,3])+(nreads_LINE1_NGS4D2_bins[16,3]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4D2_bins[9,3]*100/((nreads_LINE1_NGS4D2_bins[2,3])+(nreads_LINE1_NGS4D2_bins[9,3])+(nreads_LINE1_NGS4D2_bins[16,3]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4D2_bins[17,3]*100/((nreads_LINE1_NGS4D2_bins[3,3])+(nreads_LINE1_NGS4D2_bins[10,3])+(nreads_LINE1_NGS4D2_bins[17,3]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4D2_bins[3,3]*100/((nreads_LINE1_NGS4D2_bins[3,3])+(nreads_LINE1_NGS4D2_bins[10,3])+(nreads_LINE1_NGS4D2_bins[17,3]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4D2_bins[10,3]*100/((nreads_LINE1_NGS4D2_bins[3,3])+(nreads_LINE1_NGS4D2_bins[10,3])+(nreads_LINE1_NGS4D2_bins[17,3]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4D2_bins[18,3]*100/((nreads_LINE1_NGS4D2_bins[4,3])+(nreads_LINE1_NGS4D2_bins[11,3])+(nreads_LINE1_NGS4D2_bins[18,3]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4D2_bins[4,3]*100/((nreads_LINE1_NGS4D2_bins[4,3])+(nreads_LINE1_NGS4D2_bins[11,3])+(nreads_LINE1_NGS4D2_bins[18,3]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4D2_bins[11,3]*100/((nreads_LINE1_NGS4D2_bins[4,3])+(nreads_LINE1_NGS4D2_bins[11,3])+(nreads_LINE1_NGS4D2_bins[18,3]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4D2_bins[19,3]*100/((nreads_LINE1_NGS4D2_bins[5,3])+(nreads_LINE1_NGS4D2_bins[12,3])+(nreads_LINE1_NGS4D2_bins[19,3]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4D2_bins[5,3]*100/((nreads_LINE1_NGS4D2_bins[5,3])+(nreads_LINE1_NGS4D2_bins[12,3])+(nreads_LINE1_NGS4D2_bins[19,3]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4D2_bins[12,3]*100/((nreads_LINE1_NGS4D2_bins[5,3])+(nreads_LINE1_NGS4D2_bins[12,3])+(nreads_LINE1_NGS4D2_bins[19,3]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4D2_bins[20,3]*100/((nreads_LINE1_NGS4D2_bins[6,3])+(nreads_LINE1_NGS4D2_bins[13,3])+(nreads_LINE1_NGS4D2_bins[20,3]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4D2_bins[6,3]*100/((nreads_LINE1_NGS4D2_bins[6,3])+(nreads_LINE1_NGS4D2_bins[13,3])+(nreads_LINE1_NGS4D2_bins[20,3]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4D2_bins[13,3]*100/((nreads_LINE1_NGS4D2_bins[6,3])+(nreads_LINE1_NGS4D2_bins[13,3])+(nreads_LINE1_NGS4D2_bins[20,3]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4D2_bins[21,3]*100/((nreads_LINE1_NGS4D2_bins[7,3])+(nreads_LINE1_NGS4D2_bins[14,3])+(nreads_LINE1_NGS4D2_bins[21,3]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4D2_bins[7,3]*100/((nreads_LINE1_NGS4D2_bins[7,3])+(nreads_LINE1_NGS4D2_bins[14,3])+(nreads_LINE1_NGS4D2_bins[21,3]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4D2_bins[14,3]*100/((nreads_LINE1_NGS4D2_bins[7,3])+(nreads_LINE1_NGS4D2_bins[14,3])+(nreads_LINE1_NGS4D2_bins[21,3]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4D2KO_21 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("D2KO_21",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4D2X1_bins[15,1]*100/((nreads_LINE1_NGS4D2X1_bins[1,1])+(nreads_LINE1_NGS4D2X1_bins[8,1])+(nreads_LINE1_NGS4D2X1_bins[15,1]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4D2X1_bins[1,1]*100/((nreads_LINE1_NGS4D2X1_bins[1,1])+(nreads_LINE1_NGS4D2X1_bins[8,1])+(nreads_LINE1_NGS4D2X1_bins[15,1]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4D2X1_bins[8,1]*100/((nreads_LINE1_NGS4D2X1_bins[1,1])+(nreads_LINE1_NGS4D2X1_bins[8,1])+(nreads_LINE1_NGS4D2X1_bins[15,1]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4D2X1_bins[16,1]*100/((nreads_LINE1_NGS4D2X1_bins[2,1])+(nreads_LINE1_NGS4D2X1_bins[9,1])+(nreads_LINE1_NGS4D2X1_bins[16,1]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4D2X1_bins[2,1]*100/((nreads_LINE1_NGS4D2X1_bins[2,1])+(nreads_LINE1_NGS4D2X1_bins[9,1])+(nreads_LINE1_NGS4D2X1_bins[16,1]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4D2X1_bins[9,1]*100/((nreads_LINE1_NGS4D2X1_bins[2,1])+(nreads_LINE1_NGS4D2X1_bins[9,1])+(nreads_LINE1_NGS4D2X1_bins[16,1]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4D2X1_bins[17,1]*100/((nreads_LINE1_NGS4D2X1_bins[3,1])+(nreads_LINE1_NGS4D2X1_bins[10,1])+(nreads_LINE1_NGS4D2X1_bins[17,1]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4D2X1_bins[3,1]*100/((nreads_LINE1_NGS4D2X1_bins[3,1])+(nreads_LINE1_NGS4D2X1_bins[10,1])+(nreads_LINE1_NGS4D2X1_bins[17,1]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4D2X1_bins[10,1]*100/((nreads_LINE1_NGS4D2X1_bins[3,1])+(nreads_LINE1_NGS4D2X1_bins[10,1])+(nreads_LINE1_NGS4D2X1_bins[17,1]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4D2X1_bins[18,1]*100/((nreads_LINE1_NGS4D2X1_bins[4,1])+(nreads_LINE1_NGS4D2X1_bins[11,1])+(nreads_LINE1_NGS4D2X1_bins[18,1]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4D2X1_bins[4,1]*100/((nreads_LINE1_NGS4D2X1_bins[4,1])+(nreads_LINE1_NGS4D2X1_bins[11,1])+(nreads_LINE1_NGS4D2X1_bins[18,1]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4D2X1_bins[11,1]*100/((nreads_LINE1_NGS4D2X1_bins[4,1])+(nreads_LINE1_NGS4D2X1_bins[11,1])+(nreads_LINE1_NGS4D2X1_bins[18,1]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4D2X1_bins[19,1]*100/((nreads_LINE1_NGS4D2X1_bins[5,1])+(nreads_LINE1_NGS4D2X1_bins[12,1])+(nreads_LINE1_NGS4D2X1_bins[19,1]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4D2X1_bins[5,1]*100/((nreads_LINE1_NGS4D2X1_bins[5,1])+(nreads_LINE1_NGS4D2X1_bins[12,1])+(nreads_LINE1_NGS4D2X1_bins[19,1]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4D2X1_bins[12,1]*100/((nreads_LINE1_NGS4D2X1_bins[5,1])+(nreads_LINE1_NGS4D2X1_bins[12,1])+(nreads_LINE1_NGS4D2X1_bins[19,1]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4D2X1_bins[20,1]*100/((nreads_LINE1_NGS4D2X1_bins[6,1])+(nreads_LINE1_NGS4D2X1_bins[13,1])+(nreads_LINE1_NGS4D2X1_bins[20,1]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4D2X1_bins[6,1]*100/((nreads_LINE1_NGS4D2X1_bins[6,1])+(nreads_LINE1_NGS4D2X1_bins[13,1])+(nreads_LINE1_NGS4D2X1_bins[20,1]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4D2X1_bins[13,1]*100/((nreads_LINE1_NGS4D2X1_bins[6,1])+(nreads_LINE1_NGS4D2X1_bins[13,1])+(nreads_LINE1_NGS4D2X1_bins[20,1]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4D2X1_bins[21,1]*100/((nreads_LINE1_NGS4D2X1_bins[7,1])+(nreads_LINE1_NGS4D2X1_bins[14,1])+(nreads_LINE1_NGS4D2X1_bins[21,1]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4D2X1_bins[7,1]*100/((nreads_LINE1_NGS4D2X1_bins[7,1])+(nreads_LINE1_NGS4D2X1_bins[14,1])+(nreads_LINE1_NGS4D2X1_bins[21,1]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4D2X1_bins[14,1]*100/((nreads_LINE1_NGS4D2X1_bins[7,1])+(nreads_LINE1_NGS4D2X1_bins[14,1])+(nreads_LINE1_NGS4D2X1_bins[21,1]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4D2X1KO_22 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("D2X1KO_22",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4D2X1_bins[15,2]*100/((nreads_LINE1_NGS4D2X1_bins[1,2])+(nreads_LINE1_NGS4D2X1_bins[8,2])+(nreads_LINE1_NGS4D2X1_bins[15,2]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4D2X1_bins[1,2]*100/((nreads_LINE1_NGS4D2X1_bins[1,2])+(nreads_LINE1_NGS4D2X1_bins[8,2])+(nreads_LINE1_NGS4D2X1_bins[15,2]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4D2X1_bins[8,2]*100/((nreads_LINE1_NGS4D2X1_bins[1,2])+(nreads_LINE1_NGS4D2X1_bins[8,2])+(nreads_LINE1_NGS4D2X1_bins[15,2]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4D2X1_bins[16,2]*100/((nreads_LINE1_NGS4D2X1_bins[2,2])+(nreads_LINE1_NGS4D2X1_bins[9,2])+(nreads_LINE1_NGS4D2X1_bins[16,2]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4D2X1_bins[2,2]*100/((nreads_LINE1_NGS4D2X1_bins[2,2])+(nreads_LINE1_NGS4D2X1_bins[9,2])+(nreads_LINE1_NGS4D2X1_bins[16,2]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4D2X1_bins[9,2]*100/((nreads_LINE1_NGS4D2X1_bins[2,2])+(nreads_LINE1_NGS4D2X1_bins[9,2])+(nreads_LINE1_NGS4D2X1_bins[16,2]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4D2X1_bins[17,2]*100/((nreads_LINE1_NGS4D2X1_bins[3,2])+(nreads_LINE1_NGS4D2X1_bins[10,2])+(nreads_LINE1_NGS4D2X1_bins[17,2]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4D2X1_bins[3,2]*100/((nreads_LINE1_NGS4D2X1_bins[3,2])+(nreads_LINE1_NGS4D2X1_bins[10,2])+(nreads_LINE1_NGS4D2X1_bins[17,2]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4D2X1_bins[10,2]*100/((nreads_LINE1_NGS4D2X1_bins[3,2])+(nreads_LINE1_NGS4D2X1_bins[10,2])+(nreads_LINE1_NGS4D2X1_bins[17,2]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4D2X1_bins[18,2]*100/((nreads_LINE1_NGS4D2X1_bins[4,2])+(nreads_LINE1_NGS4D2X1_bins[11,2])+(nreads_LINE1_NGS4D2X1_bins[18,2]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4D2X1_bins[4,2]*100/((nreads_LINE1_NGS4D2X1_bins[4,2])+(nreads_LINE1_NGS4D2X1_bins[11,2])+(nreads_LINE1_NGS4D2X1_bins[18,2]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4D2X1_bins[11,2]*100/((nreads_LINE1_NGS4D2X1_bins[4,2])+(nreads_LINE1_NGS4D2X1_bins[11,2])+(nreads_LINE1_NGS4D2X1_bins[18,2]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4D2X1_bins[19,2]*100/((nreads_LINE1_NGS4D2X1_bins[5,2])+(nreads_LINE1_NGS4D2X1_bins[12,2])+(nreads_LINE1_NGS4D2X1_bins[19,2]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4D2X1_bins[5,2]*100/((nreads_LINE1_NGS4D2X1_bins[5,2])+(nreads_LINE1_NGS4D2X1_bins[12,2])+(nreads_LINE1_NGS4D2X1_bins[19,2]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4D2X1_bins[12,2]*100/((nreads_LINE1_NGS4D2X1_bins[5,2])+(nreads_LINE1_NGS4D2X1_bins[12,2])+(nreads_LINE1_NGS4D2X1_bins[19,2]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4D2X1_bins[20,2]*100/((nreads_LINE1_NGS4D2X1_bins[6,2])+(nreads_LINE1_NGS4D2X1_bins[13,2])+(nreads_LINE1_NGS4D2X1_bins[20,2]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4D2X1_bins[6,2]*100/((nreads_LINE1_NGS4D2X1_bins[6,2])+(nreads_LINE1_NGS4D2X1_bins[13,2])+(nreads_LINE1_NGS4D2X1_bins[20,2]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4D2X1_bins[13,2]*100/((nreads_LINE1_NGS4D2X1_bins[6,2])+(nreads_LINE1_NGS4D2X1_bins[13,2])+(nreads_LINE1_NGS4D2X1_bins[20,2]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4D2X1_bins[21,2]*100/((nreads_LINE1_NGS4D2X1_bins[7,2])+(nreads_LINE1_NGS4D2X1_bins[14,2])+(nreads_LINE1_NGS4D2X1_bins[21,2]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4D2X1_bins[7,2]*100/((nreads_LINE1_NGS4D2X1_bins[7,2])+(nreads_LINE1_NGS4D2X1_bins[14,2])+(nreads_LINE1_NGS4D2X1_bins[21,2]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4D2X1_bins[14,2]*100/((nreads_LINE1_NGS4D2X1_bins[7,2])+(nreads_LINE1_NGS4D2X1_bins[14,2])+(nreads_LINE1_NGS4D2X1_bins[21,2]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4D2X1KO_23 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("D2X1KO_23",21)))

percent_poliU_1_10 <- nreads_LINE1_NGS4D2X1_bins[15,3]*100/((nreads_LINE1_NGS4D2X1_bins[1,3])+(nreads_LINE1_NGS4D2X1_bins[8,3])+(nreads_LINE1_NGS4D2X1_bins[15,3]))
percent_poliU_1_10[is.na(percent_poliU_1_10)] <- 0
percent_poliA_1_10 <- nreads_LINE1_NGS4D2X1_bins[1,3]*100/((nreads_LINE1_NGS4D2X1_bins[1,3])+(nreads_LINE1_NGS4D2X1_bins[8,3])+(nreads_LINE1_NGS4D2X1_bins[15,3]))
percent_poliA_1_10[is.na(percent_poliA_1_10)] <- 0
percent_poliAU_1_10 <- nreads_LINE1_NGS4D2X1_bins[8,3]*100/((nreads_LINE1_NGS4D2X1_bins[1,3])+(nreads_LINE1_NGS4D2X1_bins[8,3])+(nreads_LINE1_NGS4D2X1_bins[15,3]))
percent_poliAU_1_10[is.na(percent_poliAU_1_10)] <- 0

percent_poliU_11_20 <- nreads_LINE1_NGS4D2X1_bins[16,3]*100/((nreads_LINE1_NGS4D2X1_bins[2,3])+(nreads_LINE1_NGS4D2X1_bins[9,3])+(nreads_LINE1_NGS4D2X1_bins[16,3]))
percent_poliU_11_20[is.na(percent_poliU_11_20)] <- 0
percent_poliA_11_20 <- nreads_LINE1_NGS4D2X1_bins[2,3]*100/((nreads_LINE1_NGS4D2X1_bins[2,3])+(nreads_LINE1_NGS4D2X1_bins[9,3])+(nreads_LINE1_NGS4D2X1_bins[16,3]))
percent_poliA_11_20[is.na(percent_poliA_11_20)] <- 0
percent_poliAU_11_20 <- nreads_LINE1_NGS4D2X1_bins[9,3]*100/((nreads_LINE1_NGS4D2X1_bins[2,3])+(nreads_LINE1_NGS4D2X1_bins[9,3])+(nreads_LINE1_NGS4D2X1_bins[16,3]))
percent_poliAU_11_20[is.na(percent_poliAU_11_20)] <- 0

percent_poliU_21_30 <- nreads_LINE1_NGS4D2X1_bins[17,3]*100/((nreads_LINE1_NGS4D2X1_bins[3,3])+(nreads_LINE1_NGS4D2X1_bins[10,3])+(nreads_LINE1_NGS4D2X1_bins[17,3]))
percent_poliU_21_30[is.na(percent_poliU_21_30)] <- 0
percent_poliA_21_30 <- nreads_LINE1_NGS4D2X1_bins[3,3]*100/((nreads_LINE1_NGS4D2X1_bins[3,3])+(nreads_LINE1_NGS4D2X1_bins[10,3])+(nreads_LINE1_NGS4D2X1_bins[17,3]))
percent_poliA_21_30[is.na(percent_poliA_21_30)] <- 0
percent_poliAU_21_30 <- nreads_LINE1_NGS4D2X1_bins[10,3]*100/((nreads_LINE1_NGS4D2X1_bins[3,3])+(nreads_LINE1_NGS4D2X1_bins[10,3])+(nreads_LINE1_NGS4D2X1_bins[17,3]))
percent_poliAU_21_30[is.na(percent_poliAU_21_30)] <- 0

percent_poliU_31_40 <- nreads_LINE1_NGS4D2X1_bins[18,3]*100/((nreads_LINE1_NGS4D2X1_bins[4,3])+(nreads_LINE1_NGS4D2X1_bins[11,3])+(nreads_LINE1_NGS4D2X1_bins[18,3]))
percent_poliU_31_40[is.na(percent_poliU_31_40)] <- 0
percent_poliA_31_40 <- nreads_LINE1_NGS4D2X1_bins[4,3]*100/((nreads_LINE1_NGS4D2X1_bins[4,3])+(nreads_LINE1_NGS4D2X1_bins[11,3])+(nreads_LINE1_NGS4D2X1_bins[18,3]))
percent_poliA_31_40[is.na(percent_poliA_31_40)] <- 0
percent_poliAU_31_40 <- nreads_LINE1_NGS4D2X1_bins[11,3]*100/((nreads_LINE1_NGS4D2X1_bins[4,3])+(nreads_LINE1_NGS4D2X1_bins[11,3])+(nreads_LINE1_NGS4D2X1_bins[18,3]))
percent_poliAU_31_40[is.na(percent_poliAU_31_40)] <- 0

percent_poliU_41_50 <- nreads_LINE1_NGS4D2X1_bins[19,3]*100/((nreads_LINE1_NGS4D2X1_bins[5,3])+(nreads_LINE1_NGS4D2X1_bins[12,3])+(nreads_LINE1_NGS4D2X1_bins[19,3]))
percent_poliU_41_50[is.na(percent_poliU_41_50)] <- 0
percent_poliA_41_50 <- nreads_LINE1_NGS4D2X1_bins[5,3]*100/((nreads_LINE1_NGS4D2X1_bins[5,3])+(nreads_LINE1_NGS4D2X1_bins[12,3])+(nreads_LINE1_NGS4D2X1_bins[19,3]))
percent_poliA_41_50[is.na(percent_poliA_41_50)] <- 0
percent_poliAU_41_50 <- nreads_LINE1_NGS4D2X1_bins[12,3]*100/((nreads_LINE1_NGS4D2X1_bins[5,3])+(nreads_LINE1_NGS4D2X1_bins[12,3])+(nreads_LINE1_NGS4D2X1_bins[19,3]))
percent_poliAU_41_50[is.na(percent_poliAU_41_50)] <- 0

percent_poliU_51_60 <- nreads_LINE1_NGS4D2X1_bins[20,3]*100/((nreads_LINE1_NGS4D2X1_bins[6,3])+(nreads_LINE1_NGS4D2X1_bins[13,3])+(nreads_LINE1_NGS4D2X1_bins[20,3]))
percent_poliU_51_60[is.na(percent_poliU_51_60)] <- 0
percent_poliA_51_60 <- nreads_LINE1_NGS4D2X1_bins[6,3]*100/((nreads_LINE1_NGS4D2X1_bins[6,3])+(nreads_LINE1_NGS4D2X1_bins[13,3])+(nreads_LINE1_NGS4D2X1_bins[20,3]))
percent_poliA_51_60[is.na(percent_poliA_51_60)] <- 0
percent_poliAU_51_60 <- nreads_LINE1_NGS4D2X1_bins[13,3]*100/((nreads_LINE1_NGS4D2X1_bins[6,3])+(nreads_LINE1_NGS4D2X1_bins[13,3])+(nreads_LINE1_NGS4D2X1_bins[20,3]))
percent_poliAU_51_60[is.na(percent_poliAU_51_60)] <- 0

percent_poliU_61 <- nreads_LINE1_NGS4D2X1_bins[21,3]*100/((nreads_LINE1_NGS4D2X1_bins[7,3])+(nreads_LINE1_NGS4D2X1_bins[14,3])+(nreads_LINE1_NGS4D2X1_bins[21,3]))
percent_poliU_61[is.na(percent_poliU_61)] <- 0
percent_poliA_61 <- nreads_LINE1_NGS4D2X1_bins[7,3]*100/((nreads_LINE1_NGS4D2X1_bins[7,3])+(nreads_LINE1_NGS4D2X1_bins[14,3])+(nreads_LINE1_NGS4D2X1_bins[21,3]))
percent_poliA_61[is.na(percent_poliA_61)] <- 0
percent_poliAU_61 <- nreads_LINE1_NGS4D2X1_bins[14,3]*100/((nreads_LINE1_NGS4D2X1_bins[7,3])+(nreads_LINE1_NGS4D2X1_bins[14,3])+(nreads_LINE1_NGS4D2X1_bins[21,3]))
percent_poliAU_61[is.na(percent_poliAU_61)] <- 0

percent_LINE1_NGS4D2X1KO_24 <- data.frame(percent=c(percent_poliU_1_10,percent_poliA_1_10,percent_poliAU_1_10,
                                          percent_poliU_11_20,percent_poliA_11_20,percent_poliAU_11_20,
                                          percent_poliU_21_30,percent_poliA_21_30,percent_poliAU_21_30,
                                          percent_poliU_31_40,percent_poliA_31_40,percent_poliAU_31_40,
                                          percent_poliU_41_50,percent_poliA_41_50,percent_poliAU_41_50,
                                          percent_poliU_51_60,percent_poliA_51_60,percent_poliAU_51_60,
                                          percent_poliU_61,percent_poliA_61,percent_poliAU_61),
                               tail=c(rep(c("U tail","A tail","AU tail"),7)),
                               range=(c(rep("1-10",3),rep("11-20",3),rep("21-30",3),rep("31-40",3),rep("41-50",3),rep("51-60",3),rep("61+",3))),
                               sample=c(rep("D2X1KO_24",21)))

percent_LINE1_NGS4_filter_bins = rbind(percent_LINE1_NGS4WT_10, percent_LINE1_NGS4WT_12, percent_LINE1_NGS4WT_13,
                                       percent_LINE1_NGS4X1KO_14, percent_LINE1_NGS4X1KO_16, percent_LINE1_NGS4X1KO_18,
                                       percent_LINE1_NGS4D2KO_19, percent_LINE1_NGS4D2KO_20, percent_LINE1_NGS4D2KO_21,
                                       percent_LINE1_NGS4D2X1KO_22, percent_LINE1_NGS4D2X1KO_23, percent_LINE1_NGS4D2X1KO_24)
```

```{r fig.height=10, fig.width=10}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")
ggplot(percent_LINE1_NGS4_filter_bins, aes(fill=tail, y=percent, x=range)) + 
    geom_bar(position="stack", stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT_10","WT_12","WT_13","X1KO_14","X1KO_16","X1KO_18","D2KO_19","D2KO_20","D2KO_21","D2X1KO_22","D2X1KO_23","D2X1KO_24")), ncol = 3) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) +
    scale_fill_manual(values=c("A tail" = "#74C476", "AU tail" = "#FD8D3C", "U tail" = "#A50F15")) +
    scale_x_discrete(limits = order)
```

### statistics; tail types in ranges {.tabset}
```{r include=FALSE}
percent_LINE1_NGS4_stat2 = percent_LINE1_NGS4_filter_bins

percent_LINE1_NGS4_stat2$sample <- gsub('WT_10', 'WT', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('WT_12', 'WT', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('WT_13', 'WT', percent_LINE1_NGS4_stat2$sample)

percent_LINE1_NGS4_stat2$sample <- gsub('X1KO_14', 'X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('X1KO_16', 'X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('X1KO_18', 'X1KO', percent_LINE1_NGS4_stat2$sample)

percent_LINE1_NGS4_stat2$sample <- gsub('D2KO_19', 'D2KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2KO_20', 'D2KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2KO_21', 'D2KO', percent_LINE1_NGS4_stat2$sample)

percent_LINE1_NGS4_stat2$sample <- gsub('D2X1KO_22', 'D2X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2X1KO_23', 'D2X1KO', percent_LINE1_NGS4_stat2$sample)
percent_LINE1_NGS4_stat2$sample <- gsub('D2X1KO_24', 'D2X1KO', percent_LINE1_NGS4_stat2$sample)


stat1_10 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "1-10",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat11_20 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "11-20",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat21_30 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "21-30",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat31_40 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "31-40",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat41_50 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "41-50",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat51_60 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "51-60",], group.by = "tail", method="t.test", p.adjust.method="BH")
stat61 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat2[percent_LINE1_NGS4_stat2$range == "61+",], group.by = "tail", method="t.test", p.adjust.method="BH")
```

#### range 1-10 
```{r}
stat1_10
```

#### range 11-20
```{r}
stat11_20
```

#### range 21-30
```{r}
stat21_30
```

#### range 31-40
```{r}
stat31_40
```

#### range 41-50
```{r}
stat41_50
```

#### range 51-60
```{r}
stat51_60
```

#### range 61+
```{r}
stat61
```

## LINE1_NGS4 U length in poly(AU)
```{r}
percent_LINE1_NGS4WT_10_binsAU = percents_AU_bins_fun(LINE1_NGS4WT_10,"WT_10")
percent_LINE1_NGS4WT_12_binsAU = percents_AU_bins_fun(LINE1_NGS4WT_12,"WT_12")
percent_LINE1_NGS4WT_13_binsAU = percents_AU_bins_fun(LINE1_NGS4WT_13,"WT_13")

percent_LINE1_NGS4X1KO_14_binsAU = percents_AU_bins_fun(LINE1_NGS4X1KO_14,"X1KO_14")
percent_LINE1_NGS4X1KO_16_binsAU = percents_AU_bins_fun(LINE1_NGS4X1KO_16,"X1KO_16")
percent_LINE1_NGS4X1KO_18_binsAU = percents_AU_bins_fun(LINE1_NGS4X1KO_18,"X1KO_18")

percent_LINE1_NGS4D2KO_19_binsAU = percents_AU_bins_fun(LINE1_NGS4D2KO_19,"D2KO_19")
percent_LINE1_NGS4D2KO_20_binsAU = percents_AU_bins_fun(LINE1_NGS4D2KO_20,"D2KO_20")
percent_LINE1_NGS4D2KO_21_binsAU = percents_AU_bins_fun(LINE1_NGS4D2KO_21,"D2KO_21")

percent_LINE1_NGS4D2X1KO_22_binsAU = percents_AU_bins_fun(LINE1_NGS4D2X1KO_22,"D2X1KO_22")
percent_LINE1_NGS4D2X1KO_23_binsAU = percents_AU_bins_fun(LINE1_NGS4D2X1KO_23,"D2X1KO_23")
percent_LINE1_NGS4D2X1KO_24_binsAU = percents_AU_bins_fun(LINE1_NGS4D2X1KO_24,"D2X1KO_24")

percent_LINE1_NGS4WT_binsAU = cbind(percent_LINE1_NGS4WT_10_binsAU, percent_LINE1_NGS4WT_12_binsAU, percent_LINE1_NGS4WT_13_binsAU)
percent_LINE1_NGS4WT_binsAU = as.data.frame(percent_LINE1_NGS4WT_binsAU)

percent_LINE1_NGS4X1_binsAU = cbind(percent_LINE1_NGS4X1KO_14_binsAU, percent_LINE1_NGS4X1KO_16_binsAU, percent_LINE1_NGS4X1KO_18_binsAU)
percent_LINE1_NGS4X1_binsAU = as.data.frame(percent_LINE1_NGS4X1_binsAU)

percent_LINE1_NGS4D2_binsAU = cbind(percent_LINE1_NGS4D2KO_19_binsAU, percent_LINE1_NGS4D2KO_20_binsAU, percent_LINE1_NGS4D2KO_21_binsAU)
percent_LINE1_NGS4D2_binsAU = as.data.frame(percent_LINE1_NGS4D2_binsAU)

percent_LINE1_NGS4D2X1_binsAU = cbind(percent_LINE1_NGS4D2X1KO_22_binsAU, percent_LINE1_NGS4D2X1KO_23_binsAU, percent_LINE1_NGS4D2X1KO_24_binsAU)
percent_LINE1_NGS4D2X1_binsAU = as.data.frame(percent_LINE1_NGS4D2X1_binsAU)

percent_LINE1_NGS4_AU = rbind(percent_LINE1_NGS4WT_10_binsAU, percent_LINE1_NGS4WT_12_binsAU, percent_LINE1_NGS4WT_13_binsAU, percent_LINE1_NGS4X1KO_14_binsAU, percent_LINE1_NGS4X1KO_16_binsAU, percent_LINE1_NGS4X1KO_18_binsAU, percent_LINE1_NGS4D2KO_19_binsAU, percent_LINE1_NGS4D2KO_20_binsAU, percent_LINE1_NGS4D2KO_21_binsAU, percent_LINE1_NGS4D2X1KO_22_binsAU, percent_LINE1_NGS4D2X1KO_23_binsAU, percent_LINE1_NGS4D2X1KO_24_binsAU)
```

```{r fig.height=10, fig.width=10}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")
my_colors=brewer.pal(9, "Blues")
my_colors = my_colors[4:8]

ggplot(percent_LINE1_NGS4_AU, aes(fill=U_range, y=percent, x=range)) + 
    geom_bar(stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT_10","WT_12","WT_13","X1KO_14","X1KO_16","X1KO_18","D2KO_19","D2KO_20","D2KO_21","D2X1KO_22","D2X1KO_23","D2X1KO_24")), ncol = 3) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) + 
    xlab("Range (total length of poly(AU) tail)") +
    labs(fill="U length") +
    scale_fill_manual(values=my_colors)
```

### statistics; U length in poly(AU)  {.tabset}
```{r include=FALSE}
percent_LINE1_NGS4_stat4 = percent_LINE1_NGS4_AU

percent_LINE1_NGS4_stat4$sample <- gsub('WT_10', 'WT', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('WT_12', 'WT', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('WT_13', 'WT', percent_LINE1_NGS4_stat4$sample)

percent_LINE1_NGS4_stat4$sample <- gsub('X1KO_14', 'X1KO', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('X1KO_16', 'X1KO', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('X1KO_18', 'X1KO', percent_LINE1_NGS4_stat4$sample)

percent_LINE1_NGS4_stat4$sample <- gsub('D2KO_19', 'D2KO', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('D2KO_20', 'D2KO', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('D2KO_21', 'D2KO', percent_LINE1_NGS4_stat4$sample)

percent_LINE1_NGS4_stat4$sample <- gsub('D2X1KO_22', 'D2X1KO', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('D2X1KO_23', 'D2X1KO', percent_LINE1_NGS4_stat4$sample)
percent_LINE1_NGS4_stat4$sample <- gsub('D2X1KO_24', 'D2X1KO', percent_LINE1_NGS4_stat4$sample)

stat1_10 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "1-10",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat11_20 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "11-20",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat21_30 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "21-30",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat31_40 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "31-40",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat41_50 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "41-50",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat51_60 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "51-60",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat61 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat4[percent_LINE1_NGS4_stat4$range == "61+",], group.by = "U_range", method="t.test", p.adjust.method="BH")
```

#### range 1-10 
```{r}
stat1_10
```

#### range 11-20
```{r}
stat11_20
```

#### range 21-30
```{r}
stat21_30
```

#### range 31-40
```{r}
stat31_40
```

#### range 41-50
```{r}
stat41_50
```

#### range 51-60
```{r}
stat51_60
```

#### range 61+
```{r}
stat61
```

## LINE1_NGS4 U length in poly(U) and poly(AU)
```{r}
percent_LINE1_NGS4WT_10_binsU = percents_UandAU_bins_fun(LINE1_NGS4WT_10,"WT_10")
percent_LINE1_NGS4WT_12_binsU = percents_UandAU_bins_fun(LINE1_NGS4WT_12,"WT_12")
percent_LINE1_NGS4WT_13_binsU = percents_UandAU_bins_fun(LINE1_NGS4WT_13,"WT_13")

percent_LINE1_NGS4X1KO_14_binsU = percents_UandAU_bins_fun(LINE1_NGS4X1KO_14,"X1KO_14")
percent_LINE1_NGS4X1KO_16_binsU = percents_UandAU_bins_fun(LINE1_NGS4X1KO_16,"X1KO_16")
percent_LINE1_NGS4X1KO_18_binsU = percents_UandAU_bins_fun(LINE1_NGS4X1KO_18,"X1KO_18")

percent_LINE1_NGS4D2KO_19_binsU = percents_UandAU_bins_fun(LINE1_NGS4D2KO_19,"D2KO_19")
percent_LINE1_NGS4D2KO_20_binsU = percents_UandAU_bins_fun(LINE1_NGS4D2KO_20,"D2KO_20")
percent_LINE1_NGS4D2KO_21_binsU = percents_UandAU_bins_fun(LINE1_NGS4D2KO_21,"D2KO_21")

percent_LINE1_NGS4D2X1KO_22_binsU = percents_UandAU_bins_fun(LINE1_NGS4D2X1KO_22,"D2X1KO_22")
percent_LINE1_NGS4D2X1KO_23_binsU = percents_UandAU_bins_fun(LINE1_NGS4D2X1KO_23,"D2X1KO_23")
percent_LINE1_NGS4D2X1KO_24_binsU = percents_UandAU_bins_fun(LINE1_NGS4D2X1KO_24,"D2X1KO_24")

percent_LINE1_NGS4WT_binsU = cbind(percent_LINE1_NGS4WT_10_binsU, percent_LINE1_NGS4WT_12_binsU, percent_LINE1_NGS4WT_13_binsU)
percent_LINE1_NGS4WT_binsU = as.data.frame(percent_LINE1_NGS4WT_binsU)

percent_LINE1_NGS4X1_binsU = cbind(percent_LINE1_NGS4X1KO_14_binsU, percent_LINE1_NGS4X1KO_16_binsU, percent_LINE1_NGS4X1KO_18_binsU)
percent_LINE1_NGS4X1_binsU = as.data.frame(percent_LINE1_NGS4X1_binsU)

percent_LINE1_NGS4D2_binsU = cbind(percent_LINE1_NGS4D2KO_19_binsU, percent_LINE1_NGS4D2KO_20_binsU, percent_LINE1_NGS4D2KO_21_binsU)
percent_LINE1_NGS4D2_binsU = as.data.frame(percent_LINE1_NGS4D2_binsU)

percent_LINE1_NGS4D2X1_binsU = cbind(percent_LINE1_NGS4D2X1KO_22_binsU, percent_LINE1_NGS4D2X1KO_23_binsU, percent_LINE1_NGS4D2X1KO_24_binsU)
percent_LINE1_NGS4D2X1_binsU = as.data.frame(percent_LINE1_NGS4D2X1_binsU)

percent_LINE1_NGS4_U = rbind(percent_LINE1_NGS4WT_10_binsU, percent_LINE1_NGS4WT_12_binsU, percent_LINE1_NGS4WT_13_binsU, percent_LINE1_NGS4X1KO_14_binsU, percent_LINE1_NGS4X1KO_16_binsU, percent_LINE1_NGS4X1KO_18_binsU, percent_LINE1_NGS4D2KO_19_binsU, percent_LINE1_NGS4D2KO_20_binsU, percent_LINE1_NGS4D2KO_21_binsU,percent_LINE1_NGS4D2X1KO_22_binsU, percent_LINE1_NGS4D2X1KO_23_binsU, percent_LINE1_NGS4D2X1KO_24_binsU)
```

```{r fig.height=10, fig.width=10}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")
my_colors=brewer.pal(9, "Blues")
my_colors = my_colors[4:8]

ggplot(percent_LINE1_NGS4_U, aes(fill=U_range, y=percent, x=range)) + 
    geom_bar(stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT_10","WT_12","WT_13","X1KO_14","X1KO_16","X1KO_18","D2KO_19","D2KO_20","D2KO_21","D2X1KO_22","D2X1KO_23","D2X1KO_24")), ncol = 3) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) + 
    xlab("Range (total length of poly(U) and poly(AU) tail)") +
    labs(fill="U length") +
    scale_fill_manual(values=my_colors)
```

### statistics; U length in poly(U) and poly(AU) {.tabset}
```{r include=FALSE}
percent_LINE1_NGS4_stat5 = percent_LINE1_NGS4_U

percent_LINE1_NGS4_stat5$sample <- gsub('WT_10', 'WT', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('WT_12', 'WT', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('WT_13', 'WT', percent_LINE1_NGS4_stat5$sample)

percent_LINE1_NGS4_stat5$sample <- gsub('X1KO_14', 'X1KO', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('X1KO_16', 'X1KO', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('X1KO_18', 'X1KO', percent_LINE1_NGS4_stat5$sample)

percent_LINE1_NGS4_stat5$sample <- gsub('D2KO_19', 'D2KO', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('D2KO_20', 'D2KO', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('D2KO_21', 'D2KO', percent_LINE1_NGS4_stat5$sample)

percent_LINE1_NGS4_stat5$sample <- gsub('D2X1KO_22', 'D2X1KO', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('D2X1KO_23', 'D2X1KO', percent_LINE1_NGS4_stat5$sample)
percent_LINE1_NGS4_stat5$sample <- gsub('D2X1KO_24', 'D2X1KO', percent_LINE1_NGS4_stat5$sample)

stat1_10 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "1-10",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat11_20 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "11-20",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat21_30 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "21-30",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat31_40 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "31-40",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat41_50 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "41-50",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat51_60 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "51-60",], group.by = "U_range", method="t.test", p.adjust.method="BH")
stat61 = compare_means(percent ~ sample, percent_LINE1_NGS4_stat5[percent_LINE1_NGS4_stat5$range == "61+",], group.by = "U_range", method="t.test", p.adjust.method="BH")
```

#### range 1-10 
```{r}
stat1_10
```

#### range 11-20
```{r}
stat11_20
```

#### range 21-30
```{r}
stat21_30
```

#### range 31-40
```{r}
stat31_40
```

#### range 41-50
```{r}
stat41_50
```

#### range 51-60
```{r}
stat51_60
```

#### range 61+
```{r}
stat61
```

# Percentage of tails in length range (mean); filtered reads {.tabset}

## LINE1_NGS4
```{r}
xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("WT_10","WT_12","WT_13")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("WT_10","WT_12","WT_13")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("WT_10","WT_12","WT_13")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("WT_10","WT_12","WT_13")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("WT_10","WT_12","WT_13")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("WT_10","WT_12","WT_13")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("WT_10","WT_12","WT_13")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("WT_10","WT_12","WT_13")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("WT_10","WT_12","WT_13")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("WT_10","WT_12","WT_13")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("WT_10","WT_12","WT_13")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("WT_10","WT_12","WT_13")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("WT_10","WT_12","WT_13")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("WT_10","WT_12","WT_13")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("WT_10","WT_12","WT_13")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("WT_10","WT_12","WT_13")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("WT_10","WT_12","WT_13")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("WT_10","WT_12","WT_13")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("WT_10","WT_12","WT_13")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("WT_10","WT_12","WT_13")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("WT_10","WT_12","WT_13")),]

percent_mean_LINE1_NGS4WT <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("WT",21)))


xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

percent_mean_LINE1_NGS4X1 <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("X1KO",21)))

xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

percent_mean_LINE1_NGS4D2 <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("D2KO",21)))

xU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU1_10 = xU1_10[with(xU1_10, range == "1-10"),]
xU1_10 = xU1_10[with(xU1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU11_20 = xU11_20[with(xU11_20, range == "11-20"),]
xU11_20 = xU11_20[with(xU11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU21_30 = xU21_30[with(xU21_30, range == "21-30"),]
xU21_30 = xU21_30[with(xU21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU31_40 = xU31_40[with(xU31_40, range == "31-40"),]
xU31_40 = xU31_40[with(xU31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU41_50 = xU41_50[with(xU41_50, range == "41-50"),]
xU41_50 = xU41_50[with(xU41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU51_60 = xU51_60[with(xU51_60, range == "51-60"),]
xU51_60 = xU51_60[with(xU51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "U tail"),]
xU61 = xU61[with(xU61, range == "61+"),]
xU61 = xU61[with(xU61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA1_10 = xA1_10[with(xA1_10, range == "1-10"),]
xA1_10 = xA1_10[with(xA1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA11_20 = xA11_20[with(xA11_20, range == "11-20"),]
xA11_20 = xA11_20[with(xA11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA21_30 = xA21_30[with(xA21_30, range == "21-30"),]
xA21_30 = xA21_30[with(xA21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA31_40 = xA31_40[with(xA31_40, range == "31-40"),]
xA31_40 = xA31_40[with(xA31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA41_50 = xA41_50[with(xA41_50, range == "41-50"),]
xA41_50 = xA41_50[with(xA41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA51_60 = xA51_60[with(xA51_60, range == "51-60"),]
xA51_60 = xA51_60[with(xA51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xA61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "A tail"),]
xA61 = xA61[with(xA61, range == "61+"),]
xA61 = xA61[with(xA61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU1_10 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU1_10 = xAU1_10[with(xAU1_10, range == "1-10"),]
xAU1_10 = xAU1_10[with(xAU1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU11_20 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU11_20 = xAU11_20[with(xAU11_20, range == "11-20"),]
xAU11_20 = xAU11_20[with(xAU11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU21_30 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU21_30 = xAU21_30[with(xAU21_30, range == "21-30"),]
xAU21_30 = xAU21_30[with(xAU21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU31_40 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU31_40 = xAU31_40[with(xAU31_40, range == "31-40"),]
xAU31_40 = xAU31_40[with(xAU31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU41_50 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU41_50 = xAU41_50[with(xAU41_50, range == "41-50"),]
xAU41_50 = xAU41_50[with(xAU41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU51_60 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU51_60 = xAU51_60[with(xAU51_60, range == "51-60"),]
xAU51_60 = xAU51_60[with(xAU51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

xAU61 = percent_LINE1_NGS4_bins[with(percent_LINE1_NGS4_bins, tail == "AU tail"),]
xAU61 = xAU61[with(xAU61, range == "61+"),]
xAU61 = xAU61[with(xAU61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

percent_mean_LINE1_NGS4D2X1 <- data.frame(percent=c(mean(xU1_10$percent),mean(xU11_20$percent),mean(xU21_30$percent),mean(xU31_40$percent),mean(xU41_50$percent),mean(xU51_60$percent),mean(xU61$percent),
                                            mean(xA1_10$percent),mean(xA11_20$percent),mean(xA21_30$percent),mean(xA31_40$percent),mean(xA41_50$percent),mean(xA51_60$percent),mean(xA61$percent),
                                            mean(xAU1_10$percent),mean(xAU11_20$percent),mean(xAU21_30$percent),mean(xAU31_40$percent),mean(xAU41_50$percent),mean(xAU51_60$percent),mean(xAU61$percent)),
                               tail=c(rep("U tail",7),rep("A tail",7),rep("AU tail",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),3)),
                               sample=c(rep("D2X1KO",21)))

percent_mean_LINE1_NGS4 = rbind(percent_mean_LINE1_NGS4WT,percent_mean_LINE1_NGS4X1,percent_mean_LINE1_NGS4D2,percent_mean_LINE1_NGS4D2X1)
```

```{r fig.height=7, fig.width=7}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")

ggplot(percent_mean_LINE1_NGS4, aes(fill=tail, y=percent, x=range)) + 
    geom_bar(position="fill", stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT","X1KO","D2KO","D2X1KO"))) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) +
    scale_fill_manual(values=c("A tail" = "#74C476", "AU tail" = "#FD8D3C", "U tail" = "#A50F15")) +
    scale_x_discrete(limits = order)
```

## LINE1_NGS4 Ulength in poly(AU)
```{r}
x1_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("WT_10","WT_12","WT_13")),]

x1_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("WT_10","WT_12","WT_13")),]

x1_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("WT_10","WT_12","WT_13")),]

x1_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("WT_10","WT_12","WT_13")),]

x1_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("WT_10","WT_12","WT_13")),]

x1_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("WT_10","WT_12","WT_13")),]

x1_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("WT_10","WT_12","WT_13")),]

x2_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("WT_10","WT_12","WT_13")),]

x2_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("WT_10","WT_12","WT_13")),]

x2_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("WT_10","WT_12","WT_13")),]

x2_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("WT_10","WT_12","WT_13")),]

x2_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("WT_10","WT_12","WT_13")),]

x2_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("WT_10","WT_12","WT_13")),]

x2_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("WT_10","WT_12","WT_13")),]

x34_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("WT_10","WT_12","WT_13")),]

x34_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("WT_10","WT_12","WT_13")),]

x34_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("WT_10","WT_12","WT_13")),]

x34_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("WT_10","WT_12","WT_13")),]

x34_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("WT_10","WT_12","WT_13")),]

x34_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("WT_10","WT_12","WT_13")),]

x34_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("WT_10","WT_12","WT_13")),]

x57_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("WT_10","WT_12","WT_13")),]

x57_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("WT_10","WT_12","WT_13")),]

x57_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("WT_10","WT_12","WT_13")),]

x57_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("WT_10","WT_12","WT_13")),]

x57_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("WT_10","WT_12","WT_13")),]

x57_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("WT_10","WT_12","WT_13")),]

x57_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("WT_10","WT_12","WT_13")),]

x8_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("WT_10","WT_12","WT_13")),]

x8_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("WT_10","WT_12","WT_13")),]

x8_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("WT_10","WT_12","WT_13")),]

x8_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("WT_10","WT_12","WT_13")),]

x8_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("WT_10","WT_12","WT_13")),]

x8_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("WT_10","WT_12","WT_13")),]

x8_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("WT_10","WT_12","WT_13")),]

percent_mean_LINE1_NGS4WT_AU <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("WT",35)))

x1_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

percent_mean_LINE1_NGS4X1_AU <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("X1KO",35)))

x1_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

percent_mean_LINE1_NGS4D2_AU <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("D2KO",35)))

x1_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_1_10 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_11_20 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_21_30 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_31_40 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_41_50 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_51_60 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_61 = percent_LINE1_NGS4_AU[with(percent_LINE1_NGS4_AU, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

percent_mean_LINE1_NGS4D2X1_AU <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("D2X1KO",35)))

percent_mean_LINE1_NGS4_AU = rbind(percent_mean_LINE1_NGS4WT_AU,percent_mean_LINE1_NGS4X1_AU,percent_mean_LINE1_NGS4D2_AU,percent_mean_LINE1_NGS4D2X1_AU)
```

```{r fig.height=7, fig.width=7}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")
my_colors=brewer.pal(9, "Blues")
my_colors = my_colors[4:8]

ggplot(percent_mean_LINE1_NGS4_AU, aes(fill=U_range, y=percent, x=range)) + 
    geom_bar(position="fill", stat="identity") + 
    facet_wrap(~factor(sample, levels = c("WT","X1KO","D2KO","D2X1KO"))) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) + 
    xlab("Range (total length of poly(AU) tail)") +
    labs(fill="U length") +
    scale_fill_manual(values=my_colors)
```

## LINE1_NGS4 Ulength in poly(U) and poly(AU)
```{r}
x1_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("WT_10","WT_12","WT_13")),]

x1_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("WT_10","WT_12","WT_13")),]

x1_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("WT_10","WT_12","WT_13")),]

x1_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("WT_10","WT_12","WT_13")),]

x1_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("WT_10","WT_12","WT_13")),]

x1_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("WT_10","WT_12","WT_13")),]

x1_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("WT_10","WT_12","WT_13")),]

x2_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("WT_10","WT_12","WT_13")),]

x2_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("WT_10","WT_12","WT_13")),]

x2_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("WT_10","WT_12","WT_13")),]

x2_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("WT_10","WT_12","WT_13")),]

x2_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("WT_10","WT_12","WT_13")),]

x2_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("WT_10","WT_12","WT_13")),]

x2_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("WT_10","WT_12","WT_13")),]

x34_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("WT_10","WT_12","WT_13")),]

x34_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("WT_10","WT_12","WT_13")),]

x34_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("WT_10","WT_12","WT_13")),]

x34_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("WT_10","WT_12","WT_13")),]

x34_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("WT_10","WT_12","WT_13")),]

x34_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("WT_10","WT_12","WT_13")),]

x34_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("WT_10","WT_12","WT_13")),]

x57_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("WT_10","WT_12","WT_13")),]

x57_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("WT_10","WT_12","WT_13")),]

x57_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("WT_10","WT_12","WT_13")),]

x57_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("WT_10","WT_12","WT_13")),]

x57_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("WT_10","WT_12","WT_13")),]

x57_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("WT_10","WT_12","WT_13")),]

x57_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("WT_10","WT_12","WT_13")),]

x8_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("WT_10","WT_12","WT_13")),]

x8_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("WT_10","WT_12","WT_13")),]

x8_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("WT_10","WT_12","WT_13")),]

x8_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("WT_10","WT_12","WT_13")),]

x8_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("WT_10","WT_12","WT_13")),]

x8_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("WT_10","WT_12","WT_13")),]

x8_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("WT_10","WT_12","WT_13")),]

percent_mean_LINE1_NGS4WT_U <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("WT",35)))

x1_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x1_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x2_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x34_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x57_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

x8_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("X1KO_14","X1KO_16","X1KO_18")),]

percent_mean_LINE1_NGS4X1_U <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("X1KO",35)))

x1_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x1_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x2_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x34_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x57_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

x8_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("D2KO_19","D2KO_20","D2KO_21")),]

percent_mean_LINE1_NGS4D2_U <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("D2KO",35)))

x1_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_1_10 = x1_1_10[with(x1_1_10, range == "1-10"),]
x1_1_10 = x1_1_10[with(x1_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_11_20 = x1_11_20[with(x1_11_20, range == "11-20"),]
x1_11_20 = x1_11_20[with(x1_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_21_30 = x1_21_30[with(x1_21_30, range == "21-30"),]
x1_21_30 = x1_21_30[with(x1_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_31_40 = x1_31_40[with(x1_31_40, range == "31-40"),]
x1_31_40 = x1_31_40[with(x1_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_41_50 = x1_41_50[with(x1_41_50, range == "41-50"),]
x1_41_50 = x1_41_50[with(x1_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_51_60 = x1_51_60[with(x1_51_60, range == "51-60"),]
x1_51_60 = x1_51_60[with(x1_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x1_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "1"),]
x1_61 = x1_61[with(x1_61, range == "61+"),]
x1_61 = x1_61[with(x1_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_1_10 = x2_1_10[with(x2_1_10, range == "1-10"),]
x2_1_10 = x2_1_10[with(x2_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_11_20 = x2_11_20[with(x2_11_20, range == "11-20"),]
x2_11_20 = x2_11_20[with(x2_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_21_30 = x2_21_30[with(x2_21_30, range == "21-30"),]
x2_21_30 = x2_21_30[with(x2_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_31_40 = x2_31_40[with(x2_31_40, range == "31-40"),]
x2_31_40 = x2_31_40[with(x2_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_41_50 = x2_41_50[with(x2_41_50, range == "41-50"),]
x2_41_50 = x2_41_50[with(x2_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_51_60 = x2_51_60[with(x2_51_60, range == "51-60"),]
x2_51_60 = x2_51_60[with(x2_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x2_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "2"),]
x2_61 = x2_61[with(x2_61, range == "61+"),]
x2_61 = x2_61[with(x2_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_1_10 = x34_1_10[with(x34_1_10, range == "1-10"),]
x34_1_10 = x34_1_10[with(x34_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_11_20 = x34_11_20[with(x34_11_20, range == "11-20"),]
x34_11_20 = x34_11_20[with(x34_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_21_30 = x34_21_30[with(x34_21_30, range == "21-30"),]
x34_21_30 = x34_21_30[with(x34_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_31_40 = x34_31_40[with(x34_31_40, range == "31-40"),]
x34_31_40 = x34_31_40[with(x34_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_41_50 = x34_41_50[with(x34_41_50, range == "41-50"),]
x34_41_50 = x34_41_50[with(x34_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_51_60 = x34_51_60[with(x34_51_60, range == "51-60"),]
x34_51_60 = x34_51_60[with(x34_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x34_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "3-4"),]
x34_61 = x34_61[with(x34_61, range == "61+"),]
x34_61 = x34_61[with(x34_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_1_10 = x57_1_10[with(x57_1_10, range == "1-10"),]
x57_1_10 = x57_1_10[with(x57_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_11_20 = x57_11_20[with(x57_11_20, range == "11-20"),]
x57_11_20 = x57_11_20[with(x57_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_21_30 = x57_21_30[with(x57_21_30, range == "21-30"),]
x57_21_30 = x57_21_30[with(x57_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_31_40 = x57_31_40[with(x57_31_40, range == "31-40"),]
x57_31_40 = x57_31_40[with(x57_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_41_50 = x57_41_50[with(x57_41_50, range == "41-50"),]
x57_41_50 = x57_41_50[with(x57_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_51_60 = x57_51_60[with(x57_51_60, range == "51-60"),]
x57_51_60 = x57_51_60[with(x57_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x57_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "5-7"),]
x57_61 = x57_61[with(x57_61, range == "61+"),]
x57_61 = x57_61[with(x57_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_1_10 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_1_10 = x8_1_10[with(x8_1_10, range == "1-10"),]
x8_1_10 = x8_1_10[with(x8_1_10, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_11_20 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_11_20 = x8_11_20[with(x8_11_20, range == "11-20"),]
x8_11_20 = x8_11_20[with(x8_11_20, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_21_30 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_21_30 = x8_21_30[with(x8_21_30, range == "21-30"),]
x8_21_30 = x8_21_30[with(x8_21_30, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_31_40 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_31_40 = x8_31_40[with(x8_31_40, range == "31-40"),]
x8_31_40 = x8_31_40[with(x8_31_40, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_41_50 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_41_50 = x8_41_50[with(x8_41_50, range == "41-50"),]
x8_41_50 = x8_41_50[with(x8_41_50, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_51_60 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_51_60 = x8_51_60[with(x8_51_60, range == "51-60"),]
x8_51_60 = x8_51_60[with(x8_51_60, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

x8_61 = percent_LINE1_NGS4_U[with(percent_LINE1_NGS4_U, U_range == "8+"),]
x8_61 = x8_61[with(x8_61, range == "61+"),]
x8_61 = x8_61[with(x8_61, sample == c("D2X1KO_22","D2X1KO_23","D2X1KO_24")),]

percent_mean_LINE1_NGS4D2X1_U <- data.frame(percent=c(mean(x1_1_10$percent),mean(x1_11_20$percent),mean(x1_21_30$percent),mean(x1_31_40$percent),mean(x1_41_50$percent),mean(x1_51_60$percent),mean(x1_61$percent),
                                             mean(x2_1_10$percent),mean(x2_11_20$percent),mean(x2_21_30$percent),mean(x2_31_40$percent),mean(x2_41_50$percent),mean(x2_51_60$percent),mean(x2_61$percent),
                                             mean(x34_1_10$percent),mean(x34_11_20$percent),mean(x34_21_30$percent),mean(x34_31_40$percent),mean(x34_41_50$percent),mean(x34_51_60$percent),mean(x34_61$percent),
                                             mean(x57_1_10$percent),mean(x57_11_20$percent),mean(x57_21_30$percent),mean(x57_31_40$percent),mean(x57_41_50$percent),mean(x57_51_60$percent),mean(x57_61$percent),
                                             mean(x8_1_10$percent),mean(x8_11_20$percent),mean(x8_21_30$percent),mean(x8_31_40$percent),mean(x8_41_50$percent),mean(x8_51_60$percent),mean(x8_61$percent)),
                               U_range=c(rep("1",7),rep("2",7),rep("3-4",7),rep("5-7",7),rep("8+",7)),
                               range=(rep(c("1-10","11-20","21-30","31-40","41-50","51-60","61+"),5)),
                               sample=c(rep("D2X1KO",35)))

percent_mean_LINE1_NGS4_U = rbind(percent_mean_LINE1_NGS4WT_U,percent_mean_LINE1_NGS4X1_U,percent_mean_LINE1_NGS4D2_U,percent_mean_LINE1_NGS4D2X1_U)
```

```{r fig.height=7, fig.width=7}
order = c("1-10","11-20","21-30","31-40","41-50","51-60","61+")
my_colors=brewer.pal(9, "Blues")
my_colors = my_colors[4:8]

ggplot(percent_mean_LINE1_NGS4_U, aes(fill=U_range, y=percent, x=range)) + 
    geom_bar(position="fill", stat="identity") +
    facet_wrap(~factor(sample, levels = c("WT","X1KO","D2KO","D2X1KO"))) +
    ggtitle("LINE1_NGS4") +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title=element_text(size=14),
          axis.text=element_text(size=12),
          legend.title=element_text(size=14),
          legend.text=element_text(size=12),
          strip.text = element_text(size=10)) +
    scale_x_discrete(limits = order) + 
    xlab("Range (total length of poly(U) and poly(AU) tail)") +
    labs(fill="U length") +
    scale_fill_manual(values=my_colors)
```
