R/calculate_intensity.R: Added a TODO in prepareBamFiles function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
Update R/calculate_intensity.R : change error() function to stop() function

Change error() function, which is not a valid function, to stop() function
Merge branch 'master' of https://github.com/adeschen/MetaFeatures
Changed the name of the prepareRegions function to prepareFeatures in main code and in unit tests

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: added the scaleVector function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
Merge branch 'patch-1' of https://github.com/adeschen/MetaFeatures
R/calculate_intensity.R: prepareBamFiles results column bam and oldBam are now character instead of factors

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: extract the mergeMatrix from plotFeatures function to make it a function of it's own

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: removed the applyOnBamFiles function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Added the prepareRegions function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity: Important changes in the main data structure and in parseBamFiles function.

The old data structure stored the same data in multiple places. To avoid this, the raw counts and the rpm counts are
now stored in groups$raw and groups$rpm, respectively. These list contains as many elements as there are features groups, the
idea being that we parse different features in each features groups and that the information should not be redundant.

              |----- featuresGroup1    |----- bamFile1    |----- feature
groups$raw ---|----- featuresGroup2 ---|----- bamFile2 ---|----- feature2
              |----- ...               |----- ...         |----- ...
              |----- featuresGroupN    |----- bamFileN    |----- featureN

              |----- featuresGroup1    |----- bamFile1    |----- feature
groups$rpm ---|----- featuresGroup2 ---|----- bamFile2 ---|----- feature2
              |----- ...               |----- ...         |----- ...
              |----- featuresGroupN    |----- bamFileN    |----- featureN

Note: bamFiles include input and controls.

Description of the main data structure:

design:			The design parsed from the design file. (optional)
param:			The params that were used (some may be empty depending on the type of input used):
			 * specie
			 * cores
			 * paddingSize
			 * maxDistance
bamFileDescription:	The data frame that contains relevant information about the bam files:
			 * oldBam:		The original names of the bam files.
			 * bam:			The name of the sorted bam files (if original file are already sorted,
						this column is identical to oldBam).
			 * alignedCount:	The number of aligned reads for the current bam file.
regionsGroups:		The list of every groups of features to include in the analysis. The data is currently stored
			in a data frame (relevant columns are: "space", "start_position" and "end_position").
data:			The data that is specific to every featuresGroup/designGroup in the analysis.
			Each combination is a list that contains:
			 * featureName:		The name of the current features group.
			 * designName:		The name of the current design group.
			 * bamFiles:		The names of the bam files (input and control) used for that combination.
			 * mergedControls:	If multiple controls were used, this list contains the average value for
						every features in current combination. Otherwise, it contains the same
						data that the original rpm version of the control bam file.
			 * noCTRL:		The normalized counts for every input bam files with the values of the
						merged control substracted.
raw:			The raw counts for every bam files in the current experiment.
rpm:			The normalized count for every bam files in the current experiment.

The new version of parseBamFiles is a splitted version of the old one:
 * The parseBamFiles now only returns raw counts.
 * Added a rawCountsToRPM function that normalize raw counts.
 * The removeControls was recoded to fit with the new data structure and should also be more memory efficient.

The old version of parseBamFiles is now deprecated but still not completely removed from the code (parseBamFiles.old).
The old version of removeControls is now deprecated but still not completely removed from the code (removeControls.old).

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: A line was missed in commit 10ab2d5b185a090604abc9b640ff87617da5de13

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Corrected an error in parseBamFiles interface

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Added the scaledVectors function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Some operations in prepareRegions are now multicores

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Added the prepareRegionsPaddings function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Changed the mergeMatrix function to fit with new data structure

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Added the parseRegions function

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: Updated the parseBamFiles documentation

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>
R/calculate_intensity.R: relaxed the params validation in extractReadsInRegions

Signed-off-by: Charles Joly Beauparlant <Charles.Joly-Beauparlant@crchul.ulaval.ca>