## ----libraryLoad---------------------------------------------------------
suppressMessages(library(metagene))

## ----bamFiles------------------------------------------------------------
bamFile1Rep1 <- system.file("extdata/align1_rep1.bam", package="metagene")
bamFile1Rep2 <- system.file("extdata/align1_rep2.bam", package="metagene")
bamFile2Rep1 <- system.file("extdata/align2_rep1.bam", package="metagene")
bamFile2Rep2 <- system.file("extdata/align2_rep2.bam", package="metagene")
bamFileCTRL <- system.file("extdata/ctrl.bam", package="metagene")
bamFiles <- c(bamFile1Rep1, bamFile1Rep2, bamFile2Rep1, bamFile2Rep2, bamFileCTRL)
bamFiles

## ----designFile----------------------------------------------------------
fileDesign <- system.file("extdata/design.txt", package="metagene")
design <- read.table(fileDesign, header=TRUE, stringsAsFactors=FALSE)
design$Samples <- paste(system.file("extdata", package="metagene"), design$Samples, sep="/")
design

## ----alternateDesign-----------------------------------------------------
design <- data.frame(Samples = c("align1_rep1.bam", "align1_rep2.bam", "align2_rep1.bam", "align2_rep2.bam", "ctrl.bam"),
		     align1 = c(1,1,0,0,2), align2 = c(0,0,1,1,2))
design$Samples <- paste0(system.file("extdata", package="metagene"), "/", design$Samples)
design

## ----featuresFile--------------------------------------------------------
fileExample <- system.file("extdata/list1.txt", package="metagene")
featuresFileExample <- read.table(fileExample, header=FALSE, stringsAsFactors=FALSE)
head(featuresFileExample)

## ----featuresArgument----------------------------------------------------
fileList1 <- system.file("extdata/list1.txt", package="metagene")
fileList2 <- system.file("extdata/list2.txt", package="metagene")
features <- c(fileList1, fileList2)
features

## ----regionsArgument-----------------------------------------------------
fileBed1 <- system.file("extdata/list1.bed", package="metagene")
fileBed2 <- system.file("extdata/list2.bed", package="metagene")
regions <- c(fileBed1, fileBed2)
regions

## ----parseFeaturesExample------------------------------------------------
groupsFeatures <- parseFeatures(bamFiles=bamFiles, features=features, design=design, specie="mouse", maxDistance=1000)

## ----parseRegionsExample, eval=FALSE-------------------------------------
#  groupsRegions <- parseRegions(bamFiles=bamFiles, regions=regions, design=design, specie="mouse", paddingSize=0)

## ----plotMatricesExample1------------------------------------------------
names(groupsFeatures$matrix)
groupsToPlot <- list(group1=c("list1_align1", "list1_align2"), group2=c("list2_align1", "list2_align2"))
DF <- plotMatrices(groupsToPlot, groupsFeatures)

## ----plotMatricesExample2------------------------------------------------
groupsToPlot <- list(group1="list1_align1", group2="list1_align2")
DF <- plotMatrices(groupsToPlot, groupsFeatures)

## ----showDataFrame-------------------------------------------------------
head(DF)

