Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: use fanc meta from neck connective repo #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Imports:
magrittr,
bit64,
usethis,
data.table,
methods
Suggests:
malevnc (> 0.3.1),
Expand Down
34 changes: 33 additions & 1 deletion R/meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,39 @@

fanc_meta <- function(ids=NULL, ...) {
ids=fanc_ids(ids)
fancr::with_fanc(fancorbanc_meta(table='neuron_information', ids=ids, ...))
df=fancr::with_fanc(fancorbanc_meta(table='neuron_information', ids=ids, ...))
metaf=getOption('coconatfly.fanc_meta')
if(!is.null(metaf)) {
# we can use an unevaluated call as an option
# by evaluating we can trigger function
if(is.call(metaf))
metaf=eval(metaf)

Check warning on line 181 in R/meta.R

View check run for this annotation

Codecov / codecov/patch

R/meta.R#L181

Added line #L181 was not covered by tests
else if(is.function(metaf))
metaf=metaf()

df2 <- if(is.data.frame(metaf))
metaf
else if(is.character(metaf)) {
ext=tools::file_ext(metaf)
if(ext=='tsv') {
data.table::fread(metaf, integer64 = 'character')
} else if(ext=='feather') {
arrow::read_feather(metaf)
} else stop("Unsupported extension:", ext, " for FANC metadata file!")

Check warning on line 193 in R/meta.R

View check run for this annotation

Codecov / codecov/patch

R/meta.R#L188-L193

Added lines #L188 - L193 were not covered by tests
} else stop("options('coconatfly.fancmeta') must be path to a file, a function or an unevaluated R `call`.")
df2$root_id=fancr::with_fanc(fafbseg::flywire_updateids(df2$root_id, df2$supervoxel_id, version = fanc_version()))
df2 <- df2 |>
rename(id=root_id) |>
select(-supervoxel_id, -cell_id)
df=dplyr::bind_rows(df2, df)
df <- df |>
filter(!duplicated(id))
if(length(ids)>0) {
df <- left_join(data.frame(id=ids), df, by='id')
}
}
df$side=sub("HS|idline$", "", df$side)
df
}

banc_meta <- function(ids=NULL, ...) {
Expand Down
10 changes: 10 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.onLoad <- function(libname, pkgname) {
# set up experimental extra
coconatfly.fanc_meta=getOption('coconatfly.fanc_meta')
if(is.null(coconatfly.fanc_meta)) {
options(coconatfly.fanc_meta=function() {
fafbseg::flywire_sirepo_file_memo('https://github.com/flyconnectome/2023neckconnective/blob/dev/data/fanc-neckconnective-anns.tsv', read=TRUE)

Check warning on line 6 in R/zzz.R

View check run for this annotation

Codecov / codecov/patch

R/zzz.R#L3-L6

Added lines #L3 - L6 were not covered by tests
})
}
invisible()

Check warning on line 9 in R/zzz.R

View check run for this annotation

Codecov / codecov/patch

R/zzz.R#L9

Added line #L9 was not covered by tests
}
Loading