-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.Rmd
83 lines (62 loc) · 2.45 KB
/
report.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: "Contamination Report"
output: html_document
---
## Contamination Overview Plots
```{r echo=FALSE, warning=FALSE, message=FALSE, fig.width=12, fig.height=10}
list.of.packages <- c("ggplot2", "knitr", "stringr", "readr", "data.table")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(knitr))
suppressPackageStartupMessages(library(stringr))
suppressPackageStartupMessages(library(readr))
suppressPackageStartupMessages(library(data.table))
args <- commandArgs(trailingOnly = TRUE)
args <- commandArgs(trailingOnly = TRUE)
contam = read.table(args[1], header = TRUE, sep="\t");
meta<-data.frame(with(contam, table(Contamination)))
```
---
## Graphical overview
```{r echo=FALSE, fig.width=5.5, fig.height=4, result='asis'}
print(ggplot(data=meta, aes(x=Contamination, y=Freq, fill=Contamination)) + geom_bar(stat="identity") + xlab("Contamination Status") + ylab("Samples") )
```
---
## Verdict
This interactive table shows the detected contaminated samples.
```{r echo=FALSE, results='asis'}
if(nrow(contam)>0){
kable(contam[,c(1,2,3,4,5,6,7,8,9,10)], "html", table.attr = "id=\"contam_table\" class=\"table table-bordered table-striped display responsive nowrap\"",caption = "")
} else{
cat("<div class='alert alert-neutral'>No entries found!</div>")
}
```
<script type="text/javascript">
$(document).ready(function() {
$('#contam_table').DataTable({
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.modal( {
header: function ( row ) {
var data = row.data();
return 'Details for '+data[0];
}
} ),
renderer: function ( api, rowIdx, columns ) {
var data = $.map( columns, function ( col, i ) {
return '<b>' + col.title+':'+'</b><br>'+
col.data+'<br><hr>';
} ).join('');
return $('<div/>').append( data );
}
}
},
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
if ( aData[6] != "1" ){
$('td', nRow).css('background-color', '#f2dede');
}
}
});
} );
</script>