# Nils Gehlenborg / Nozzle Demo Report / February 2011 require( "Nozzle.R1" ); fhReport <- newReport( "Nozzle Demo Report" ); # --- Data --- figureFile <- "figures/image1.jpg"; figureFileHighRes <- "figures/image1_highres.jpg"; tableDataFile <- "files/table_file.txt"; tableData <- read.table( tableDataFile, sep="\t", skip=1, nrows=10, header=TRUE ); # --- References --- simpleCitation <- newCitation( authors="Nils Gehlenborg", title="The Nozzle Report Package", year="2011", url="http://www.gehlenborg.com" ); webCitation <- newCitation( title="The Cancer Genome Atlas Website", url="http://tcga.cancer.gov/" ); fullCitation <- newCitation( authors="Nils Gehlenborg", title="Nozzle: An R Package for Report Generation", publication="Yet Another Bioinformatics Journal", issue="14", number="44", pages="783-789", year="2011", url="http://www.wikipedia.org" ); fhReport <- addToReferences( fhReport, simpleCitation, webCitation, fullCitation ); # --- Overview --- fhReport <- addToIntroduction( fhReport, newParagraph( "Nozzle is an R Package to new Firehose reports based on\ HTML, CSS and JavaScript. However, ", asEmph( "to use " ), "Nozzle, no knowledge of\ these technologies is required." ) ); fhReport <- addToSummary( fhReport, newParagraph( "A simple API that enables developers to design efficient reports quickly." ) ); # --- Results --- figure <- newFigure( figureFile, fileHighRes=figureFileHighRes, "An example for a figure. Everything that is shown in the figure should be explained\ in the caption. The figure needs to have axis labels and a legend." ); figure2 <- newFigure( figureFile, "An example for a figure without a link to a high-res file." ); table1 <- newTable( tableData, file=tableDataFile, "A small table. All ", asParameter( "parameters" ), " shown in the columns\ of the table need to be explained in the caption." ); table3 <- newTable( tableData, "A small table without a link to a file." ); paragraph1 <- newParagraph( "Nozzle supports a range of different formatting styles: ", asStrong( "strong" ), "; ", asEmph( "emph" ), "; ", asParameter( "parameter" ), " = ", asValue( "value" ), "; ", asFilename( "filename" ), "; ", asCode( "code" ), "; " ); list <- newList( newParagraph( "Nozzle also provides lists." ), newParagraph( "They can even be nested." ), newList( isNumbered=TRUE, newParagraph( "They may contain other lists." ), newParagraph( "Or selected other elements." ), newParagraph( "Numbered." ) ), newParagraph( "Or unnumbered." ) ); paragraph2 <- newParagraph( "The Nozzle package ", asReference( simpleCitation ), " also supports referencing of figures, tables and\ references ", asReference( webCitation ), asReference( fullCitation ), " that are part of the report. For instance, developers can\ refer to a figure, such as ", asReference( figure ), ", or to a table, such\ as ", asReference( table1 ), "." ); paragraphPublic <- newParagraph( "Nozzle reports may also contain results with different levels\ of protection. For instance, this paragraph is labeled ", asLink( "\'PUBLIC\'", url="demo_public.html" ), " and will be\ included in all reports. However, the next paragraph is labeled ", asLink( "\'TCGA\'", url="demo_tcga.html" ), " and will\ only be included in reports for members of the TCGA Consortium. The paragraph after \ the next is even more restricted and labeled ", asLink( "\'PRIVATE\'", url="demo_private.html" ), ", which means that it\ will only show up in internal reports. ", asStrong( "Please note that if you\ are viewing the public version or the TCGA version of the report you might not\ see any paragraphs or only one paragraph after this one." ), protection=PROTECTION.PUBLIC ); paragraphTcga <- newParagraph( "This paragraph is protected and will only be included in reports\ for members of the TCGA Consortium.", protection=PROTECTION.TCGA ); paragraphPrivate <- newParagraph( "This is a private paragraph. Hardly anyone gets to see this.", protection=PROTECTION.PRIVATE ); result <- newResult( asParameter( "A" ), " = ", asValue( "53030" ), isSignificant=round( runif(1) ) ); result <- addTo( result, addTo( newSection( "My Rocking Result" ), addTo( newSubSection( "My Rocking Subresult" ), addTo( newSubSubSection( "My Subrocking Subresult" ), newParagraph( "This is a paragraph related to the rocking result of A = 53030.\ Results may contain all sorts of section, figures, tables, list and so on.\ But no more results, please!" ) ) ), newFigure( "figures/image2.jpg", fileHighRes="figures/image2_highres.jpg", "Symmetry. By Kokorono: ", asLink( url="http://www.flickr.com/photos/kokorono/5422006034" ) ) ) ); result2 <- newResult( asParameter( "B" ), " = ", asValue( "1234" ), isSignificant=round( runif(1) ) ); result2 <- addTo( result2, addTo( newSection( "My Rocking Result" ), newParagraph( "This is a paragraph related to the rocking result of A = 53030.\ Results may contain all sorts of section, figures, tables, list and so on.\ But no more results, please!" ), newFigure( "figures/image1.jpg", fileHighRes="figures/image1_highres.jpg", "Anothr pictur from Flickr." ) ) ); paragraph3 <- newParagraph( "A particularly fun aspect of Nozzle is how it handles results and\ summaries of results. For instance, we have found that ", asSummary( result ), ", which is totally an amazing result. It is ", if ( result$isSignificant ) { "totally" } else { "not" }, " significant." ); list2 <- newList( newParagraph( "This is another list." ), newParagraph( "It contains a result: ", asSummary( result2 ) ), newParagraph( "That's nice!" ) ); table2 <- newTable( tableData, file=tableDataFile, "Another small table. This table has result summaries associated with it. All ", asParameter( "parameters" ), " shown in the columns of the table need to be explained in the caption." ); for ( i in 1:dim( tableData )[1] ) { result <- addTo( newResult( "", isSignificant=( tableData[i,4] < 0.0001 ) ), addTo( newSection( "Result ", i ), newParagraph( "This is a paragraph related to ", tableData[i,1], "." ) ) ); table2 <- addTo( table2, result, row=i, column=4 ); } fhReport <- addToResults( fhReport, addTo( newSubSection( "Nozzle Figure" ), figure, figure2 ), addTo( newSubSection( "Nozzle Table" ), table1, table3 ), addTo( newSubSection( "Nozzle Text" ), paragraph1, list, paragraph2, paragraphPublic, paragraphTcga, paragraphPrivate ), addTo( newSubSection( "Nozzle Results" ), addTo( newSubSubSection( "Subsubsection!" ), newParagraph( "Text in a subsection!" ) ), paragraph3, list2, table2 ) ); # --- Methods --- method1 <- addTo( newSubSection( "Really Cool Method" ), newParagraph( "A typical method description consists of one or two paragraphs of\ text describing the method, followed by a list of method parameters and their\ values for the present run." ), newParameterList( asParameter( "param alpha" ), asValue( "Bet" ), asParameter( "param beta" ), asValue( "Carotene" ), asParameter( "param gamma" ), asValue( "Erich" )) ); method2 <- addTo( newSubSection( "Pretty Fast Method" ), newParagraph( "A typical method description consists of one or two paragraphs of\ text describing the method, followed by a list of method parameters and their\ values for the present run." ), newParameterList( asParameter( "n" ), asValue( "x" ), asParameter( "Q" ), asValue( "1034" ), asParameter( "T" ), asValue( "4.4" )) ); fhReport <- addToMethods( fhReport, method1, method2 ); fhReport <- addToInput( fhReport, newParagraph( "This section should list the files that were used as input." ), newParameterList( asParameter( "methylation file" ), asFilename( "/path/to/this/great/file" ), asParameter( "gene expression file" ), asFilename( "/path/to/gene/expression/file" ) ) ); # --- HTML generation --- writeReport( fhReport, filename="demo_public", level=PROTECTION.PUBLIC ); writeReport( fhReport, filename="demo_tcga", level=PROTECTION.TCGA ); writeReport( fhReport, filename="demo_private", level=PROTECTION.PRIVATE ); writeReport( fhReport, filename="demo", level=PROTECTION.PRIVATE );