Browse code

passing BioC checks - removed exported function without working examples

sherman5 authored on 29/01/2018 16:21:13
Showing 24 changed files

... ...
@@ -4,28 +4,16 @@ export(CoGAPS)
4 4
 export(CoGapsFromCheckpoint)
5 5
 export(GWCoGAPS)
6 6
 export(binaryA)
7
-export(calcCoGAPSStat)
8
-export(calcGeneGSStat)
9 7
 export(calcZ)
10
-export(computeGeneGSProb)
11 8
 export(createGWCoGAPSSets)
12 9
 export(displayBuildReport)
13 10
 export(gapsMapRun)
14 11
 export(gapsRun)
15
-export(generateSeeds)
16
-export(patternMarkers)
17
-export(patternMatch4Parallel)
18
-export(patternMatcher)
19 12
 export(plotAtoms)
20 13
 export(plotDiag)
21 14
 export(plotGAPS)
22 15
 export(plotP)
23
-export(plotPatternMarkers)
24
-export(plotSmoothPatterns)
25
-export(postFixed4Parallel)
26
-export(reOrderBySet)
27 16
 export(reconstructGene)
28
-export(reorderByPatternMatch)
29 17
 export(residuals)
30 18
 import(doParallel)
31 19
 import(foreach)
... ...
@@ -118,6 +118,9 @@ displayBuildReport <- function()
118 118
 #' @return list with A and P matrix estimates
119 119
 #' @importFrom methods new
120 120
 #' @inheritParams CoGAPS
121
+#' @examples
122
+#' data(SimpSim)
123
+#' result <- gapsRun(SimpSim.D, SimpSim.S, nFactor=3)
121 124
 #' @export
122 125
 gapsRun <- function(D, S, ABins=data.frame(), PBins=data.frame(), nFactor=7,
123 126
 simulation_id="simulation", nEquil=1000, nSample=1000, nOutR=1000,
... ...
@@ -142,6 +145,11 @@ alphaP=0.01, nMaxP=100000, max_gibbmass_paraP=100.0, seed=-1, messages=TRUE)
142 145
 #' @return list with A and P matrix estimates
143 146
 #' @importFrom methods new
144 147
 #' @inheritParams gapsRun
148
+#' @examples
149
+#' data(SimpSim)
150
+#' nC <- ncol(SimpSim.D)
151
+#' patterns <- matrix(runif(nC, 0, 1), nrow=1, ncol=nC)
152
+#' result <- gapsMapRun(SimpSim.D, SimpSim.S, FP=patterns, nFactor=3)
145 153
 #' @export
