Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Library metadata is displayed in hover window + kludge bug fix #14

Merged
merged 5 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Imports:
V8 (>= 1.5)
Remotes:
ropensci/plotly@efe5535d40200b12e87301f5fd2b5805d0dd38ce
Suggests: testthat, roxygen2
Suggests: testthat, roxygen2, bit64
RoxygenNote: 6.0.1
10 changes: 9 additions & 1 deletion R/create_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,15 @@ createAcquacottaServer <- function(config = createConfig()) {
# This string is used by event_data to register user interactions with the plot
# This string is used by shinyjs to reset a click event, so that the user can click on the same plot element twice
source = config$plotly_id_lib_source,
marker = list(line = list(color = 'rgb(0,0,0)', width = line_width))
marker = list(line = list(color = 'rgb(0,0,0)', width = line_width)),
# Hovertext showing metadata for library
text = ~paste(
'Lane: ', Lane,
'</br>Study: ', Study,
'</br>Barcode: ', Barcode,
'</br>Group ID: ', `Group ID`,
'</br>External Name: ', `External Name`
)
) %>%
add_bars(
y = ~ Value,
Expand Down
5 changes: 0 additions & 5 deletions R/list_reports.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ listRunReports <- function(base_dir) {
file = file,
name = name)

# This is temporary code to exclude the TSV files in the base directory from eariler app version
valid_dir <- list.dirs(path = full_path, full.names = TRUE)
valid_dir <- valid_dir[2:length(valid_dir)]
dt <- dt[dt$dir_path %in% valid_dir, ]

# If two or more TSV files share the same name, their parent folder name is prepanded to remove ambiguity
dup_name <- duplicated(dt$name) | duplicated(dt$name, fromLast = TRUE)
unambiguous_name <- paste(
Expand Down
20 changes: 20 additions & 0 deletions R/utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ fixSeqWareTSV <- function(t.df, valid.dt) {
paste(result.dt$Library, result.dt$Lane, result.dt$Barcode, sep = "_")
)

# Add any missing columns as all NA (Columns from the valid.dt starting with # are ignored, as it is a flag to split column)
missing.columns <- setdiff(valid.dt$app.name, colnames(result.dt))
remove.flag.columns <- grepl('^[^#]', missing.columns) # Columns that do not start with flag
missing.columns <- missing.columns[remove.flag.columns]

if(!identical(missing.columns, character(0))) {
# https://stackoverflow.com/questions/11745169/dynamic-column-names-in-data-table
result.dt[, (missing.columns) := NA]
}

return(result.dt)
}

Expand Down Expand Up @@ -164,6 +174,16 @@ readSeqWareTSV <- function(path) {
set(dt, j = "Run Name", value = factor(rep(path, nrow(dt))))

}, warning = function(w) {
# This is a crutch to fix a bug in data.table. If fread causes a warning, it is caught, but the function is left in a failed state.
# The next valid call to fread will fail again, as the function has to reset itself. The next valid call will work fine.
# I am manually making a valid call to fread to reset it
# Issue is at https://github.com/Rdatatable/data.table/issues/2904
tryCatch({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 That's quite a bug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 hours of my life right there. The good news is that my Issue was deemed a bug, so there was a purpose to my hair pulling.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the report. 10 years of my life hair pulling on data.table now.

fread("echo bug, fix")
}, warning = function(w) {
# Squash the warning message produced by resetting fread
})

stop(conditionMessage(w))
})
}
Expand Down
2 changes: 2 additions & 0 deletions config/column_naming.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Insert Mean (SD),#Split_Mean_SD,NA,
Insert Mean,Insert Mean,Numeric,
Insert Stddev,Insert Stddev,Numeric,
Read Length,#Split_Read1_Read2,NA,
R1 Length,R1 Length,Numeric,
R2 Length,R2 Length,Numeric,
PF Reads,PF Reads,Numeric,
PF Yield,PF Yield,Numeric,
Map Percent,Map Percent,Numeric,
Expand Down
3 changes: 0 additions & 3 deletions tests/testthat/test_list_reports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
library(testthat)
library(acquacotta)

context("Loading Run Report files")

