R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("SAGx-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('SAGx') Loading required package: multtest Loading required package: survival Loading required package: splines > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "Fstat" > > ### * Fstat > > flush(stderr()); flush(stdout()) > > ### Name: Fstat > ### Title: Calculation of F statistic by gene given a linear model > ### Aliases: Fstat > ### Keywords: models > > ### ** Examples > > ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". > ## Page 9: Plant Weight Data. > ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) > trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) > group <- gl(2,10,20, labels=c("Ctl","Trt")) > weight <- c(ctl, trt) > anova(lm.D9 <- lm(weight ~ group)) Analysis of Variance Table Response: weight Df Sum Sq Mean Sq F value Pr(>F) group 1 0.6882 0.6882 1.4191 0.249 Residuals 18 8.7293 0.4850 > # Analysis of Variance Table > > # Response: weight > # Df Sum Sq Mean Sq F value Pr(>F) > #group 1 0.6882 0.6882 1.4191 0.249 > #Residuals 18 8.7292 0.4850 > > Fstat(indata = rbind(weight,weight),formula1=~group) # Fstat will need at least two genes to work with # $Fstat weight weight [1,] 1.419101 1.419101 $fnum [1] 18 $fdenom [1] 1 $design1 (Intercept) groupTrt 1 1 0 2 1 0 3 1 0 4 1 0 5 1 0 6 1 0 7 1 0 8 1 0 9 1 0 10 1 0 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 1 attr(,"assign") [1] 0 1 attr(,"contrasts") attr(,"contrasts")$group [1] "contr.treatment" $design0 (Intercept) 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 attr(,"assign") [1] 0 $SS1 weight weight [1,] 8.72925 8.72925 $SS0 weight weight [1,] 0.688205 0.688205 $pvalue NULL > #$Fstat > # weight weight > #1.419101 1.419101 > > #$fnum > #[1] 18 > > #$fdenom > #[1] 1 > > #$design1 > # (Intercept) groupTrt > #1 1 0 > #2 1 0 > #3 1 0 > #4 1 0 > #5 1 0 > #6 1 0 > #7 1 0 > #8 1 0 > #9 1 0 > #10 1 0 > #11 1 1 > #12 1 1 > #13 1 1 > #14 1 1 > #15 1 1 > #16 1 1 > #17 1 1 > #18 1 1 > #19 1 1 > #20 1 1 > #attr(,"assign") > #[1] 0 1 > > # $design0 > # NULL > > # $SS1 > # weight weight > #8.72925 8.72925 > > #$SS0 > # weight weight > #0.688205 0.688205 > > > > > cleanEx(); ..nameEx <- "fetchSignal" > > ### * fetchSignal > > flush(stderr()); flush(stdout()) > > ### Name: fetchSignal > ### Title: Fetch data from the GATC database > ### Aliases: fetchSignal > ### Keywords: database > > ### ** Examples > > ## Not run: > ##D # Do not run example 1. Fetch Probeset, Signal, ABS_CALL and CHIP for one sample. > ##D library(RODBC) > ##D (channel<-odbcConnect("DSN",uid="USERID",pwd="PASSWORD")) > ##D ali.data <-fetchSignal(experiment="AZ33 ALI", channel, chip="hg_u95a") > ##D colnames(ali.data) > ##D #[1] "FILENAME" "PROBESET" "SIGNAL" "ABS_CALL" "CHIP" > ##D > ##D # Do not run example 2 > ##D t1 <- paste("select q1.name as name from experiment q1, physical_chip q2, chip_design q3") > ##D t2 <- paste("where q1.physical_chip_id=q2.id and q3.id=q2.design_id and ") > ##D t3 <- paste("upper(q1.name) like ' > ##D Ids <- sqlQuery(channel,paste(t1,t2,t3) ) > ##D # fetch Signal from GATC corresponding to the U95A chip for all samples in experiment. # > ##D tmp <- apply(Ids,1,toupper) > ##D probes <- data.frame(fetchSignal(experiment=tmp[1],channel, chip="hg_u95a")[,"PROBESET"]) > ##D test <- matrix(nrow=nrow(as.data.frame(probes)),ncol=nrow(Ids)) > ##D for(i in 1:nrow(as.data.frame(tmp))){ > ##D test[,i] <- fetchSignal(experiment=tmp[i],channel, chip="hg_u95a")[,"SIGNAL"] > ##D } > ##D codes <- data.frame(apply(Ids,1,code<-function(x) substr(x,1,5))) > ##D colnames(test) <- as.character(t(codes)) > ##D test <- test[,order(colnames(test))] > ## End(Not run) > > > > cleanEx(); ..nameEx <- "firstpass" > > ### * firstpass > > flush(stderr()); flush(stdout()) > > ### Name: firstpass > ### Title: First pass description of GeneChip data > ### Aliases: firstpass > ### Keywords: nonparametric > > ### ** Examples > > ## Not run: > ##D # not run > ##D g <- c(rep(1,4),rep(2,4)); labs <- c("Mean Diet","Mean Control"); probes <- paste("Probe",1:1000) > ##D firstpass(data = utmat[1:2,], probes = probes[1:2], g, log = FALSE, labels = labs) > ##D # Probesets Mean Diet Mean Control LCL.1 LCL.2 UCL.1 UCL.2 pval > ##D #1 Probe 1 -12.3444460036497 -11.7495704973055 -12.9047961446666 -12.2832657957485 -11.7840958626327 -11.2158751988625 0.0433081428107922 > ##D #2 Probe 2 -7.99773926405627 -8.02799133391929 -8.47704512876227 -8.19487551919835 -7.51843339935028 -7.86110714864023 0.772829992684449 > ##D # Difference Subject 1 Subject 2 Subject 3 Subject 4 Subject 5 Subject 6 Subject 7 Subject 8 > ##D #1 -0.594875506344176 -12.345150 -11.805071 -12.776232 -12.451332 -11.595748 -12.320430 -11.482349 -11.599755 > ##D #2 0.0302520698630131 -7.660097 -8.157944 -8.404433 -7.768484 -7.979951 -8.017327 -8.197361 -7.917326 > ## End(Not run) > > > > cleanEx(); ..nameEx <- "gap" > > ### * gap > > flush(stderr()); flush(stdout()) > > ### Name: gap > ### Title: GAP statistic clustering figure of merit > ### Aliases: gap > ### Keywords: multivariate > > ### ** Examples > > library(MASS) > data(swiss) > cl <- myclus(data = swiss, k = 3) > gap(swiss,cl$cluster) [1] 0.8540805 > > > > cleanEx(); ..nameEx <- "list.experiments" > > ### * list.experiments > > flush(stderr()); flush(stdout()) > > ### Name: list.experiments > ### Title: Display all experiment names and id's > ### Aliases: list.experiments > ### Keywords: database > > ### ** Examples > > # Not run > ## Not run: > ##D library(Rodbc) > ##D channel <- odbcConnect(DBN, USRID, PWD) > ##D ut <- list.experiments(channel, chip = "hu6800") > ##D colnames(ut) > ##D #[1] "EXPERIMENT" > ## End(Not run) > > > > cleanEx(); ..nameEx <- "myclus" > > ### * myclus > > flush(stderr()); flush(stdout()) > > ### Name: myclus > ### Title: A clustering function > ### Aliases: myclus > ### Keywords: multivariate > > ### ** Examples > > library(MASS) > data(swiss) > cl <- myclus(data = swiss, k = 3) > gap(swiss,cl$cluster) [1] 0.8540805 > > > > cleanEx(); ..nameEx <- "outlier" > > ### * outlier > > flush(stderr()); flush(stdout()) > > ### Name: outlier > ### Title: Identify outliers in the multivariate distribution > ### Aliases: outlier > ### Keywords: multivariate > > ### ** Examples > > ## Not run: > ##D # not run > ##D ut<-outlier(M) > ##D #[1] "The number of significant dimensions is 19" > ##D colnames(ut) > ##D #[1] "Hotelling" "DMODX" > ## End(Not run) > > > > cleanEx(); ..nameEx <- "pava" > > ### * pava > > flush(stderr()); flush(stdout()) > > ### Name: pava > ### Title: Pooling of Adjacent Violators > ### Aliases: pava > ### Keywords: regression > > ### ** Examples > > pava(c(1,2,4,3,5)) [1] 1.0 2.0 3.5 3.5 5.0 > # [1] 1.0 2.0 3.5 3.5 5.0 > > > > cleanEx(); ..nameEx <- "permutation.t" > > ### * permutation.t > > flush(stderr()); flush(stdout()) > > ### Name: permutation.t > ### Title: bootstrap p-value for matrix with variables in rows and with > ### arbitrary missing structure. > ### Aliases: permutation.t > ### Keywords: nonparametric > > ### ** Examples > > ## Not run: > ##D p.vals <- permutation.t(data = clinical.data,grp = grp, B = 10000, na.rate = 0.1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "rank.trend" > > ### * rank.trend > > flush(stderr()); flush(stdout()) > > ### Name: rank.trend > ### Title: Trens analysis based on ranks > ### Aliases: rank.trend > ### Keywords: robust > > ### ** Examples > > # not run > D <- c(123, 334, 578, 762, 755, 890) > rank.trend(data = t(as.matrix(D)), har = TRUE) Trend score Hardy score p-value for no trend [1,] 2 90 0.01750284 > # Trend score Hardy score p-value for no trend > # [1,] 2 90 0.01750284 > > > > > cleanEx(); ..nameEx <- "samrocnboot" > > ### * samrocnboot > > flush(stderr()); flush(stdout()) > > ### Name: samrocNboot > ### Title: Calculate ROC curve based SAM statistic > ### Aliases: samrocNboot > ### Keywords: htest > > ### ** Examples > > library(multtest) > #Loading required package: genefilter > #Loading required package: survival > #Loading required package: splines > #Loading required package: reposTools > data(golub) > # This makes the expression data from Golub et al available > # in the matrix golub, and the sample labels in the vector golub.cl > > samroc.res <- samrocNboot(data = golub, formula = ~as.factor(golub.cl)) Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf > #Warning message: > #package 'modreg' has been merged into 'stats' > samroc.res$p0 [1] 0.4288874 > #[1] 0.4776763 > samroc.res$s0 10% 0.1147915 > # 0 > hist(samroc.res$pvalue) > # many genes appear changed > > > > ### *