Browse code

adding a bunch of examples for functions

From: nosson <jpaulson@umiacs.umd.edu>

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/metagenomeSeq@122454 bc3139a8-67e5-0310-9ffc-ced21a209358

Hector Corrada Bravo authored on 15/10/2016 08:30:34
Showing6 changed files

... ...
@@ -12,7 +12,10 @@
12 12
 #' @seealso \code{\link{cumNorm}} \code{\link{quantile}}
13 13
 #' @examples
14 14
 #' 
15
-#' # see vignette
15
+#' data(lungData)
16
+#' dataDirectory <- system.file("extdata", package="metagenomeSeq")
17
+#' exportStats(lungData[,1:5],file=file.path(dataDirectory,"tmp.tsv"))
18
+#' head(read.csv(file=file.path(dataDirectory,"tmp.tsv"),sep="\t"))
16 19
 #' 
17 20
 exportStats <-function(obj,p= cumNormStat(obj),file="~/Desktop/res.stats.tsv"){
18 21
 	xx=MRcounts(obj)
... ...
@@ -15,6 +15,18 @@
15 15
 #'
16 16
 #' @return Call made, fit object from lmFit, t-statistics and p-values for each feature.
17 17
 #' @export
18
+#' @examples
19
+#' 
20
+#' # This is a simple demonstration
21
+#' data(lungData)
22
+#' k = grep("Extraction.Control",pData(lungData)$SampleType)
23
+#' lungTrim = lungData[,-k]
24
+#' k = which(rowSums(MRcounts(lungTrim)>0)<30)
25
+#' lungTrim = cumNorm(lungTrim)
26
+#' lungTrim = lungTrim[-k,]
27
+#' smokingStatus = pData(lungTrim)$SmokingStatus
28
+#' mod = model.matrix(~smokingStatus)
29
+#' fit = fitLogNormal(obj = lungTrim,mod=mod,B=1)
18 30
 #' 
19 31
 fitLogNormal <- function(obj,mod,useCSSoffset=TRUE,B=1000,coef=2,sl=1000){
20 32
     if(class(obj)=="MRexperiment"){
... ...
@@ -8,9 +8,9 @@
8 8
 #' @examples
9 9
 #' 
10 10
 #' #library(biomformat)
11
-#' #rich_dense_file = system.file("extdata", "rich_dense_otu_table.biom", package = "biomformat")
12
-#' #x = loadBiom(rich_dense_file)
13
-#' #x
11
+#' rich_dense_file = system.file("extdata", "rich_dense_otu_table.biom", package = "biomformat")
12
+#' x = loadBiom(rich_dense_file)
13
+#' x
14 14
 loadBiom <- function(file){
15 15
 	requireNamespace("biomformat")
16 16
 	x = biomformat::read_biom(file);
... ...
@@ -12,7 +12,8 @@
12 12
 #' @seealso \code{\link{loadMeta}}
13 13
 #' @examples
14 14
 #' 
15
-#' # see vignette
15
+#' dataDirectory <- system.file("extdata", package="metagenomeSeq")
16
+#' clin = loadPhenoData(file.path(dataDirectory,"CHK_clinical.csv"),tran=TRUE)
16 17
 #' 
17 18
 loadPhenoData <-function(file,tran=TRUE,sep="\t")
18 19
 {
... ...
@@ -9,6 +9,11 @@
9 9
 #' \item     pheno  : phenotype table
10 10
 #' \item     feat  : feature table
11 11
 #' }
12
+#' 
13
+#' @examples
14
+#'
15
+#' data(mouseData)
16
+#' head(metagenomeSeq:::extractMR(mouseData))
12 17
 #'
13 18
 extractMR<-function(obj){
14 19
 	mat = MRcounts(obj)
... ...
@@ -95,4 +100,4 @@ mergeMRexperiments<-function(x,y){
95 100
 					phenoData = AnnotatedDataFrame(pheno),
96 101
 					featureData=AnnotatedDataFrame(feat))
97 102
 	return(obj)
98
-}
99 103
\ No newline at end of file
104
+}
... ...
@@ -54,7 +54,8 @@ uniqueFeatures<-function(obj,cl,nsamples=0,nreads=0){
54 54
 #' @param norm is the data normalized?
55 55
 #' @param log is the data logged?
56 56
 #' @return vector of x,y labels
57
-#' 
57
+#' @examples
58
+#' metagenomeSeq::makeLabels(norm=TRUE,log=TRUE) 
58 59
 makeLabels<-function(x="samples",y="abundance",norm,log){
59 60
 	yl = xl = ""
60 61
 	if(log == TRUE){
... ...
@@ -66,4 +67,4 @@ makeLabels<-function(x="samples",y="abundance",norm,log){
66 67
 	yl = paste(yl,y)
67 68
 	xl = paste(xl,x)
68 69
 	return(c(xl,yl))
69
-}
70 70
\ No newline at end of file
71
+}