Skip to content

Commit c3f7184

Browse files
author
Kenneth Daily
authored
Merge pull request #16 from Sage-Bionetworks/develop
Develop
2 parents e13166d + 777eee7 commit c3f7184

File tree

4 files changed

+133
-85
lines changed

4 files changed

+133
-85
lines changed

inst/report.Rmd

Lines changed: 102 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ output:
33
html_document:
44
keep_md: yes
55
params:
6-
projectId: !r 'syn1773109'
7-
nMonths: 2
8-
useTeamGrouping: TRUE
9-
aclTeamOrder: !r c(2224090, 3319054, 273957, 'syn1773109')
6+
projectId: !r 'syn2775243'
7+
nMonths: !r NA
8+
useTeamGrouping: !r TRUE
9+
aclTeamOrder: !r c('syn2775243')
1010
queryDataFile: !r NA
1111
---
1212

@@ -40,7 +40,18 @@ qDownloadTemplate <- 'select CLIENT,ENTITY_ID,CONVERT(AR.TIMESTAMP, CHAR) AS TIM
4040
config <- yaml.load_file("~/datawarehouse_config.yml")
4141
4242
projectId <- gsub("syn", "", params$projectId)
43-
nMonths <- params$nMonths
43+
proj <- synGet(params$projectId)
44+
45+
46+
if (is.na(params$nMonths)) {
47+
startDate <- lubridate::as_date(proj@properties$createdOn)
48+
thisDate <- lubridate::floor_date(lubridate::today(), "month")
49+
thisDate <- thisDate - lubridate::period(1, "months")
50+
nMonths <- interval(startDate, thisDate) %/% months(1)
51+
} else {
52+
nMonths <- params$nMonths
53+
}
54+
4455
useTeamGrouping <- params$useTeamGrouping
4556
aclTeamOrder <- params$aclTeamOrder
4657
@@ -52,7 +63,6 @@ con <- dbConnect(MySQL(),
5263
5364
timestampBreaksDf <- makeDateBreaks(nMonths) %>% dplyr::arrange(date)
5465
55-
proj <- synGet(params$projectId)
5666
5767
```
5868

@@ -125,27 +135,36 @@ queryData %>%
125135

126136
There are `r length(setdiff(unique(queryData$userName), c("anonymous")))` active registered Synapse users in this time period. Of these, `r multiMonthVisits(queryData) %>% nrow` users were active in the project in at least two different months.
127137

138+
## Project page views
139+
140+
Count of the number of page views of the main project Wiki (`r params$projectId`) per month.
141+
128142
```{r}
129143
projectPageViews <- queryData %>% filter(recordType=='pageview', NODE_TYPE=='project', id==projectId)
130144
131-
if (useTeamGrouping) {
132-
projectPageViewsCount <- projectPageViews %>%
133-
dplyr::filter(recordType == 'pageview') %>%
134-
dplyr::count(teamName, dateGrouping) %>%
135-
reshape2::dcast(teamName ~ dateGrouping, fun.aggregate = sum)
136-
} else {
137-
projectPageViewsCount <- projectPageViews %>%
138-
dplyr::filter(recordType == 'pageview') %>%
139-
dplyr::mutate(teamName='All') %>%
140-
dplyr::count(teamName, dateGrouping) %>%
141-
reshape2::dcast(teamName ~ dateGrouping)
145+
if (nrow(projectPageViews) > 0) {
146+
if (useTeamGrouping) {
147+
projectPageViewsCount <- projectPageViews %>%
148+
dplyr::filter(recordType == 'pageview') %>%
149+
dplyr::count(teamName, dateGrouping) %>%
150+
reshape2::dcast(teamName ~ dateGrouping, fun.aggregate = sum)
151+
} else {
152+
projectPageViewsCount <- projectPageViews %>%
153+
dplyr::filter(recordType == 'pageview') %>%
154+
dplyr::mutate(teamName='All') %>%
155+
dplyr::count(teamName, dateGrouping) %>%
156+
reshape2::dcast(teamName ~ dateGrouping)
157+
}
158+
159+
projectPageViewsCount %>% knitr::kable()
142160
}
143161
144-
projectPageViewsCount %>% knitr::kable()
145-
146162
```
147163

148164
#### Page views per month
165+
166+
Count of the page views of any page (Wiki or entity) in the entire project per month.
167+
149168
```{r loadpermonth, include=TRUE, eval=TRUE}
150169
if (useTeamGrouping) {
151170
dateGroupingCount <- queryData %>%
@@ -164,47 +183,62 @@ dateGroupingCount %>% knitr::kable()
164183
```
165184

166185
#### Page views per day
186+
187+
Plot of the page views of any page (Wiki or entity) in the entire project per day.
188+
167189
```{r plotperday, fig.width=20, fig.height=6, include=TRUE, eval=TRUE}
168190
perdayCount <- countByDay(queryData %>% filter(recordType == 'pageview'),
169191
useTeamGrouping)
170-
plotByDay(perdayCount, useTeamGrouping)
192+
193+
if (nrow(perdayCount) > 0) {
194+
plotByDay(perdayCount, useTeamGrouping)
195+
}
171196
```
172197

173-
#### Entity page views (top 100 with more than 5 views)
198+
#### Entity page views
199+
200+
The top 50 Files or Folders with at least 5 views.
201+
174202
```{r include=TRUE, eval=TRUE}
175203
### Data
176204
tmp <- queryData %>%
177205
dplyr::filter(recordType == 'pageview') %>%
178206
dplyr::count(id, NAME, NODE_TYPE) %>%
179207
dplyr::filter(n >= 5, !stringr::str_detect(id, "acl"))
180208
181-
dataaccessCount1 <- queryData %>%
182-
dplyr::filter(recordType == 'pageview') %>%
183-
dplyr::filter(id %in% tmp$id) %>%
184-
dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
185-
dplyr::ungroup() %>%
186-
reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
187-
dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
209+
if (nrow(tmp) > 0) {
210+
dataaccessCount1 <- queryData %>%
211+
dplyr::filter(recordType == 'pageview') %>%
212+
dplyr::filter(id %in% tmp$id) %>%
213+
dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
214+
dplyr::ungroup() %>%
215+
reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
216+
dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
188217
# dplyr::mutate(name=sprintf("[%s](https://www.synapse.org/#!Synapse:syn%s)", NAME, id))
189-
190-
191-
dataaccessCount2 <- queryData %>%
192-
dplyr::filter(recordType == 'pageview') %>%
193-
dplyr::filter(id %in% tmp$id) %>%
194-
dplyr::count(id, NAME, NODE_TYPE) %>%
195-
dplyr::ungroup() %>%
196-
dplyr::arrange(dplyr::desc(n))
197-
198-
dataaccessCount <- dataaccessCount1 %>% left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
199-
dplyr::arrange(dplyr::desc(n)) %>%
200-
head(50) %>%
201-
dplyr::rename(total=n) %>%
202-
dplyr::select(name, everything(), total, -id, -NAME)
203-
204-
dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
218+
219+
220+
dataaccessCount2 <- queryData %>%
221+
dplyr::filter(recordType == 'pageview') %>%
222+
dplyr::filter(id %in% tmp$id) %>%
223+
dplyr::count(id, NAME, NODE_TYPE) %>%
224+
dplyr::ungroup() %>%
225+
dplyr::arrange(dplyr::desc(n))
226+
227+
dataaccessCount <- dataaccessCount1 %>%
228+
left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
229+
dplyr::arrange(dplyr::desc(n)) %>%
230+
head(50) %>%
231+
dplyr::rename(total=n) %>%
232+
dplyr::select(name, everything(), total, -id, -NAME)
233+
234+
dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
235+
}
205236
```
206237

207238
#### Entity downloads (top 100 with more than 5 views)
239+
240+
The top 50 Files or Folders with at least 5 views.
241+
208242
```{r include=TRUE, eval=TRUE}
209243
### Data
210244
tmp <- queryData %>%
@@ -213,29 +247,30 @@ tmp <- queryData %>%
213247
dplyr::filter(n >= 5, !stringr::str_detect(id, "acl"))
214248
215249
if (nrow(tmp) > 0) {
216-
dataaccessCount1 <- queryData %>%
217-
dplyr::filter(recordType == 'download') %>%
218-
dplyr::filter(id %in% tmp$id) %>%
219-
dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
220-
dplyr::ungroup() %>%
221-
reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
222-
dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
250+
dataaccessCount1 <- queryData %>%
251+
dplyr::filter(recordType == 'download') %>%
252+
dplyr::filter(id %in% tmp$id) %>%
253+
dplyr::count(id, NAME, NODE_TYPE, dateGrouping) %>%
254+
dplyr::ungroup() %>%
255+
reshape2::dcast(id + NAME + NODE_TYPE ~ dateGrouping, value.var='n') %>%
256+
dplyr::mutate(name=sprintf("<a href='https://www.synapse.org/#!Synapse:syn%s' target='_blank'>%s</a>", id, NAME))
223257
# dplyr::mutate(name=sprintf("[%s](https://www.synapse.org/#!Synapse:syn%s)", NAME, id))
224-
225-
226-
dataaccessCount2 <- queryData %>%
227-
dplyr::filter(recordType == 'download') %>%
228-
dplyr::filter(id %in% tmp$id) %>%
229-
dplyr::count(id, NAME, NODE_TYPE) %>%
230-
dplyr::ungroup() %>%
231-
dplyr::arrange(dplyr::desc(n))
232-
233-
dataaccessCount <- dataaccessCount1 %>% left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
234-
dplyr::arrange(dplyr::desc(n)) %>%
235-
head(50) %>%
236-
dplyr::rename(total=n) %>%
237-
dplyr::select(name, everything(), total, -id, -NAME)
238-
239-
dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
258+
259+
260+
dataaccessCount2 <- queryData %>%
261+
dplyr::filter(recordType == 'download') %>%
262+
dplyr::filter(id %in% tmp$id) %>%
263+
dplyr::count(id, NAME, NODE_TYPE) %>%
264+
dplyr::ungroup() %>%
265+
dplyr::arrange(dplyr::desc(n))
266+
267+
dataaccessCount <- dataaccessCount1 %>%
268+
left_join(dataaccessCount2, by=c("id", "NAME", "NODE_TYPE")) %>%
269+
dplyr::arrange(dplyr::desc(n)) %>%
270+
head(50) %>%
271+
dplyr::rename(total=n) %>%
272+
dplyr::select(name, everything(), total, -id, -NAME)
273+
274+
dataaccessCount %>% DT::datatable(options=list(pageLength=20), escape=1)
240275
}
241276
```

inst/scripts/manual_AMPAD.R

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
library(synapseClient)
22
synapseLogin()
33

4-
templates <- c("webAccess"="../webAccess.Rmd",
5-
"downloads"="../downloads.Rmd",
6-
"report"="../report.Rmd")
7-
8-
### AMP-AD
9-
projectId <- 'syn2580853'
4+
templates <- c("report"="../report.Rmd")
105
reportType <- "report"
116

12-
# Store HTML file here
7+
projectId <- 'syn2580853'
138
parentId <- 'syn8457451'
149

1510
myParams <- list(projectId=projectId,
16-
nMonths=30,
11+
nMonths=NA,
1712
aclTeamOrder=c(3346847, 3320424, projectId),
1813
useTeamGrouping=TRUE)
1914

@@ -24,4 +19,5 @@ rmarkdown::render(input=templates[[reportType]],
2419
output_file=htmlFileName,
2520
params = myParams)
2621

27-
htmlFile <- synStore(File(paste0("../", htmlFileName), parentId=parentId))
22+
htmlFile <- synStore(File(paste0("../", htmlFileName),
23+
parentId=parentId))

inst/scripts/manual_MEP-LINCS.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
library(synapseClient)
2+
synapseLogin()
3+
14
templates <- c("report"="../report.Rmd")
5+
reportType <- "report"
26

3-
### MEP-LINCS
47
projectId <- 'syn2862345'
8+
parentId <- 'syn5578879'
9+
510
myParams <- list(projectId=projectId,
6-
nMonths=28,
11+
nMonths=NA,
712
aclTeamOrder=c(3323597, 3330234, 3332397, projectId),
813
useTeamGrouping=TRUE)
914

10-
reportType <- "report"
15+
htmlFileName <- paste0(myParams[['projectId']], "_", reportType, "_",
16+
lubridate::today(), ".html")
17+
1118
rmarkdown::render(input=templates[[reportType]],
12-
output_file=paste0(myParams[['projectId']], "_", reportType, "_",
13-
lubridate::today(), ".html"),
19+
output_file=htmlFileName,
1420
params = myParams)
21+
22+
htmlFile <- synStore(File(paste0("../", htmlFileName),
23+
parentId=parentId))

inst/scripts/manual_PCBC.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1+
library(synapseClient)
2+
synapseLogin()
3+
14
templates <- c("report"="../report.Rmd")
5+
reportType <- "report"
26

37
projectId <- 'syn1773109'
8+
parentId <- 'syn4892835'
9+
410
myParams <- list(projectId=projectId,
5-
nMonths=12,
11+
nMonths=NA,
612
aclTeamOrder=c(2224090, 3319054, 273957, projectId),
713
useTeamGrouping=FALSE)
814

9-
reportType <- "report"
15+
htmlFileName <- paste0(myParams[['projectId']], "_", reportType, "_",
16+
lubridate::today(), ".html")
1017

1118
rmarkdown::render(input=templates[[reportType]],
12-
output_file=paste0(myParams[['projectId']], "_", reportType, "_",
13-
lubridate::today(), ".html"),
19+
output_file=htmlFileName,
1420
params = myParams)
1521

22+
htmlFile <- synStore(File(paste0("../", htmlFileName),
23+
parentId=parentId))

0 commit comments

Comments
 (0)