comparison rmarkdown_report.Rmd @ 0:803f4888f36a draft

planemo upload commit 004a320fc0619c234164b44c64ba5dce205734e1
author mingchen0919
date Thu, 13 Dec 2018 22:46:23 -0500
parents
children e08dd15646c6
comparison
equal deleted inserted replaced
-1:000000000000 0:803f4888f36a
1 ---
2 title: 'HTSeq-count Report'
3 output:
4 html_document:
5 highlight: pygments
6 ---
7
8 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
9 knitr::opts_chunk$set(error = TRUE, echo = FALSE)
10 ```
11
12 ```{css echo=FALSE}
13 # code chunks scrollable
14 pre code, pre, code {
15 white-space: pre !important;
16 overflow-x: scroll !important;
17 word-break: keep-all !important;
18 word-wrap: initial !important;
19 }
20 ```
21
22
23 ```{r, echo=FALSE}
24 # to make the css theme to work, <link></link> tags cannot be added directly
25 # as <script></script> tags as below.
26 # it has to be added using a code chunk with the htmltool functions!!!
27 css_link = tags$link()
28 css_link$attribs = list(rel="stylesheet", href="vakata-jstree-3.3.5/dist/themes/default/style.min.css")
29 css_link
30 ```
31
32 ```{r, eval=FALSE, echo=FALSE}
33 # this code chunk is purely for adding comments
34 # below is to add jQuery and jstree javascripts
35 ```
36 <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
37 <script src="vakata-jstree-3.3.5/dist/jstree.min.js"></script>
38
39 ```{r, eval=FALSE, echo=FALSE}
40 # The script below is used to avoid conflicts between different javascript labraries
41 ```
42
43 <script>
44 jQuery.noConflict();
45
46 jQuery( document ).ready(function( $ ) {
47 // You can use the locally-scoped $ in here as an alias to jQuery.
48 $( "jstree" ).hide();
49 });
50
51 // The $ variable in the global scope has the prototype.js meaning.
52 window.onload = function(){
53 var mainDiv = $( "main" );
54 }
55 </script>
56
57 ---
58 # javascript code below is to build the file tree interface
59 # see this for how to implement opening hyperlink: https://stackoverflow.com/questions/18611317/how-to-get-i-get-leaf-nodes-in-jstree-to-open-their-hyperlink-when-clicked-when
60 ---
61 <script>
62 $(function () {
63 // create an instance when the DOM is ready
64 $('#jstree').jstree().bind("select_node.jstree", function (e, data) {
65 window.open( data.node.a_attr.href, data.node.a_attr.target )
66 });
67 });
68 </script>
69
70 ---
71 # ADD YOUR DATA ANALYSIS CODE AND MARKUP TEXT BELOW TO EXTEND THIS R MARKDOWN FILE
72 ---
73
74 ## Job script
75
76 ```{bash, echo=FALSE}
77 sh ${TOOL_INSTALL_DIR}/build-and-run-job-scripts.sh > ${REPORT_FILES_PATH}/log.txt 2>&1
78 ```
79
80 ```{r echo=FALSE, comment='', results='asis'}
81 cat('```bash\n')
82 cat(readLines(paste0(Sys.getenv('REPORT_FILES_PATH'), '/htseq-count.sh')), sep = '\n')
83 cat('\n```')
84 ```
85
86 ## Counts
87
88 Write data into a CSV file.
89
90 ```{r, echo=TRUE}
91 count_data = read.table(paste0(opt$X_d, '/counts.txt'), row.names = 1)
92 sample_names = trimws(strsplit(opt$X_B, ',')[[1]])
93 colnames(count_data) = rep(sample_names, length = ncol(count_data))
94
95
96 # modify column names
97 count_data = data.frame(feature_id = rownames(count_data), count_data)
98 write.csv(count_data,
99 file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/count_data.csv'),
100 quote = FALSE, row.names = FALSE)
101 ```
102
103 Display the top 1000 rows with largest average counts.
104
105 ```{r echo=TRUE}
106 # Sort count table by count average
107 rownames(count_data) = count_data$feature_id
108 count_data = count_data[, -1]
109 sorted_ct_table = count_data[order(rowMeans(count_data), decreasing = TRUE), ]
110 DT::datatable(head(sorted_ct_table, 1000))
111 ```
112
113