Skip to content
Open
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
3 changes: 2 additions & 1 deletion R/gGnome.R
Original file line number Diff line number Diff line change
Expand Up @@ -5824,7 +5824,8 @@ gGraph = R6::R6Class("gGraph",
## remove zero or NA weight loose ends
loose.ed = loose.ed[!is.na(weight), ][weight>0, ]
## add cid values for loose ends
loose.ed[, (cid.field) := 1:.N + nrow(ed)]
max.cid = max(ed[, get(cid.field)], na.rm = T)
loose.ed[, (cid.field) := 1:.N + max.cid]
loose.ed[, class := '']

if (!is.null(annotations))
Expand Down
224 changes: 217 additions & 7 deletions R/jsUtils.R

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions inst/extdata/anatomy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"sample": "mypair",
"x": 0.33634716658325137,
"y": 0.22019120743756065
},
{
"sample": "mypair2",
"x": 0.4075275393996103,
"y": 0.2523906292502009
},
{
"sample": "J",
"x": 0.367271614907495,
"y": 0.2732773509729865
},
{
"sample": "K",
"x": 0.3412517649786515,
"y": 0.3080960805908625
},
{
"sample": "D",
"x": 0.5376586370853564,
"y": 0.3359488062611934
},
{
"sample": "I",
"x": 0.608870857943244,
"y": 0.33419883768441944
},
{
"sample": "E",
"x": 0.4664782642689975,
"y": 0.3516082024933575
},
{
"sample": "F",
"x": 0.32899026899015116,
"y": 0.3707562457592193
},
{
"sample": "G",
"x": 0.4198208834296392,
"y": 0.3803302673921502
},
{
"sample": "A",
"x": 0.5303017394922562,
"y": 0.4299390540137285
},
{
"sample": "L",
"x": 0.8912037460940367,
"y": 0.5039119192719399
},
{
"sample": "B",
"x": 0.5401109362830565,
"y": 0.5065312270771757
}
]
Binary file added inst/extdata/figure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions inst/extdata/figure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions inst/extdata/template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion tests/testthat/test_jsUtils.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ bad.kag = list(not_segstats = '')
bad.kag.fn = paste0(tmpdir, '/bad-kag.rds')
saveRDS(bad.kag, bad.kag.fn)

myfigure = system.file('extdata', 'figure.png', package="gGnome")
mycoord = system.file('extdata', 'anatomy.json', package="gGnome")

js_data = data.table(sample = 'mypair', coverage = cov.fn, graph = gg.rds, kag = kag.fn, bad.kag = bad.kag.fn)
test_that('gen_js_instance', {

Expand Down Expand Up @@ -131,6 +134,10 @@ test_that('gen_js_instance', {
annotation = NULL,
ncn.gr = ncn.gr,
dataset_name = 'test',
figure = myfigure,
coordinates = mycoord,
nfields = 'eslack.out',
efields = 'tier'
)

# test adding more data and also test what happens when the cov.field is NA (we expect a warning about skipping the coverage generation)
Expand All @@ -145,7 +152,7 @@ test_that('gen_js_instance', {
dataset_name = 'test',
))

# re-run without adding a new samples, but with adding tree (so should just update the datafiles)
# re-run without adding new samples, but with adding tree (so should just update the datafiles)
# also adding connections.associations
pgv(data.table(sample = 'mypair2', coverage = cov.fn, graph = gg.rds),
outdir = paste0(tmpdir, '/PGV'),
Expand Down Expand Up @@ -194,6 +201,8 @@ test_that('gen_js_instance', {
dataset_name = 'test'
))

# test invalid png
expect_error(png2pgv('no-such-file'))

})

Expand Down