General
.switch to using BSSeq?
.Generalize to histone data? Show exampe with Roadmap data and RNA-seq
. Change meth sites from single position to whole palindormes? Check BSseq

methodical.R ! Revise if updating to also work with histone data

chunk_regions.R # Default is one core
.chunk_regions

rapid_cor_test.R
.rapidCorTest

meth_rse_functions.R ! Show examples for all in meth_rse vignette
.extractGRangesMethSiteValues # Check if redundant and rename get_values_overlapping_regions
.sampleMethSites ! Show example in working_with_meth_rse vignette with e.g. mouse for CpG islands, gene bodies, repeats
.liftoverMethRSE
.maskRangesInRSE 

plotting_functions.R
rangesRelativeToTSS ! Make non-exported
plotRegionValues
plotMethSiteCorCoefs ! Simplify to use code from plotRegionValues
plotTMRs Generalize to worj with other regions?
plotMethodicalScores ! Simplify to use code from plotRegionValues
annotatePlot

granges_manipulation.R
extractMethSitesFromGenome ! Check if redundant with 
.expand_granges ! Check if redundant with promoters?
.strandedDistance ! Make non-exported + plus check if any other function cab perform the same task?
extractMethSitesFromGenome ! Check if redundnat with 
rangesRelativeToTSS ! Make non-exported?
.count_covered_bases. # Used by calculate_regions_intersections. ! Remove from package?
calculate_regions_intersections # Used by annotateGRanges. ! Remove from package?
createRandomRegions ! Check if redundant with RegioneR

genome_annotation.R
.annotateGRanges ! Remove from package? 

object_documentation.R ! Check that all objects included

kallisto_quantify.R: ! Remove from package
.kallistoIndex
.kallistoQuantify
.sumTranscriptValuesForGenes

### make_meth_rse
Pass meth_site_context_width to .split_meth_files_into_chunks
Add TCGA WGBS files with coverage
Add option for files missing coverage + use for array files
Add preset options like CGmap, bedMethyl, etc

.make_meth_rse_setup = Sets chunkdims and creates HDF5 file. Creates realization sinks for beta and cov and HDF5 grid. Creates temporary directories for each chunk. 
Splits meth_sites and samples into groups, with each chunk being a combination of one meth_site and one sample group. Also returns a list with the samples in each chunk, with the
grid being filled row-wise
Returns a list with setup parameters. 

.split_bedgraphs_into_chunks = Creates a list of parameters to pass to .split_meth_file using BiocParallel::bpmapply. This is the part that can be executed in parallel.

.split_meth_file = Reads in a meth file, standardizes columns, collapses strands if specified, sorts meth_df and add values for all sites in meth_sites and then 
loops through each group of methylation sites and writes them to a file with the sample name in the directory for the appropriate chunk.
Chunks fill the HDF5-array in a column-wise manner i.e. all the chunks in the 1st column of the grid are added first and then the 2nd and so on

.write_chunks_to_hdf5 = Write the beta and cov columns in the chunk directories to the appropriate chunk of the HDF5 file. Needs to be executed sequentially. 

.create_meth_rse_from_hdf5

### To do

Add parameters to extract meth sites to say if sites are symmetrically methylated or not

Add option to provide cmd to fread to filter input files before reading?
Chnage use of BiocParallel?/Make .split_meth_file cheaper
Make .check_input_files parallel

set context width

meth_df and meth_sites_df names too similar
Use data.table syntax instead of summarize and group_by e.g. with make_meth_rse functions e.g. DT2 <- DT[, .(mean_x = mean(x)), by = group]
Remove decimal places?

Each bg in extdata has 750 lines

Print messages at start up with 0-based, stranded, context information etc. 
Make summarize methylation return a SummarizedExperiment

Check what happens if .split_meth_file throws an error when used in parallel
Print number of matching sites per file

Check there is enough memory on machine before starting make_meth_rse!!!
Allow files with only methylation and no coverage

Remove use of BSgenome.Hsapiens.UCSC.hg19 in working_with_meth_rses.Rmd

Check that overwrite in make_meth_rse works

Make export_bedGraph_from_rse also export bigWigs? Use genome info from meth_rse

### Make reading files use less memory
meth_sites (modified), meth_sites_df, meth_sites_final, 
parameters_list (contains meth_sites_df)[should not be duplicated unless copied]

Each call to .split_meth_file using 5 GB RAM
Inside 
meth_site_values = meth_sites_df
meth_df = Read in meth_file
GenomicRanges::isDisjoint uses 3 GB
merge uses 2.5 GB (try data.table vs merge)
.collapse_strands uses 3 GB (try data.table vs merge)

