Skip to content

Commit

Permalink
Merge pull request #25 from kkleinoros/master
Browse files Browse the repository at this point in the history
S4 documentation
  • Loading branch information
kkleinoros authored Dec 21, 2016
2 parents 087fe3f + aab710f commit e00c3ac
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 95 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Title: Normalization Procedure for Infinium HumanMethylation450 BeadChip Kit
Version: 0.99.7
Date: 2016-12-14
Author: Celia Greenwood <[email protected]>,Stepan Grinek
<[email protected]>, Kathleen Klein <[email protected]>
<[email protected]>, Maxime Turgeon <[email protected]>,
Kathleen Klein <[email protected]>
Maintainer: Kathleen Klein <[email protected]>
Description: Provides a function to normalize Illumina Infinium Human
Methylation 450 BeadChip (Illumina 450K), correcting for tissue and/or cell
Expand Down
105 changes: 58 additions & 47 deletions R/SampleSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
#' We then define then the 6 (2*3) labels: AIGrn BIGrn AIRed BIRed AII BII
#'
#'
#' @slot type character: is 'minfi' or 'GenomeStudio'
#' @slot type Character: is 'minfi' or 'GenomeStudio'
#' @slot sampleNames character vector:
#' contain the list of sample names in order used
#' @slot sampleSize numeric: the number of samples
#' @slot nPos numeric: the number of positions in the ILLUMINA chip
#' @slot annotation IlluminaMethylationAnnotation: the annotation object from
#' @slot annotation character: the annotation object from
#' minfi package
#' @slot cell_type factor: vector of the cell type for each sample as factors
#' @slot qntllist list: vector of ordered quantiles
#' @slot qntllist numeric: vector of ordered quantiles
#' @slot quantiles list: list of 6 quantiles tables for the 6 signal types
#' @slot ctl.covmat matrix: covariance matrix for the model fit
#' @slot signal list: list of the values for all 6 probe types.
#' @slot names list: list of probes for each type
#' @slot predmat list: list of the normalized values for all 6 probe types.
#'
#' @return a S4 object of class SampleSet
#' @export
Expand Down Expand Up @@ -60,12 +61,13 @@ setClass("SampleSet", representation(type = "character",

#' @title Creates an object of class SampleSet from a RGChannelSet {minfi}
#'
#' @description Creates a object of class SampleSet from the raw unprocessed data in RGChannelSet
#' @description Creates a object of class SampleSet from the raw unprocessed
#' data in RGChannelSet
#'
#' @param myRGChannelSet : RGChannelSet, from minfi package, should contain a
#' cell_type vector in pData
#'
#' @return a class 'SampleSet' object
#' @return An object of class 'SampleSet'
#' @export
#'
#' @examples require(minfiData)
Expand Down Expand Up @@ -195,13 +197,13 @@ fromRGChannelSet <- function(myRGChannelSet){
################################################################################
#' Creates a S4 object of class 'SampleSet' from GenomeStudio files
#'
#' @param controlProbeFile file of control probe data exported from GenomeStudio
#' @param signalFile file exported from GenomeStudio with the exact same samples
#' as control probe File
#' @param cell_type this vector should have names matching all the samples in
#' the files from genome studios, and at least 2 different cell types.
#' @param controlProbeFile The control probe file exported from GenomeStudio
#' @param signalFile The signals exported from GenomeStudio samples must be in
#' same order as the control probe File
#' @param cell_type A vector of cell types, names must match control probes and
#' signal files.
#'
#' @return a SampleSet object
#' @return An object of class 'SampleSet'.
#' @export
#'
fromGenStudFiles <- function(controlProbeFile,signalFile,cell_type){
Expand Down Expand Up @@ -307,7 +309,7 @@ fromGenStudFiles <- function(controlProbeFile,signalFile,cell_type){
#' Show Object SampleSet
#'
#' @description Display informations about the SampleSet object
#' @param x an object of class SampleSet
#' @param object an object of class SampleSet
#' @param ... optional arguments passed to or from other methods.
#'
#' @export
Expand Down Expand Up @@ -377,11 +379,11 @@ setMethod("getPositionNames",
)


#' Return a list
#' Build GRange object of methylation probes
#'
#' @param object object of class SampleSet
#' @param object Object of class SampleSet.
#'
#' @return a GRange object of all the methylated positions
#' @return A GRange object of the positions of each cpg.
#' @export
#'
#' @examples require(minfiData)
Expand All @@ -392,7 +394,7 @@ setMethod("getPositionNames",
setGeneric(name="getGRanges",
def=function(object) standardGeneric("getGRanges")
)

#' @describeIn getGRanges Build GRange object of methylation probes
setMethod("getGRanges",
signature = "SampleSet",
definition = function(object){
Expand All @@ -408,8 +410,7 @@ setMethod("getGRanges",


################################################################################
#' Computes the beta value from the raw signal at each position for each
#' sample
#' Computes Beta value from raw signals
#'
#' @param object object of class SampleSet
#' @param offset default is 100 as Illumina standard
Expand All @@ -426,7 +427,7 @@ setMethod("getGRanges",
setGeneric(name="getRawBeta",
def=function(object, offset=100) standardGeneric("getRawBeta")
)

#' @describeIn getRawBeta Computes Beta value from raw signals
setMethod("getRawBeta",
signature = "SampleSet",
definition = function(object,offset){
Expand All @@ -440,8 +441,7 @@ setMethod("getRawBeta",
)

################################################################################
#' Computes the beta value after normalization at each position for each
#' sample
#' Computes Beta values from normalized signals
#'
#' @param object of type SampleSet
#' @param offset default is 100 as Illumina standard
Expand All @@ -458,7 +458,7 @@ setMethod("getRawBeta",
setGeneric(name="getNormBeta",
def=function(object, offset=100) standardGeneric("getNormBeta")
)

#' @describeIn getNormBeta Computes Beta values from normalized signals
setMethod("getNormBeta",
signature = "SampleSet",
definition = function(object,offset){
Expand All @@ -475,14 +475,12 @@ setMethod("getNormBeta",
)

################################################################################
#' Computes the M value after normalization at each position for each
#' sample
#' Computes M values,log2(Meth/Unmeth), from normalized signals
#'
#' @param object of type SampleSet
#' @param offset default is 100 as Illumina standard
#' @param object An object of class SampleSet
#' @param offset Default is 100 as Illumina standard
#'
#' @return a matrix containing M values, log2(Meth/Unmeth), after normalization at each position
#' for each samples.
#' @return a matrix containing M values, log2(Meth/Unmeth), after normalization
#' @export
#'
#' @examples require(minfiData)
Expand All @@ -493,7 +491,8 @@ setMethod("getNormBeta",
setGeneric(name="getNormM",
def=function(object) standardGeneric("getNormM")
)

#' @describeIn getNormM Computes M values, log2(Meth/Unmeth),
#' from normalized signals
setMethod("getNormM",
signature = "SampleSet",
definition = function(object){
Expand All @@ -508,11 +507,12 @@ setMethod("getNormM",
)

################################################################################
#' Computes the M value after normalization for each SNP.
#' Computes M values after normalization of SNP data.
#'
#' @param object of class SampleSet
#'
#' @return a matrix containing M values, log2(Meth/Unmeth), after normalization for each SNP
#' @return a matrix containing M values, log2(Meth/Unmeth), after normalization
#' for SNP data
#'
#' @export
#'
Expand All @@ -524,7 +524,8 @@ setMethod("getNormM",
setGeneric(name="getSnpM",
def=function(object) standardGeneric("getSnpM")
)

#' @describeIn getSnpM Computes M values, log2(Meth/Unmeth), for normalized
#' SNP data
setMethod("getSnpM",
signature = "SampleSet",
definition = function(object){
Expand All @@ -539,15 +540,20 @@ setMethod("getSnpM",
)

################################################################################
#' This is the main normalization function which applies to autosomes and the X chromosome.
#' The funtooNorm normalization function
#'
#' \code{funtooNorm}
#'
#' This is a generic function which applies to autosomes and the X chromosome.
#' Chromosome Y requires separate analysis as there are few probes on Y.
#' We use a straightforward quantile normalization applied to males only.
#'
#' @param object of class SampleSet
#' @param type.fits can be "PCR" or "PLS" (default "PCR")
#' @param ncmp number of components used in the analysis (default 4)
#' @param force when set to TRUE forces the normalization procedure to re-compute
#' @param sex boolean vector: if NULL Beta values from ChrY are used for classification.
#' @param object Object of class SampleSet
#' @param type.fits Choice between "PCR" or "PLS" (default="PCR")
#' @param ncmp Number of components included in the analysis (default=4)
#' @param force When set to TRUE forces the normalization procedure to re-compute
#' @param sex Boolean vector if male. if NULL Beta values from ChrY are used for
#' classification.
#'
#' @return a S4 object of class SampleSet containing the normalized signal
#' @export
Expand All @@ -558,9 +564,10 @@ setMethod("getSnpM",
#' mySampleSet=funtooNorm(mySampleSet)
#'
setGeneric(name="funtooNorm",
def=function(object, type.fits="PCR",ncmp=4,force=FALSE,sex=NULL) standardGeneric("funtooNorm")
def=function(object, type.fits="PCR",ncmp=4,force=FALSE,sex=NULL)
standardGeneric("funtooNorm")
)

#' @describeIn funtooNorm The funtooNorm normalization function
setMethod("funtooNorm",
signature = "SampleSet",
definition = function(object,type.fits,ncmp,force,sex)
Expand All @@ -570,9 +577,9 @@ setMethod("funtooNorm",
###### this part deal with chrY
if(is.null(sex)){
mens=matrixStats::colMedians(calcBeta(object@signal$AchrY,
object@signal$BchrY))<0.6
message("we found ",sum(mens)," men and ",
sum(!mens)," women in your data set base on Y probes only")
object@signal$BchrY))<0.6
message("we found ",sum(mens)," men and ",sum(!mens),
" women in your data set base on Y probes only")
}else{
mens=sex
message("There is ",sum(mens)," men and ",
Expand Down Expand Up @@ -607,8 +614,9 @@ setMethod("funtooNorm",


################################################################################
#' Plot a series of graphs for each signal type, illustrating the effects
#' of the number of components included
#' @title plot of Validation Graph for determing number of components
#' @description Plots a series of graphs for each signal type, to determine
#' the number of components to include in the normalization procedure.
#'
#' @param object of class SampleSet
#' @param type.fits can be "PCR" or "PLS" (default "PCR")
Expand All @@ -623,9 +631,12 @@ setMethod("funtooNorm",
#' plotValidationGraph(mySampleSet)
#'
setGeneric(name="plotValidationGraph",
def=function(object, type.fits="PCR",file=NULL) standardGeneric("plotValidationGraph")
def=function(object, type.fits="PCR",file=NULL)
standardGeneric("plotValidationGraph")
)

#' @describeIn plotValidationGraph Plots a series of graphs for each
#' signal type, to determine the number of components to include
#' in the normalization procedure.
setMethod("plotValidationGraph",
signature = "SampleSet",
definition = function(object,type.fits,file){
Expand Down
8 changes: 5 additions & 3 deletions man/SampleSet-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/fromGenStudFiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/fromRGChannelSet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/funtooNorm-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Type: \tab Package\cr
License: \tab GPL-3\cr
}
}
\author{Celia Greenwood, Raphael Poujol, Stepan Grinek, Kathleen Oros Klein}
\author{Celia Greenwood, Stepan Grinek, Raphael Poujol, Maxime Turgeon,
Kathleen Oros Klein}

%\references{
%Literature or other references for background information
Expand Down
Loading

0 comments on commit e00c3ac

Please sign in to comment.