## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/"
)

## -----------------------------------------------------------------------------
ceiling(-10*log10(0.5))

## ----eval=FALSE, include=TRUE-------------------------------------------------
# ## Prepare many samples
# inpath <- "filtered/"
# outpath <- "Processed/"
# filelist <- list.files(path = inpath, pattern = "*.bam" )
# filelist <- gsub(".bam", "", filelist)
# 
# for( i in 1:length(filelist)){
#   prepare_data(filelist[i], inpath, outpath)
# }
# 

## ----eval=FALSE, include=TRUE-------------------------------------------------
# ## Prepare many samples
# textfiles <- list.files(path = "Processed/", pattern = "*.txt", full.name = FALSE)
# 
# for(i in 1:length(textfiles)){
#   temp <- process_data(paste0("Processed/", textfiles[i]), # File with full location
#                        min.depth = 2, # Total coverage gilter
#                        max.depth.quantile.prob = 0.9, # Total coverage filter
#                        error = 0.01, # Allele Coverage Filter
#                        trunc = c(0,0)) # Allele Frequency Filter
#   assign((gsub(".txt", "", textfiles[i])), temp)
# }

## ----eval=FALSE, include=TRUE-------------------------------------------------
# # Plot
# hist(xm[,1])
# 
# ## Error cutoffs
# ### If I increase the sequence error rate, how many sites will likely be removed?
# new.e <- 0.02 # 2 sites out of every 100
# removes <- c()
# for(i in 1:nrow(xm)){
#   if(xm[i,2] < (xm[i,1]*new.e) | xm[i,2] > (xm[i,1]*(1-new.e))){
#   removes[i] <- 1
# }else{
#   removes[i] <- 0
#   }
# }
# sum(removes)

## ----eval=FALSE, include=TRUE-------------------------------------------------
# # Convert to allele frequency
# xi <- xm[,2]/xm[,1]
# 
# # Plot
# hist(xi)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/NoTrunc.png",  dpi = 5000)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/Truncated.png", dpi = 5000)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/DataCompare.png",  dpi = 5000)

## ----eval=FALSE, include=TRUE-------------------------------------------------
# # Read in nQuire txt file
# df <- process_nquire("file.txt")

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/FancyDenoise88069-lowtrunc.png",  dpi = 5000)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/DenoiseFancy88069-highertrunc.png",  dpi = 5000)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/noTruncBclean.png",  dpi = 5000)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/TruncBClean.png",  dpi = 5000)

## ----echo=FALSE, out.width="125%", fig.align='center'-------------------------
knitr::include_graphics("../man/figures/AllInThisTogether.png",  dpi = 5000)

