Skip to content

Commit

Permalink
Helper function to quickly update IDs with supervoxels in seatable
Browse files Browse the repository at this point in the history
* bancr:::banctable_updateids
  • Loading branch information
alexanderbates committed Sep 4, 2024
1 parent 1d6b4d8 commit a060908
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions R/banc-table.R
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,41 @@ banc_update_status <- function(df, update, col = "status", wipe = FALSE){
# append_allowed = FALSE,
# chunksize = 100)

# Update the BANC IDs
banctable_updateids <- function(){

# Get cell info table
info <- banc_cell_info() %>%
dplyr::select(pt_root_id, pt_supervoxel_id) %>%
dplyr::mutate(pt_root_id=as.character(pt_root_id),
pt_supervoxel_id=as.character(pt_supervoxel_id)) %>%
dplyr::distinct(pt_supervoxel_id, .keep_all = TRUE)

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

# Update
bc.new <- bc %>%
dplyr::left_join(info,
by = c("supervoxel_id"="pt_supervoxel_id")) %>%
dplyr::mutate(root_id = ifelse(is.na(pt_root_id),root_id,pt_root_id)) %>%
dplyr::select(-pt_root_id)

# Update root IDs directly where needed
# bc.new <- banc_updateids(bc.new)

# Update
banctable_update_rows(df = bc.new,
base = "banc_meta",
table = "banc_meta",
append_allowed = FALSE,
chunksize = 1000)

# Return
invisible()

}



Expand Down

0 comments on commit a060908

Please sign in to comment.