<!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:22:17" name="DC.date.created" /> <meta content="2005-07-01 10:22:17" 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="../RCode.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="Lab9.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">Lab9.R</h1> <div class="documentDescription"></div> <div class="plain"> <p>################################################### ### chunk number 1: loadpacks ################################################### library(wavethresh) library(Rwave) library(ts) library(Milan)</p> <p>################################################### ### chunk number 2: plotwavelets ################################################### op = par(mfrow=c(5,2), oma = c(0,0, 4, 0), mgp = c(1.2, .8, 0), mar = .1 + c(4,4, .5,1)) for(fn in 1:10) { draw.default(filter.number= fn, col = "blue", main = NULL, xlab= "") abline(h=0,v=0, lty=3, lwd=.5, col = "gray") } mtext(paste("draw.default(*, family = <code>",formals(draw.default)$family[[2]],"</code>)"), side = 3, line = 1, outer = TRUE, cex = par("cex.main"), font = par("font.main")) par(op)</p> <p>################################################### ### chunk number 3: Example1 ################################################### test.data1=example.1()$y ts.plot(test.data1,ylab="y") title("A function with a jump")</p> <p>################################################### ### chunk number 4: DWT1 ################################################### wds1 <- wd(test.data1) plot(wds1)</p> <p>################################################### ### chunk number 5: tree1 ################################################### par(mfrow=c(4,2)) plot.ts(accessC(wds1, level=8)) plot.ts(accessD(wds1, level=8)) plot.ts(accessC(wds1, level=7)) plot.ts(accessD(wds1, level=7)) plot.ts(accessC(wds1, level=6)) plot.ts(accessD(wds1, level=6)) plot.ts(accessC(wds1, level=5)) plot.ts(accessD(wds1, level=5))</p> <p>################################################### ### chunk number 6: Example2 ################################################### par(mfrow=c(1,1)) test.data2<-achirp(512)$y ts.plot(test.data2,ylab="y") title("A linear chirp")</p> <p>################################################### ### chunk number 7: DWT2 ################################################### wds2 <- wd(test.data2) plot(wds2)</p> <p>################################################### ### chunk number 8: tree2 ################################################### par(mfrow=c(4,2)) plot.ts(accessC(wds2, level=8)) plot.ts(accessD(wds2, level=8)) plot.ts(accessC(wds2, level=7)) plot.ts(accessD(wds2, level=7)) plot.ts(accessC(wds2, level=6)) plot.ts(accessD(wds2, level=6)) plot.ts(accessC(wds2, level=5)) plot.ts(accessD(wds2, level=5))</p> <p>################################################### ### chunk number 9: CWT ################################################### par(mfrow=c(3,1)) plot.ts(test.data2) title("A chirp") cwtchirp<-cwt(test.data2,5,12) image(Arg(cwtchirp))</p> <p>################################################### ### chunk number 10: Approx1 ################################################### levels<-3:(wds1$nlevels - 1) nthresh <- length(levels) d <- NULL dz <- 0 for (i in 1:nthresh) { d <- accessD(wds1, level = levels<a href="#refi">[i]</a>) d[abs(d) <= 0.06] = 0 dz=dz+sum(d==0) cat("Level: ", levels<a href="Lab9.R#refi">[i]</a>, " there are ", sum(d == 0), " zeroes\n") wds2 <- putD(wds1, level = levels<a href="#refi">[i]</a>, v = d) } cat("there are in total", dz, " zeroes\n")</p> <p>################################################### ### chunk number 11: Approx2 ################################################### par(mfrow=c(2,1)) ts.plot(wr(wds2)) # look at the difference ts.plot(test.data1-wr(wds2))</p> <p>################################################### ### chunk number 12: Denoise1 ################################################### par(mfcol = c(3, 2), mar = c(2, 2, 2, 1), mgp = c(5, 0.4, 0))<p> x <- (1:128)/128 f1 <- 2 <em> sin(2 </em> pi * x) f2 <- c(rep(0, 32), rep(4, 64), rep(0, 32)) y1 <- f1 + rnorm(128) # performing the dwt of y1 y1wd <- wd(y1, filter.number = 5) plot(x, y1, cex = 0.55) lines(x, wr(threshold(y1wd, policy = "manual", type = "hard", levels = 0:6, value = 1.75))) mtext("Threshold = 1.75", side = 3, line = 0.1, cex = 0.6) plot(x, y1, cex = 0.55) lines(x, wr(threshold(y1wd, policy = "manual", type = "hard", levels = 0:6, value = 2.75))) mtext("Threshold = 2.75", side = 3, line = 0.1, cex = 0.6) plot(x, y1, cex = 0.55) lines(x, wr(threshold(y1wd, policy = "manual", type = "hard", levels = 0:6, value = 3.75))) mtext("Threshold = 3.75", side = 3, line = 0.1, cex = 0.6)</p> <p> y2 <- f2 + rnorm(128) y2wd <- wd(y2, filter.number = 5) plot(x, y2, cex = 0.55) lines(x, wr(threshold(y2wd, policy = "manual", type = "hard", levels = 0:6, value = 1.75))) mtext("Threshold = 1.75", side = 3, line = 0.1, cex = 0.6) plot(x, y2, cex = 0.55) lines(x, wr(threshold(y2wd, policy = "manual", type = "hard", levels = 0:6, value = 2.75))) mtext("Threshold = 2.75", side = 3, line = 0.1, cex = 0.6) plot(x, y2, cex = 0.55) lines(x, wr(threshold(y2wd, policy = "manual", type = "hard", levels = 0:6, value = 3.75))) mtext("Threshold = 3.75", side = 3, line = 0.1, cex = 0.6)</p> </p> <p>################################################### ### chunk number 13: Denoise2 ################################################### par(mfrow = c(2, 2), mar = c(1.5, 1.5, 1.5, 0.5), mgp = c(5, 0.4, 0)) x <- (1:2048)/2048 f <- fblocks(x) ssig <- sqrt(var(f)) f <- ((f - mean(f)) * 5)/ssig fnoise <- f + rnorm(2048) fwd <- wd(fnoise, filter.number = 5) plot(x, f, type = "l") mtext(side = 3, line = 0.1, "True function") plot(x, fnoise, type = "l") mtext(side = 3, line = 0.1, "Noisy observations") fwdsure <- threshsure(fwd) plot(x, wr(fwdsure), type = "l") mtext(side = 3, line = 0.1, "SURE estimator") fwdhyb <- threshhyb(fwd, lowlev = 2, seed = 0) plot(x, wr(fwdhyb), type = "l") mtext(side = 3, line = 0.1, "SURE hybrid estimator")</p> <p>################################################### ### chunk number 14: TI1 ################################################### # k1 and k2 are translation amounts k1 <- 32 k2 <- 42 par(mfrow = c(3, 1), mar = c(1.5, 1.5, 1.5, 0), mgp = c(5, 0.4, 0)) x <- (1:128)/128 unshft <- c(rep(1, 64), rep(-1, 64)) noise <- rnorm(128) # ORIGINAL ESTIMATOR y <- 2 * unshft + noise plot(x, y, type = "l") yest <- wr(threshold(wd(y, filter.number = 1), levels = 0:6)) lines(x, yest) # FIRST TRANSLATED ESTIMATOR if(k1 == 0) y1 <- y else y1 <- c(y[(1 + k1):128], y<a href="#ref1:k1">[1:k1]</a>) if(k1 == 0) shft1 <- unshft else shft2 <- c(unshft[(1 + k1):128], unshft<a href="#ref1:k1">[1:k1]</a>) plot(x, y1, type = "l") y1est <- wr(threshold(wd(y1, filter.number = 1), levels = 0:6)) lines(x, y1est) # SECOND TRANSLATED ESTIMATOR if(k2 == 0) y2 <- y else y2 <- c(y[(1 + k2):128], y<a href="#ref1:k2">[1:k2]</a>) if(k2 == 0) shft2 <- unshft else shft2 <- c(unshft[(1 + k2):128], unshft<a href="#ref1:k2">[1:k2]</a>) plot(x, y2, type = "l") y2est <- wr(threshold(wd(y2, filter.number = 1), levels = 0:6)) lines(x, y2est)</p> <p>################################################### ### chunk number 15: TI2 ################################################### par(mfrow=c(1,1)) par(mar = c(1.5, 1.5, 1.5, 0.5), mgp = c(5, 0.4, 0)) x <- (1:128)/128 y <- 2 * c(rep(1, 64), rep(-1, 64)) + rnorm(128) plot(x, y, type = "l") yest <- spincyclen(y, filter.number = 1) lines(x, yest) yest1 <- spincyclen(y, filter.number = 3) lines(x, yest1,col=<code>red</code>)</p> </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="../../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 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">Milan - May</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">RCode</span> </a> <a href="../../../2002/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="../../../../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/2003/Milan/RCode/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/2003/Milan/RCode/Lab9.R/search?SearchableText=" id="search_portal">In this site</option> <option value="http://bioconductor.org/workshops/2003/Milan/RCode/Lab9.R/search?path=/Plones/rgentlem/bioconductor/workshops/2003/Milan/RCode/Lab9.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>