Skip to content

Commit a060908

Browse files
Helper function to quickly update IDs with supervoxels in seatable
* bancr:::banctable_updateids
1 parent 1d6b4d8 commit a060908

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

R/banc-table.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,41 @@ banc_update_status <- function(df, update, col = "status", wipe = FALSE){
371371
# append_allowed = FALSE,
372372
# chunksize = 100)
373373

374+
# Update the BANC IDs
375+
banctable_updateids <- function(){
374376

377+
# Get cell info table
378+
info <- banc_cell_info() %>%
379+
dplyr::select(pt_root_id, pt_supervoxel_id) %>%
380+
dplyr::mutate(pt_root_id=as.character(pt_root_id),
381+
pt_supervoxel_id=as.character(pt_supervoxel_id)) %>%
382+
dplyr::distinct(pt_supervoxel_id, .keep_all = TRUE)
375383

384+
# Get current table
385+
bc <- banctable_query() %>%
386+
dplyr::select(root_id, supervoxel_id, `_id`)
376387

388+
# Update
389+
bc.new <- bc %>%
390+
dplyr::left_join(info,
391+
by = c("supervoxel_id"="pt_supervoxel_id")) %>%
392+
dplyr::mutate(root_id = ifelse(is.na(pt_root_id),root_id,pt_root_id)) %>%
393+
dplyr::select(-pt_root_id)
377394

395+
# Update root IDs directly where needed
396+
# bc.new <- banc_updateids(bc.new)
397+
398+
# Update
399+
banctable_update_rows(df = bc.new,
400+
base = "banc_meta",
401+
table = "banc_meta",
402+
append_allowed = FALSE,
403+
chunksize = 1000)
404+
405+
# Return
406+
invisible()
407+
408+
}
378409

379410

380411

0 commit comments

Comments
 (0)