test_that("Loading of clean data", {
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test_utility.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
context("Reading Run Report")

test_that("Loading of valid data", {
expect_error(readSeqWareTSV("./test_utility_data/180406_valid.tsv"), NA)
})

test_that("Loading of invalid data is handled gracefully", {
expect_error(readSeqWareTSV("./test_utility_data/180406_invalid.tsv"))

# fread() cleaned up bug does not happen
# https://github.com/Rdatatable/data.table/issues/2904
expect_error(readSeqWareTSV("./test_utility_data/180406_valid.tsv"), NA)
})
28 changes: 28 additions & 0 deletions tests/testthat/test_utility_data/180406_invalid.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Lane Barcode Group ID External Name Library Insert Mean Insert Stddev Read Length PF Reads PF Yield Map Percent R1 Mismatch Percent R2 Mismatch Percent R1 Indel Percent R2 Indel Percent R1 Soft Clip Percent R2 Soft Clip Percent Reads/SP Percent Mapped on Target Estimated Yield (collapsed) Coverage (collapsed) Target Size (bp) Number of Targets Target File
1 CTCCGATCGTCC na na Lib1 381.15 171.79 151, 151 216418826 32679172611 92.17 0.4 1.03 0.06 0.06 1.06 2.38 1.2 100 24729302364 7.88 3137161171 93 T1
1 ATCTAGCCGGCC na na Lib2 363.78 159.04 151, 151 252302380 38097555690 91.75 0.4 1.02 0.06 0.06 1.1 2.46 1.21 100 28285158676 9.02 3137161171 93 T2
1 TCGGGAAGGTCC na na Lib3 369.18 162.14 151, 151 236526798 35715462763 92.15 0.4 0.97 0.06 0.06 1.01 2.23 1.2 100 26935365729 8.59 3137161171 93 T3
1 GCCTCGAAGTCC na na Lib4 375.03 168.3 151, 151 243644668 36790256463 92.41 0.41 0.98 0.06 0.06 1.14 2.3 1.2 100 27834574154 8.87 3137161171 93 T4
2 ATCTAGCCGGCC na na Lib5 372.56 166.46 151, 151 254039950 38359982266 91.77 0.36 1.01 0.06 0.06 1.07 2.28 1.2 100 28787340464 9.18 3137161171 93 T5
2 TCGGGAAGGTCC na na Lib6 379.52 170.98 151, 151 238841060 36064868521 92.18 0.37 0.98 0.06 0.06 1.02 2.14 1.19 100 27455453152 8.75 3137161171 93 T6
2 GCCTCGAAGTCC na na Lib7 384.88 176.13 151, 151 247411212 37358963614 92.42 0.37 0.98 0.06 0.06 1.08 2.25 1.19 100 28522068554 9.09 3137161171 93 T7
2 CTCCGATCGTCC na na Lib8 391.5 178.75 151, 151 221182532 33398484860 92.19 0.36 1.02 0.06 0.06 1 2.32 1.19 100 25508277420 8.13 3137161171 93 T8
3 GCCTCGAAGTCC na na Lib9 395.1 185.66 151, 151 254121044 38372177283 92.38 0.36 0.97 0.06 0.06 1.09 2.29 1.2 100 28941215516 9.23 3137161171 93 T9
3 TCGGGAAGGTCC na na Lib10 388.72 178.51 151, 151 244101080 36859194245 92.13 0.35 0.95 0.06 0.06 0.98 2.16 1.21 100 27729094422 8.84 3137161171 93 T10
3 CTCCGATCGTCC na na Lib11 401.92 188.53 151, 151 227552300 34360273237 92.14 0.35 1.03 0.06 0.06 1.04 2.36 1.2 100 25912070735 8.26 3137161171 93 T11
3 ATCTAGCCGGCC na na Lib12 380.29 174.51 151, 151 259420556 39172393171 91.73 0.36 0.99 0.06 0.06 1.11 2.36 1.22 100 29024773825 9.25 3137161171 93 T12
4 ATCTAGCCGGCC na na Lib13 382.18 174.56 151, 151 258522006 39036759398 91.78 0.33 0.94 0.06 0.06 1.1 2.29 1.22 100 28821734974 9.19 3137161171 93 T13
4 GCCTCGAAGTCC na na Lib14 396.34 185.94 151, 151 253040936 38209062060 92.42 0.33 0.92 0.06 0.06 1.06 2.23 1.21 100 28719305274 9.15 3137161171 93 T14
4 TCGGGAAGGTCC na na Lib15 389.41 178.05 151, 151 243227188
36727286387 92.19 0.32 0.89 0.06 0.06 0.97 2.11 1.21 100 27532330327 8.78 3137161171 93 T15
4 CTCCGATCGTCC na na Lib16 404.6 189.15 151, 151 226971682 34272611454 92.19 0.32 0.97 0.06 0.06 0.98 2.3 1.21 100 25755587119 8.21 3137161171 93 T16
5 ATCTAGCCGGCC na na Lib17 377.45 175.64 151, 151 262110344 39578617505 91.74 0.35 0.94 0.06 0.06 1.18 2.29 1.26 100 28295604657 9.02 3137161171 93 T17
5 GCCTCGAAGTCC na na Lib18 390.52 186.33 151, 151 255439380 38571326444 92.41 0.35 0.93 0.06 0.06 1.11 2.3 1.24 100 28176385193 8.98 3137161171 93 T18
5 TCGGGAAGGTCC na na Lib19 384.09 178.29 151, 151 246301176 37191373174 92.13 0.35 0.91 0.06 0.06 1.01 2.15 1.25 100 27067104926 8.63 3137161171 93 T19
5 CTCCGATCGTCC na na Lib20 399.6 189.24 151, 151 229297100 34623839979 92.16 0.34 0.99 0.06 0.06 1.05 2.34 1.24 100 25315289382 8.07 3137161171 93 T20
6 CTCCGATCGTCC na na Lib21 399.79 187.64 151, 151 226406380 34187224251 92.14 0.36 1.03 0.06 0.06 1.01 2.31 1.21 100 25502118885 8.13 3137161171 93 T21
6 ATCTAGCCGGCC na na Lib22 377.95 173.58 151, 151 258628142 39052848619 91.74 0.36 1 0.06 0.06 1.11 2.36 1.23 100 28547020088 9.1 3137161171 93 T22
6 TCGGGAAGGTCC na na Lib23 386.48 178.16 151, 151 243040660 36699058535 92.14 0.36 0.96 0.06 0.06 1.03 2.13 1.22 100 27264861066 8.69 3137161171 93 T23
6 GCCTCGAAGTCC na na Lib24 393.02 184.94 151, 151 252419606 38115229911 92.38 0.36 0.99 0.06 0.06 1.09 2.33 1.22 100 28401642000 9.05 3137161171 93 T24
7 AAGCGTACGTCC na na Lib25 301.12 149.43 151, 151 988749818 149301208938 91.18 0.39 0.93 0.07 0.06 3.01 4.04 1.25 100 105042282719 33.48 3137161171 93 T25
8 TTTAGTCAGTCC na na Lib26 308.09 155.88 151, 151 1000300318 151045251998 92.15 0.4 0.87 0.06 0.06 2.13 3.11 1.24 100 109434035708 34.88 3137161171 93 T26
27 changes: 27 additions & 0 deletions tests/testthat/test_utility_data/180406_valid.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Lane Barcode Group ID External Name Library Insert Mean Insert Stddev Read Length PF Reads PF Yield Map Percent R1 Mismatch Percent R2 Mismatch Percent R1 Indel Percent R2 Indel Percent R1 Soft Clip Percent R2 Soft Clip Percent Reads/SP Percent Mapped on Target Estimated Yield (collapsed) Coverage (collapsed) Target Size (bp) Number of Targets Target File
1 CTCCGATCGTCC na na Lib1 381.15 171.79 151, 151 216418826 32679172611 92.17 0.4 1.03 0.06 0.06 1.06 2.38 1.2 100 24729302364 7.88 3137161171 93 T1
1 ATCTAGCCGGCC na na Lib2 363.78 159.04 151, 151 252302380 38097555690 91.75 0.4 1.02 0.06 0.06 1.1 2.46 1.21 100 28285158676 9.02 3137161171 93 T2
1 TCGGGAAGGTCC na na Lib3 369.18 162.14 151, 151 236526798 35715462763 92.15 0.4 0.97 0.06 0.06 1.01 2.23 1.2 100 26935365729 8.59 3137161171 93 T3
1 GCCTCGAAGTCC na na Lib4 375.03 168.3 151, 151 243644668 36790256463 92.41 0.41 0.98 0.06 0.06 1.14 2.3 1.2 100 27834574154 8.87 3137161171 93 T4
2 ATCTAGCCGGCC na na Lib5 372.56 166.46 151, 151 254039950 38359982266 91.77 0.36 1.01 0.06 0.06 1.07 2.28 1.2 100 28787340464 9.18 3137161171 93 T5
2 TCGGGAAGGTCC na na Lib6 379.52 170.98 151, 151 238841060 36064868521 92.18 0.37 0.98 0.06 0.06 1.02 2.14 1.19 100 27455453152 8.75 3137161171 93 T6
2 GCCTCGAAGTCC na na Lib7 384.88 176.13 151, 151 247411212 37358963614 92.42 0.37 0.98 0.06 0.06 1.08 2.25 1.19 100 28522068554 9.09 3137161171 93 T7
2 CTCCGATCGTCC na na Lib8 391.5 178.75 151, 151 221182532 33398484860 92.19 0.36 1.02 0.06 0.06 1 2.32 1.19 100 25508277420 8.13 3137161171 93 T8
3 GCCTCGAAGTCC na na Lib9 395.1 185.66 151, 151 254121044 38372177283 92.38 0.36 0.97 0.06 0.06 1.09 2.29 1.2 100 28941215516 9.23 3137161171 93 T9
3 TCGGGAAGGTCC na na Lib10 388.72 178.51 151, 151 244101080 36859194245 92.13 0.35 0.95 0.06 0.06 0.98 2.16 1.21 100 27729094422 8.84 3137161171 93 T10
3 CTCCGATCGTCC na na Lib11 401.92 188.53 151, 151 227552300 34360273237 92.14 0.35 1.03 0.06 0.06 1.04 2.36 1.2 100 25912070735 8.26 3137161171 93 T11
3 ATCTAGCCGGCC na na Lib12 380.29 174.51 151, 151 259420556 39172393171 91.73 0.36 0.99 0.06 0.06 1.11 2.36 1.22 100 29024773825 9.25 3137161171 93 T12
4 ATCTAGCCGGCC na na Lib13 382.18 174.56 151, 151 258522006 39036759398 91.78 0.33 0.94 0.06 0.06 1.1 2.29 1.22 100 28821734974 9.19 3137161171 93 T13
4 GCCTCGAAGTCC na na Lib14 396.34 185.94 151, 151 253040936 38209062060 92.42 0.33 0.92 0.06 0.06 1.06 2.23 1.21 100 28719305274 9.15 3137161171 93 T14
4 TCGGGAAGGTCC na na Lib15 389.41 178.05 151, 151 243227188 36727286387 92.19 0.32 0.89 0.06 0.06 0.97 2.11 1.21 100 27532330327 8.78 3137161171 93 T15
4 CTCCGATCGTCC na na Lib16 404.6 189.15 151, 151 226971682 34272611454 92.19 0.32 0.97 0.06 0.06 0.98 2.3 1.21 100 25755587119 8.21 3137161171 93 T16
5 ATCTAGCCGGCC na na Lib17 377.45 175.64 151, 151 262110344 39578617505 91.74 0.35 0.94 0.06 0.06 1.18 2.29 1.26 100 28295604657 9.02 3137161171 93 T17
5 GCCTCGAAGTCC na na Lib18 390.52 186.33 151, 151 255439380 38571326444 92.41 0.35 0.93 0.06 0.06 1.11 2.3 1.24 100 28176385193 8.98 3137161171 93 T18
5 TCGGGAAGGTCC na na Lib19 384.09 178.29 151, 151 246301176 37191373174 92.13 0.35 0.91 0.06 0.06 1.01 2.15 1.25 100 27067104926 8.63 3137161171 93 T19
5 CTCCGATCGTCC na na Lib20 399.6 189.24 151, 151 229297100 34623839979 92.16 0.34 0.99 0.06 0.06 1.05 2.34 1.24 100 25315289382 8.07 3137161171 93 T20
6 CTCCGATCGTCC na na Lib21 399.79 187.64 151, 151 226406380 34187224251 92.14 0.36 1.03 0.06 0.06 1.01 2.31 1.21 100 25502118885 8.13 3137161171 93 T21
6 ATCTAGCCGGCC na na Lib22 377.95 173.58 151, 151 258628142 39052848619 91.74 0.36 1 0.06 0.06 1.11 2.36 1.23 100 28547020088 9.1 3137161171 93 T22
6 TCGGGAAGGTCC na na Lib23 386.48 178.16 151, 151 243040660 36699058535 92.14 0.36 0.96 0.06 0.06 1.03 2.13 1.22 100 27264861066 8.69 3137161171 93 T23
6 GCCTCGAAGTCC na na Lib24 393.02 184.94 151, 151 252419606 38115229911 92.38 0.36 0.99 0.06 0.06 1.09 2.33 1.22 100 28401642000 9.05 3137161171 93 T24
7 AAGCGTACGTCC na na Lib25 301.12 149.43 151, 151 988749818 149301208938 91.18 0.39 0.93 0.07 0.06 3.01 4.04 1.25 100 105042282719 33.48 3137161171 93 T25
8 TTTAGTCAGTCC na na Lib26 308.09 155.88 151, 151 1000300318 151045251998 92.15 0.4 0.87 0.06 0.06 2.13 3.11 1.24 100 109434035708 34.88 3137161171 93 T26