146 154
 gapsMapRun <- function(D, S, FP, ABins=data.frame(), PBins=data.frame(),
147 155
 nFactor=5, simulation_id="simulation", nEquil=1000, nSample=1000, nOutR=1000,
... ...
@@ -163,6 +171,7 @@ v2CoGAPS <- function(result, ...)
163 171
 {
164 172
     if (!is.null(list(...)$GStoGenes))
165 173
     {
174
+        #warning('GStoGenes is deprecated with v3.0, see CoGAPS documentation')
166 175
         if (is.null(list(...)$plot) | list(...)$plot)
167 176
         {
168 177
             plotGAPS(result$Amean, result$Pmean)
... ...
@@ -8,13 +8,6 @@
8 8
 #' @param GStoGenes data.frame or list with gene sets
9 9
 #' @param numPerm number of permutations for null
10 10
 #' @return gene set statistics for each column of A
11
-#' @examples
12
-#' # Load the sample data from CoGAPS
13
-#' data(SimpSim)
14
-#' # Run calcCoGAPSStat with the correct arguments from 'results'
15
-#' calcCoGAPSStat(SimpSim.result$Amean, SimpSim.result$Asd,
16
-#' GStoGenes=GSets, numPerm=500)
17
-#' @export
18 11
 calcCoGAPSStat <- function (Amean, Asd, GStoGenes, numPerm=500)
19 12
 {
20 13
     # test for std dev of zero, possible mostly in simple simulations
... ...
@@ -24,29 +17,30 @@ calcCoGAPSStat <- function (Amean, Asd, GStoGenes, numPerm=500)
24 17
     # calculate Z scores
25 18
     zMatrix <- calcZ(Amean,Asd)
26 19
 
20
+    # check input arguments
21
+    if (!is(GStoGenes, "data.frame") && !is(GStoGenes, "list") && !is(GStoGenes,"GSA.genesets"))
22
+    {
23
+        stop("GStoGenes must be a data.frame,GSA.genesets, or list with format specified in the users manual.")
24
+    }
25
+
27 26
     if (is(GStoGenes, "GSA.genesets"))
28 27
     {
29 28
         names(GStoGenes$genesets) <- GStoGenes$geneset.names
30 29
         GStoGenes <- GStoGenes$genesets
31 30
     }
32
-    else if (is(GStoGenes, "list"))
31
+
32
+    if (is(GStoGenes, "list"))
33 33
     {
34 34
         GStoGenesList <- GStoGenes
35 35
     }
36
-    else if (is(GStoGenes, "data.frame"))
36
+    else
37 37
     {
38 38
         GStoGenesList <- list()
39 39
         for (i in 1:dim(GStoGenes)[2])
40 40
         {
41
-            GStoGenesList[[as.character(colnames(GStoGenes)[i])]] <- 
42
-                as.character(unique(GStoGenes[,i]))
41
+            GStoGenesList[[as.character(colnames(GStoGenes)[i])]] <- as.character(unique(GStoGenes[,i]))
43 42
         }
44 43
     }
45
-    else
46
-    {
47
-        stop(paste("GStoGenes must be a data.frame, GSA.genesets, or list with",
48
-            "format specified in the users manual."))
49
-    }
50 44
 
51 45
     # get dimensions
52 46
     numGS   <- length(names(GStoGenesList))
... ...
@@ -10,13 +10,6 @@
10 10
 #' @param Pw weight on genes
11 11
 #' @param nullGenes logical indicating gene adjustment
12 12
 #' @return gene similiarity statistic
13
-#' @examples
14
-#' # Load the sample data from CoGAPS
15
-#' data('SimpSim')
16
-#' # Run calcGeneGSStat
17
-#' calcGeneGSStat(SimpSim.result$Amean, SimpSim.result$Asd, 
18
-#' GSGenes=GSets[[1]], numPerm=500, nullGenes=TRUE)
19
-#' @export
20 13
 calcGeneGSStat  <- function(Amean, Asd, GSGenes, numPerm, Pw=rep(1,ncol(Amean)),
21 14
 nullGenes=FALSE)
22 15
 {
... ...
@@ -46,10 +39,10 @@ nullGenes=FALSE)
46 39
     outStats <- outStats / apply(ZD,1,sum)
47 40
     outStats[which(apply(ZD,1,sum) < 1e-6)] <- 0
48 41
 
49
-    #if (sum(gsStat) < 1e-6)
50
-    #{
51
-    #    return(0)
52
-    #}
42
+    if (sum(gsStat) < 1e-6)
43
+    {
44
+        return(0)
45
+    }
53 46
     return(outStats)
54 47
 }
55 48
 
... ...
@@ -69,12 +62,6 @@ nullGenes=FALSE)
69 62
 #' @return A vector of length GSGenes containing the p-values of set membership
70 63
 #' for each gene containined in the set specified in GSGenes.
71 64
 #' @examples
72
-#' # Load the sample data from CoGAPS
73
-#' data('SimpSim')
74
-#' # Run calcGeneGSStat with the correct arguments from 'results'
75
-#' calcGeneGSStat(SimpSim.result$Amean, SimpSim.result$Asd, 
76
-#' GSGenes=GSets[[1]], numPerm=500)
77
-#' @export
78 65
 computeGeneGSProb <- function(Amean, Asd, GSGenes, Pw=rep(1,ncol(Amean)),
79 66
 numPerm=500, PwNull=FALSE)
80 67
 {
... ...
@@ -4,9 +4,6 @@
4 4
 #' @param seed positive values are kept, negative values will be overwritten
5 5
 #' by a seed generated from the current time
6 6
 #' @return vector of randomly generated seeds
7
-#' @examples
8
-#' seeds <- generateSeeds(chains=2, seed=-1)
9
-#' @export
10 7
 generateSeeds <- function(chains=2, seed=-1)
11 8
 {
12 9
     if (chains < 2 || (as.integer(chains) != chains))
... ...
@@ -8,13 +8,6 @@
8 8
 #' @param full logical indicating whether to return the ranks of each gene for each pattern
9 9
 #' @return By default a non-overlapping list of genes associated with each \code{lp}. If \code{full=TRUE} a data.frame of
10 10
 #' genes rankings with a column for each \code{lp} will also be returned.
11
-#' @examples
12
-#' # Load the sample data from CoGAPS
13
-#' data(SimpSim)
14
-#' # Run patternMarkers with the correct arguments from 'results'
15
-#' patternMarkers(Amatrix=results$Amean,scaledPmatrix=FALSE,
16
-#' Pmatrix=results$Pmean,threshold="all",full=TRUE)
17
-#' @export
18 11
 patternMarkers <- function(Amatrix=NA, scaledPmatrix=FALSE, Pmatrix=NA,
19 12
 threshold="all", lp=NA, full=FALSE)
20 13
 {
... ...
@@ -10,7 +10,6 @@
10 10
 #' @param ... additional parameters for \code{agnes}
11 11
 #' @return a matrix of concensus patterns by samples. If \code{bySet=TRUE} then a list of the set contributions to each
12 12
 #' concensus pattern is also returned.
13
-#' @export
14 13
 #' @seealso \code{\link{agnes}}
15 14
 patternMatch4Parallel <- function(Ptot, nSets, cnt, minNS, 
16 15
 cluster.method="complete", ignore.NA=FALSE, bySet=FALSE, ...)
... ...
@@ -5,7 +5,6 @@
5 5
 #' @param order optional vector indicating order of samples for plotting. Default is NULL.
6 6
 #' @param sample.color optional vector of colors of same length as colnames. Default is NULL.
7 7
 #' @return either an index of selected sets' contributions or the editted \code{PBySet} object
8
-#' @export
9 8
 patternMatcher<-function(PBySet=NULL,out=NULL,order=NULL, sample.color=NULL)
10 9
 {
11 10
     runApp(list(
... ...
@@ -11,8 +11,8 @@
11 11
 #' # Load the sample data from CoGAPS
12 12
 #' data(SimpSim)
13 13
 #' # Run plotAtoms
14
-#' plotAtoms(results,type="sampA")
15
-#'@export
14
+#' plotAtoms(SimpSim.result, type="sampA")
15
+#' @export
16 16
 plotAtoms<-function(gapsRes, type='sampA')
17 17
 {
18 18
     if (type == 'sampA')       atoms <- gapsRes$atomsASamp
... ...
@@ -12,15 +12,6 @@
12 12
 #' @param ... additional graphical parameters to be passed to \code{heatmap.2}
13 13
 #' @return heatmap of the \code{data} values for the \code{patternMarkers}
14 14
 #' @seealso  \code{\link{heatmap.2}}
15
-#' @examples
16
-#' # Load the sample data from CoGAPS
17
-#' data(SimpSim)
18
-#' # Run patternMarkers and save the outputs
19
-#' PM <- patternMarkers(Amatrix=results$Amean,scaledPmatrix=FALSE,
20
-#' Pmatrix=results$Pmean,threshold="all",full=TRUE)
21
-#' # Run plotPatternMarkers with the correct argument from 'PM'
22
-#' plotPatternMarkers(data=SimpSim.D,patternMarkers=PM$PatternMarkers)
23
-#' @export
24 15
 plotPatternMarkers <- function(data=NA, patternMarkers=NA, patternPalette=NA,
25 16
 sampleNames=NA, samplePalette=NULL, colDenogram=TRUE, heatmapCol="bluered",
26 17
 scale='row', ...)
... ...
@@ -17,7 +17,6 @@
17 17
 #' `main') and graphical parameters (see `par') which are passed to
18 18
 #' `plot.window()', `title()' and `axis'.
19 19
 #' @return plot
20
-#' @export
21 20
 plotSmoothPatterns <- function(P, x=NULL, breaks=NULL, breakStyle=TRUE,
22 21
 orderP=!all(is.null(x)), plotPTS=FALSE, pointCol='black', lineCol='grey',
23 22
 add=FALSE, ...)
... ...
@@ -5,7 +5,6 @@
5 5
 #' for gapsMapRun
6 6
 #' @return list of two data.frames containing the A matrix estimates or their
7 7
 #' corresponding standard deviations from output of parallel CoGAPS
8
-#' @export
9 8
 postFixed4Parallel <- function(AP.fixed=NA, setPs=NA)
10 9
 {
11 10
     ASummary <- do.call(rbind,lapply(AP.fixed, function(x) x$Amean))
... ...
@@ -7,7 +7,6 @@
7 7
 #' @param nSets number of sets
8 8
 #' @return a list containing the \code{nSets} sets solution for Amean under "A",
9 9
 #' Pmean under "P", and Asd under "Asd"
10
-#' @export
11 10
 reOrderBySet<-function(AP, nFactor, nSets)
12 11
 {
13 12
     P<-do.call(rbind,lapply(AP, function(x) x$Pmean))
... ...
@@ -3,7 +3,6 @@
3 3
 #' @param P matrix to be matched
4 4
 #' @param matchTo matrix to match P to
5 5
 #' @return matched patterns
6
-#' @export
7 6
 reorderByPatternMatch <- function(P, matchTo)
8 7
 {
9 8
     # check that P and the matchTo matrix have the same dimensions
... ...
@@ -26,11 +26,4 @@ calculates the gene set statistics for each
26 26
 column of A using a Z-score from the elements of the A matrix,
27 27
 the input gene set, and permutation tests
28 28
 }
29
-\examples{
30
-# Load the sample data from CoGAPS
31
-data(SimpSim)
32
-# Run calcCoGAPSStat with the correct arguments from 'results'
33
-calcCoGAPSStat(SimpSim.result$Amean, SimpSim.result$Asd,
34
-GStoGenes=GSets, numPerm=500)
35
-}
36 29
 
... ...
@@ -31,11 +31,4 @@ calculates the probability that a gene
31 31
 listed in a gene set behaves like other genes in the set within
32 32
 the given data set
33 33
 }
34
-\examples{
35
-# Load the sample data from CoGAPS
36
-data('SimpSim')
37
-# Run calcGeneGSStat
38
-calcGeneGSStat(SimpSim.result$Amean, SimpSim.result$Asd, 
39
-GSGenes=GSets[[1]], numPerm=500, nullGenes=TRUE)
40
-}
41 34
 
... ...
@@ -34,11 +34,4 @@ membership for each candidate gene in a set specified in \code{GSGenes} by
34 34
 comparing the inferred activity of that gene to the average activity of the
35 35
 set.
36 36
 }
37
-\examples{
38
-# Load the sample data from CoGAPS
39
-data('SimpSim')
40
-# Run calcGeneGSStat with the correct arguments from 'results'
41
-calcGeneGSStat(SimpSim.result$Amean, SimpSim.result$Asd, 
42
-GSGenes=GSets[[1]], numPerm=500)
43
-}
44 37
 
... ...
@@ -71,4 +71,10 @@ list with A and P matrix estimates
71 71
 \description{
72 72
 Backwards Compatibility with v2
73 73
 }
74
+\examples{
75
+data(SimpSim)
76
+nC <- ncol(SimpSim.D)
77
+patterns <- matrix(runif(nC, 0, 1), nrow=1, ncol=nC)
78
+result <- gapsMapRun(SimpSim.D, SimpSim.S, FP=patterns, nFactor=3)
79
+}
74 80
 
... ...
@@ -64,4 +64,8 @@ list with A and P matrix estimates
64 64
 \description{
65 65
 Backwards Compatibility with v2
66 66
 }
67
+\examples{
68
+data(SimpSim)
69
+result <- gapsRun(SimpSim.D, SimpSim.S, nFactor=3)
70
+}
67 71
 
... ...
@@ -18,7 +18,4 @@ vector of randomly generated seeds
18 18
 \description{
19 19
 Generate Seeds for Multiple Concurrent Runs
20 20
 }
21
-\examples{
22
-seeds <- generateSeeds(chains=2, seed=-1)
23
-}
24 21
 
... ...
@@ -27,11 +27,4 @@ genes rankings with a column for each \code{lp} will also be returned.
27 27
 \description{
28 28
 patternMarkers
29 29
 }
30
-\examples{
31
-# Load the sample data from CoGAPS
32
-data(SimpSim)
33
-# Run patternMarkers with the correct arguments from 'results'
34
-patternMarkers(Amatrix=results$Amean,scaledPmatrix=FALSE,
35
-Pmatrix=results$Pmean,threshold="all",full=TRUE)
36
-}
37 30
 
... ...
@@ -27,6 +27,6 @@ from one of the vectors returned with atom numbers
27 27
 # Load the sample data from CoGAPS
28 28
 data(SimpSim)
29 29
 # Run plotAtoms
30
-plotAtoms(results,type="sampA")
30
+plotAtoms(SimpSim.result, type="sampA")
31 31
 }
32 32
 
... ...
@@ -34,15 +34,6 @@ heatmap of the \code{data} values for the \code{patternMarkers}
34 34
 \description{
35 35
 plotPatternMarkers
36 36
 }
37
-\examples{
38
-# Load the sample data from CoGAPS
39
-data(SimpSim)
40
-# Run patternMarkers and save the outputs
41
-PM <- patternMarkers(Amatrix=results$Amean,scaledPmatrix=FALSE,
42
-Pmatrix=results$Pmean,threshold="all",full=TRUE)
43
-# Run plotPatternMarkers with the correct argument from 'PM'
44
-plotPatternMarkers(data=SimpSim.D,patternMarkers=PM$PatternMarkers)
45
-}
46 37
 \seealso{
47 38
 \code{\link{heatmap.2}}
48 39
 }
... ...
@@ -69,10 +69,7 @@ Rcpp::NumericMatrix GibbsSampler::getNormedMatrix(char mat)
69 69
     for (unsigned r = 0; r < mPMatrix.nRow(); ++r)
70 70
     {
71 71
         normVec[r] = gaps::algo::sum(mPMatrix.getRow(r));
72
-        if (normVec[r] == 0)
73
-        {
74
-            normVec[r] = 1.0;
75
-        }
72
+        normVec[r] = (normVec[r] == 0) ? 1.f : normVec[r];
76 73
     }
77 74
 
78 75
     if (mat == 'A')