-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpnldashboard.Rmd
103 lines (82 loc) · 3.73 KB
/
pnldashboard.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
title: "Flexdashboard"
output:
flexdashboard::flex_dashboard:
navbar:
- { title: "PNL Project Dashboard Test", align: right }
source_code: embed
orientation: columns
smart: false
always_allow_html: yes
---
```{r setup, include=FALSE}
library(data.table)
library(DT)
library(magrittr)
library(flexdashboard)
library(knitr)
PATHS <- '*/paths.csv' %>% Sys.glob %>% lapply(fread) %>% rbindlist
EXTRA <- '*/unaccounted_files.csv' %>% Sys.glob %>% lapply(fread,colClasses = c('character', 'character', 'double')) %>% rbindlist
DU <- '*/du.csv' %>% Sys.glob %>% lapply(fread) %>% rbindlist
PARAMS <- '*/params.csv' %>% Sys.glob %>% lapply(fread) %>% rbindlist
```
Overview
=====================================
```{r overview}
#TODO handle empty project paths
PATHS.unique = PATHS[, head(.SD, 1), by=.(projectPath, path)]
PATHS.byProject = PATHS.unique[PATHS.unique[,exists] & ! path %like% '\\.\\./.*', .('project files (G)'=sum(sizeMB)/1024),by=projectPath]
EXTRA.byProject = EXTRA[,.('extra files (G)'=sum(sizeMB)/1024), by=projectPath]
SPACE_TABLE.a = merge(PATHS.byProject, EXTRA.byProject, all.x=T, by="projectPath")
SPACE_TABLE = merge(SPACE_TABLE.a, DU, by="projectPath")[,'total directory size (G)':=diskUsageG][,diskUsageG:=NULL]
DT::datatable(SPACE_TABLE, options = list(bPaginate=F)) %>% DT::formatRound(c('project files (G)', 'extra files (G)', 'total directory size (G)'), 2)
```
```{r projectpages, include=FALSE}
paths.grouped <- PATHS[,.( completed=sum(exists), missing=sum(not(exists)), total=.N, 'size (G)'=sum(sizeMB, na.rm=T)/1024, examplePath=head(path,n=1)), by=.(projectPath, pathKey, pipelineId)]
indentText <- function(text) {
paste0(" ", gsub("\n", "\n ", text))
}
summarizePipeline <- function(projectpath, projectSD) {
pipelinesCol = projectSD[,
{
paramid=pipelineId
paramCombo = PARAMS[projectPath==projectpath & pipelineId==paramid,]
pipelineDescription = indentText(paramCombo[,pipelineDescription][1])
setorder(paramCombo, param)
paramTable = kable(paramCombo[,.(parameter=param, "parameter value"=paramValue)])
if (nrow(paramCombo) == 0) {
paramTable = "None given."
}
pathsSummary = kable(.SD, digits=1)
diskUsage = .SD[,sum(.SD$'size (G)')] %>% round(digits=1)
# TODO will be empty for an empty PATHS table
caselist = kable(unique(PATHS[projectPath==projectpath & pipelineId==paramid,caseid]))
knit_expand(text='### PIPELINE #{{pipelineId}} ({{diskUsage}}G)
#### Description
{{pipelineDescription}}
#### Parameters
{{paramTable}}
#### Output Paths
{{pathsSummary}}
#### Caselist
{{caselist}}
')
}, by=.(pipelineId)][,V1]
spaceTakenTable = SPACE_TABLE[projectPath==projectpath][,projectPath:=NULL]
spaceTakenTable.html = kable(spaceTakenTable, align=c("l","l"), digits=1)
diskUsage = spaceTakenTable[,.SD$'project files (G)'] %>% round(digits=1)
pageHeader = knit_expand(text='# {{projectpath}} ({{diskUsage}}G) {data-navmenu="Projects"}')
# Add leading 4 spaces to make description a markdown quotation block, hence preserving its formatting
projectDescription = indentText(PARAMS[projectPath==projectpath,description][1])
colSep = "--------------"
#spaceTakenTable = table[projectPath==projectpath][,projectPath:=NULL] %>% DT::formatRound(c('project files (G)', 'extra files (G)'), 1)
overviewCol = c("Col1", colSep, knit_expand(text="### {{projectpath}}"), "", "#### Description", projectDescription, "#### Disk space", spaceTakenTable.html)
c(pageHeader, overviewCol, " ", "Col2 {.tabset} ", colSep, pipelinesCol)
}
out = paths.grouped[,
{
summarizePipeline(projectPath, .SD)
}
, by=.(projectPath)][,V1]
```
`r paste(out, collapse = '\n')`