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("HighProbability-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('HighProbability') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "alternative.probable" > > ### * alternative.probable > > flush(stderr()); flush(stdout()) > > ### Name: alternative.probable > ### Title: alternative.probable and alternative.beneficial > ### Aliases: alternative.probable alternative.beneficial > ### Keywords: htest nonparametric > > ### ** Examples > > > n.variables <- 1000 # This could be the number of genes on a microarray. > n.individuals <- 5 # This could be the number of microarrays per group. > n.effects <- 100 # This is the number of alternative hypotheses that are true, e.g., number of genes differentially expressed. > x1 <- matrix(c(rnorm(n.effects * n.individuals, mean = 2, sd = 1), rnorm((n.variables - n.effects) * n.individuals, mean = 0, sd = 1)), nrow = n.variables, byrow = TRUE) # Observed data, e.g., logarithms of gene expression ratios, for group 1. > x2 <- matrix(rnorm(n.variables * n.individuals, mean = 0, sd = 1), nrow = n.variables, byrow = TRUE) # The same for group 2. > p.values <- numeric(n.variables) > for(i in 1:n.variables) p.values[i] <- t.test(x1[i, ], x2[i, ])$p.value > is.probable <- alternative.probable(p.values) # Selects which alternative hypotheses are probably true, e.g., which genes are probably differentially expressed. Using marginal.probability estimate of 0.073 > c(sum(is.probable[1:100]), sum(is.probable[101:1000])) # Numbers of true and false calls of differential expression. [1] 58 15 > is.probable.95 <- alternative.probable(p.values, min.probability = .95) # To be at least 95 Using marginal.probability estimate of 0.073 > c(sum(is.probable.95[1:100]), sum(is.probable.95[101:1000])) # Smaller numbers of true and false calls of differential expression. [1] 2 0 > is.beneficial <- alternative.beneficial(p.values, cost.to.benefit = 1) Calling alternative.probable with min.probability = 0.5 Using marginal.probability estimate of 0.073 > all.equal(is.beneficial, is.probable) [1] TRUE > > > > > ### *