diff --git a/R/datasets.R b/R/datasets.R index 5297101..e978122 100644 --- a/R/datasets.R +++ b/R/datasets.R @@ -23,6 +23,7 @@ match_datasets <- function(ds) { #' @examples #' abbreviate_datasets(c("flywire", "flywire", "hemibrain")) abbreviate_datasets <- function(ds) { + if(length(ds)<1) return(ds) ds=match_datasets(ds) abbrevlist=c(hemibrain='hb', flywire='fw', manc='mv', fanc='fv', malecns='mc', opticlobe='ol', banc='bc') diff --git a/R/partners.R b/R/partners.R index 745169c..4c95a7c 100644 --- a/R/partners.R +++ b/R/partners.R @@ -143,12 +143,22 @@ cf_partners <- function(ids, threshold=1L, partners=c("inputs", "outputs"), )) } tres=coconat:::standardise_partner_summary(tres) - tres$dataset=n + if(nrow(tres)>0) { + tres$dataset=n + } else { + tres$dataset=character() + warning("no ", partners, " found for `", n, "` dataset.") + } tres$pre_key=keys(tres, idcol="pre_id") tres$post_key=keys(tres, idcol='post_id') res[[n]]=tres } - if(isTRUE(bind.rows)) bind_rows2(res) else res + if(isTRUE(bind.rows)) { + res=bind_rows2(res) + # record the datasets we tried to find + attr(res, 'datasets')=names(ids) + res + } else res } diff --git a/tests/testthat/test-cosine.R b/tests/testthat/test-cosine.R index 3a1d1b4..06cd1ce 100644 --- a/tests/testthat/test-cosine.R +++ b/tests/testthat/test-cosine.R @@ -33,3 +33,15 @@ test_that("cosine plots work", { expect_equal(cf_cosine_plot(lalids, min_datasets = 1, heatmap = F), hc1))) }) + + +test_that("cosine plot with no partners", { + op <- options(fafbseg.use_static_celltypes=T) + on.exit(options(op)) + + suppressWarnings( + suppressMessages( + expect_warning(cf_cosine_plot(cf_ids(hemibrain = 'ORN_DA1', flywire = 'ORN_DA1'), threshold = 8), + "no inputs.*flywire") + )) +})