@@ -175,13 +175,23 @@ fanc_meta <- function(ids=NULL, ...) {
175
175
df = fancr :: with_fanc(fancorbanc_meta(table = ' neuron_information' , ids = ids , ... ))
176
176
metaf = getOption(' coconatfly.fancmeta' )
177
177
if (! is.null(metaf )) {
178
- ext = tools :: file_ext( metaf )
179
- df2 = if ( ext == ' tsv ' ) {
180
- data.table :: fread (metaf , integer64 = ' character ' )
181
- } else if ( ext == ' feather ' ) {
182
- arrow :: read_feather( metaf )
183
- } else stop( " Unsupported extension: " , ext , " for FANC metadata file! " )
178
+ # we can use an unevaluated call as an option
179
+ # by evaluating we can trigger function
180
+ if (is.call (metaf ) )
181
+ metaf = eval( metaf )
182
+ else if (is.function( metaf ) )
183
+ metaf = metaf( )
184
184
185
+ df2 <- if (is.data.frame(metaf ))
186
+ metaf
187
+ else if (is.character(metaf )) {
188
+ ext = tools :: file_ext(metaf )
189
+ if (ext == ' tsv' ) {
190
+ data.table :: fread(metaf , integer64 = ' character' )
191
+ } else if (ext == ' feather' ) {
192
+ arrow :: read_feather(metaf )
193
+ } else stop(" Unsupported extension:" , ext , " for FANC metadata file!" )
194
+ } else stop(" options('coconatfly.fancmeta') must be path to a file, a function or an unevaluated R `call`." )
185
195
df2 $ root_id = fancr :: with_fanc(fafbseg :: flywire_updateids(df2 $ root_id , df2 $ supervoxel_id , version = fanc_version()))
186
196
df2 <- df2 | >
187
197
rename(id = root_id ) | >
0 commit comments