<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title> document_view — bioconductor.org </title> <base href="" /> <meta name="generator" content="Plone - http://plone.org" /> <meta content="admin" name="DC.creator" /> <meta content="2005-07-01 10:24:40" name="DC.date.created" /> <meta content="2005-07-01 11:49:52" name="DC.date.modified" /> <meta content="Document" name="DC.type" /> <meta content="text/plain" name="DC.format" /> <!-- Basic crude style for Netscape4.x - This can be removed if you don't want the special NS4 look - it will still work, just be plain text instead. Column layout for Netscape4.x included --> <link rel="Stylesheet" type="text/css" href="../../../../ploneNS4.css" /> <!-- Column style sheet. --> <style type="text/css" media="screen"><!-- @import url(http://bioconductor.org/ploneColumns.css); --></style> <!-- Main style sheets for CSS2 capable browsers --> <style type="text/css" media="screen"><!-- @import url(http://bioconductor.org/plone.css); --></style> <!-- Old style sheet from Plone 1.0, remove tal:condition="nothing" if you need to use the old styles. Will be removed in Plone 2.1. --> <!-- Alternate style sheets for the bigger/smaller text switcher --> <link rel="alternate stylesheet" type="text/css" media="screen" href="../../../../ploneTextSmall.css" title="Small Text" /> <link rel="alternate stylesheet" type="text/css" media="screen" href="../../../../ploneTextLarge.css" title="Large Text" /> <!-- Style sheet used for printing --> <link rel="stylesheet" type="text/css" media="print" href="../../../../plonePrint.css" /> <!-- Style sheet used for presentations (Opera is the only browser supporting this at the moment) --> <link rel="stylesheet" type="text/css" media="projection" href="../../../../plonePresentation.css" /> <!-- Internet Explorer CSS Fixes --> <!--[if IE]> <style type="text/css" media="all">@import url(http://bioconductor.org/ploneIEFixes.css);</style> <![endif]--> <!-- Custom style sheet if available --> <style type="text/css" media="all"><!-- @import url(http://bioconductor.org/ploneCustom.css); --></style> <link rel="shortcut icon" href="../../../../favicon.ico" type="image/x-icon" /> <link rel="search" href="../../../../search_form" title="Search this site" /> <link rel="up" href="../labs.1" title="Up one level" /> <!-- Disable IE6 image toolbar --> <meta http-equiv="imagetoolbar" content="no" /> <!-- A slot where you can insert CSS in the header from a template --> <!-- min-width support for IE via Javascript, required for tableless --> <!--[if IE]> <script type="text/javascript" src="http://bioconductor.org/plone_minwidth.js"></script> <![endif]--> <!-- A slot where you can insert elements in the header from a template --> <!-- A slot where you can insert javascript in the header from a template --> <!-- Common Plone ECMAScripts --> <!-- Pull-down ECMAScript menu, only active if logged in --> <!-- old google analytics here --> <!-- Define dynamic server-side variables for javascripts in this one --> <script type="text/javascript" src="../../../../plone_javascript_variables.js"> </script> <script type="text/javascript" src="../../../../plone_javascripts.js"> </script> <!-- Old JS from Plone 1.0, remove tal:condition="nothing" if you need to use the old pop-ups. Will be removed in Plone 2.1 --> </head> <body class="section-workshops"> <div id="visual-portal-wrapper"> <div id="portal-top"> <a href="lab2.R#documentContent" class="hiddenStructure">Skip to content.</a> <h1 id="portal-logo"> <a href="../../../../index.html">bioconductor.org</a> </h1> <div id="portal-slogan"><p>Bioconductor is an open source and open development software project<br /> for the analysis and comprehension of genomic data.</p></div> <h5 class="hiddenStructure">Sections</h5> <ul id="portal-globalnav"><li id="portaltab-index_html" class="plain"><a href="../../../../index.html" accesskey="t">Home</a></li><li id="portaltab-GettingStarted" class="plain"><a href="../../../../GettingStarted" accesskey="t">Getting Started</a></li><li id="portaltab-overview" class="plain"><a href="../../../../overview" accesskey="t">Overview</a></li><li id="portaltab-download" class="plain"><a href="../../../../download" accesskey="t">Downloads</a></li><li id="portaltab-docs" class="plain"><a href="../../../../docs" accesskey="t">Documentation</a></li><li id="portaltab-biocpub" class="plain"><a href="../../../../pub" accesskey="t">Publications</a></li><li id="portaltab-workshops" class="selected"><a href="../../../../workshops" accesskey="t">Workshops</a></li><li id="portaltab-cabig" class="plain"><a href="http://wiki.fhcrc.org/caBioc" accesskey="t">caBIG</a></li></ul> </div> <div class="visualClear"></div> <!-- The wrapper div. It contains the three columns. --> <div id="portal-columns" class="visualColumnHideNone"> <!-- start of the main and left columns --> <div id="visual-column-wrapper"> <!-- start of main content block --> <div id="portal-column-content" class="topmargin1"> <div id="content" class=""> <div class="documentContent" id="region-content"> <a name="documentContent"></a> <h1 class="documentFirstHeading">lab2.R</h1> <div class="documentDescription"></div> <div class="plain"> ################################################### <br />### chunk number 1: <br />################################################### <br />set.seed(1234) <br />x <- rnorm(5) <br />print(x) <br /> <br />################################################### <br />### chunk number 2: <br />################################################### <br />print(3:10) <br /> <br />################################################### <br />### chunk number 3: <br />################################################### <br />print(x[2:4]) <br /> <br />################################################### <br />### chunk number 4: <br />################################################### <br />inds <- c(2,3,4) <br />print(x[inds]) <br /> <br />################################################### <br />### chunk number 5: <br />################################################### <br />inds <- c(low=2,mid=3,hi=4) <br />print(inds) <br />print(x[ inds[c("low","hi")] ]) <br /> <br />################################################### <br />### chunk number 6: <br />################################################### <br />myList <- list(a=x, b=inds) <br />print(myList[[1]]) <br />print(myList[["a"]]) <br />print(myList$b) <br /> <br /> <br />################################################### <br />### chunk number 7: <br />################################################### <br />library(cluster) <br />library(Biobase) <br />library(annotate) <br />library(genefilter) <br />library(AggPred) <br />library(sma) <br /> <br /> <br />################################################### <br />### chunk number 8: <br />################################################### <br />library(golubEsets) <br />data(golubTrain) <br />data(golubTest) <br />print(golubTrain) <br />print(table(golubTrain$ALL.AML)) <br /> <br />################################################### <br />### chunk number 9: <br />################################################### <br />LS <- exprs(golubTrain) <br />cl <- golubTrain$ALL.AML <br />TS <- exprs(golubTest) <br />clts <- golubTest$ALL.AML <br /> <br />################################################### <br />### chunk number 10: <br />################################################### <br />LS[LS<100]<-100 <br />TS[TS<100]<-100 <br />LS[LS>16000]<-16000 <br />TS[TS>16000]<-16000 <br /> <br /> <br />################################################### <br />### chunk number 11: <br />################################################### <br />mmfilt <- function(r=5, d=500, na.rm=TRUE) { <br /> function(x) { <br /> minval <- min(x, na.rm=na.rm) <br /> maxval <- max(x, na.rm=na.rm) <br /> (maxval/minval > 5) && (maxval-minval > 500) <br /> } <br /> } <br /> <br />mmfun <- mmfilt() <br /> <br />ffun <- filterfun(mmfun) <br /> <br />good <- genefilter(cbind(LS, TS), ffun ) <br /> <br />sum(good) ##I get 3571 not 3051! <br /> <br />LSsub <- log10(LS[good,]) <br />TSsub <- log10(TS[good,]) <br />print(dim(LSsub)) <br /> <br /> <br />################################################### <br />### chunk number 12: <br />################################################### <br />cor.all<-cor(LSsub) <br />plot.cor(cor.all[order(cl), order(cl)], labels=sort(cl), <br /> labcols=unclass(sort(cl)), <br /> title="Correlation matrix, all genes",zlim=c(-1,1)) <br /> <br />################################################### <br />### chunk number 13: <br />################################################### <br />library(ellipse) <br />plotcorr(cor.all[order(cl), order(cl)], labels=sort(cl), <br /> labcols=unclass(sort(cl)), <br /> title="Correlation matrix, all genes") <br /> <br />################################################### <br />### chunk number 14: <br />################################################### <br />gf <- gapFilter(250, 500, .1) <br />ff <- filterfun(gf) <br />good <- genefilter(10^LSsub, gf) <br />sum(good) # should be 1091 <br /> <br />cor.gf <- cor(LS[good,]) <br /> <br /> <br />################################################### <br />### chunk number 15: <br />################################################### <br />plot.cor(cor.gf[order(cl), order(cl)], labels=sort(cl), <br /> labcols=unclass(sort(cl)), <br /> title="Correlation matrix, filtered genes",zlim=c(-1,1)) <br /> <br />################################################### <br />### chunk number 16: <br />################################################### <br />plotcorr(cor.gf[order(cl), order(cl)], labels=sort(cl), <br /> labcols=unclass(sort(cl)), <br /> title="Correlation matrix, filtered genes") <br /> <br />################################################### <br />### chunk number 17: <br />################################################### <br />library(edd) <br />ALLtrDists <- edd.unsupervised( golubTrain[, golubTrain$ALL=="ALL"] ) <br />print(table(ALLtrDists)) <br /> <br />################################################### <br />### chunk number 18: <br />################################################### <br />golURL <- url("http://www-genome.wi.mit.edu/mpr/data_set_ALL_AML_train.txt","r") <br /> <br />################################################### <br />### chunk number 19: <br />################################################### <br />golVec <- scan(golURL, sep="\t", what="") <br /> <br /> <br />################################################### <br />### chunk number 20: <br />################################################### <br />print(length(golVec)) <br />print(length(golVec)/79) <br /> <br />################################################### <br />### chunk number 21: <br />################################################### <br />golVec <- c(golVec[1:78],"",golVec[-(1:78)]) <br />print(length(golVec)/79) <br />golMat <- t(matrix(golVec,nr=79)) <br />print(dim(golMat)) <br />print(golMat[1:5,1:5]) <br /> <br />################################################### <br />### chunk number 22: <br />################################################### <br />cExprs <- golMat[-1,seq(3,78,2)] <br />numExprs <- t(apply(cExprs,1,as.numeric)) <br />print(numExprs[1:4,1:4]) <br /> <br />################################################### <br />### chunk number 23: <br />################################################### <br />accnos <- golMat[-1,2] <br />dimnames(numExprs) <- list(accnos,NULL) <br /> <br />################################################### <br />### chunk number 24: <br />################################################### <br />exprSamps <- golMat[1,seq(3,78,2)] <br /> <br />################################################### <br />### chunk number 25: <br />################################################### <br />pheu <- url("http://www-genome.wi.mit.edu/mpr/table_ALL_AML_samples.txt","r") <br />PH <- readLines(pheu) <br />print(length(PH)) <br />print(PH[1:5]) <br /> <br />################################################### <br />### chunk number 26: <br />################################################### <br />print(PH[10]) <br />print(PH[47]) <br /> <br />################################################### <br />### chunk number 27: <br />################################################### <br />print(strsplit(PH[10],"\t")) <br /> <br />################################################### <br />### chunk number 28: <br />################################################### <br />samp <- rep(NA,38) <br />dx <- rep(NA,38) <br />cellType <- rep(NA,38) <br />for (i in 10:47) { <br /> tmp <- strsplit(PH[i],"\t")[[1]] <br /> samp[i-9] <- tmp[1] <br /> dx[i-9] <- tmp[3] <br /> cellType[i-9] <- tmp[6] <br />} <br />dx <- substring(dx,1,3) <br />samp <- c(substring(samp[1:9],1,1),substring(samp[10:38],1,2)) <br />phenoDF <- data.frame(samp=as.numeric(samp), dx=dx, <br /> cellType=cellType) <br />print(phenoDF[1:4,]) <br /> <br />################################################### <br />### chunk number 29: <br />################################################### <br />library(Biobase) <br />myPh <- new("phenoData", pData=phenoDF[as.numeric(exprSamps),], <br /> varLabels=list(samp="sample code", <br /> dx="diagnosis", cellType="cell type")) <br />myES <- new("exprSet", exprs=numExprs, <br /> phenoData=myPh, description=names(phenoDF), <br /> annotation="affy", notes="from web") <br /> <br />################################################### <br />### chunk number 30: <br />################################################### <br />print(myES) <br />print(myES[1:10,]) <br />print(myES$dx[c(1:5,37:38)]) <br /> <br />################################################### <br />### chunk number 31: <br />################################################### <br />print(geneNames(myES)[c(1,1000,2000)]) <br />print(exprs(myES)[c(1,1000,2000),1:3]) <br /> <br /> <br /> </div> <div class="discussion"> </div> </div> </div> </div> <!-- end of main content block --> <!-- start of the left (by default at least) column --> <div id="portal-column-one"> <div class="visualPadding"> <br><br><br> <!-- disabled left slot image <img tal:replace="structure nocall:here/pict.jpg" /> --> <div class="portlet" id="portlet-navigation-tree"> <div> <h5>Navigation</h5> <div class="portletBody"> <div class="portletContent odd"> <a href="../../../../GettingStarted/index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Getting Started</span> </a> <a href="../../../../overview/index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Overview</span> </a> <a href="../../../../download/index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Downloads</span> </a> <a href="../../../../docs/index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Documentation</span> </a> <a href="../../../../pub/index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Publications</span> </a> <a href="../../../index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Workshops</span> </a> <a href="../../../2010/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2010</span> </a> <a href="../../../2009/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2009</span> </a> <a href="../../../2008/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2008</span> </a> <a href="../../../2007/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2007</span> </a> <a href="../../../2006/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2006</span> </a> <a href="../../../2005/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2005</span> </a> <a href="../../../2004/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2004</span> </a> <a href="../../../2003/index.html" accesskey="n" class="navItem navLevel2" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2003</span> </a> <a href="../../index.html" accesskey="n" class="navItem navLevel2" title="Workshops and courses 2002"> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">2002</span> </a> <a href="../index.html" accesskey="n" class="navItem navLevel3" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Boston 1-2002</span> </a> <a href="index.html" accesskey="n" class="navItem navLevel4 currentNavItem" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">labs</span> </a> <a href="../../../../developers/index.html" accesskey="n" class="navItem navLevel1" title=""> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">Developers</span> </a> <a href="../../../../News/index.html" accesskey="n" class="navItem navLevel1" title="BioC Project News"> <!-- Disable Folder icon <img src="" height="16" width="16" alt="" class="navIcon" tal:condition="not:isAnon" tal:attributes="src python:portal_url+'/'+sibling.getIcon(1); title sibling/Type;" /> --> <span class="navItemText">News</span> </a> </div> </div> </div> </div> </div> </div> <!-- end of the left (by default at least) column --> </div> <!-- end of the main and left columns --> <!-- start of right (by default at least) column --> <div id="portal-column-two"> <div class="visualPadding"> <div> <!-- The Related Items box --> <script type="text/javascript" src="plonesearchbox_utils.js"> </script> <div class="portlet"> <!-- <h5 i18n:translate="searchbox_title">Search Box</h5> --> <div class="portletBody"> <form name="searchbox_form" id="searchbox_form" method="post" onsubmit="return process()" action="http://bioconductor.org/workshops/2002/ShortCourse012302/labs/redirectToUrl" target="_blank"> <div class="portletContent odd"> <div id="searchbox_fields"> <input type="text" name="toSearch" id="toSearch" size="22" /> </div> <select name="choice" id="choice" onchange="return generateForm();" style="margin: 3px 0px 0px 0px;"> <option value="http://bioconductor.org/workshops/2002/ShortCourse012302/labs/lab2.R/search?SearchableText=" id="search_portal">In this site</option> <option value="http://bioconductor.org/workshops/2002/ShortCourse012302/labs/lab2.R/search?path=/Plones/rgentlem/bioconductor/workshops/2002/ShortCourse012302/labs/lab2.R&SearchableText=" id="search_rubric">In this folder</option> <option value="http://google.com/search?sitesearch=www.bioconductor.org&q=%(text)s">Google this site</option> </select> <input class="context searchButton" type="submit" value="Search" style="margin: 3px;" /> </div> <!-- <div class="portletContent odd"> <input class="context searchButton" type="submit" value="Search" style="margin: 3px;" i18n:attributes="value"/> </div> <div class="portletContent even"> <a href="" tal:attributes="href string:${portal_url}/search_form" i18n:translate="advanced_search_link">Advanced search</a> </div> --> </form> <script type="text/javascript"> <!-- /*in case the first choice of the combobox is an url with several fields*/ clearForm(); generateForm(); --> </script> </div> </div> </div> <div class="portlet" id="portlet-news"> <h5>News</h5> <div class="portletBody"> <div class="portletContent odd"> <div class="portletDetails"> <a href="../../../../News/2009-10-28-Release-2.5" class="date" title="BioC 2.5 Released">2009-10-26</a> <p> BioC 2.5, consisting of 352 packages and designed to work with R 2.10.z, was released today. </p> </div> </div> <div class="portletContent even"> <div class="portletDetails"> <a href="../../../../News/RinNYT" class="date" title="Print Media Recognition">2009-01-07</a> <p> R, the open source platform used by Bioconductor, featured in a series of articles in the New York Times. </p> </div> </div> <div class="portletContent odd"> <a href="../../../../news" class="portletMore"> More... </a> </div> </div> </div> </div> </div> <!-- end of the right (by default at least) column --> </div> <!-- end column wrapper --> <div class="visualClear"></div> <hr class="netscape4" /> <div id="portal-footer"> © 2003-2009 BioConductor. All Rights Reserved. <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-357281-1"); pageTracker._trackPageview(); } catch(err) {} </script> </div> </div> </body> </html>