Skip to content

Commit 74c0b7a

Browse files
helper function to update IDs in seatable: banctable_updateids
1 parent 34798bf commit 74c0b7a

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

R/banc-table.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,18 +376,26 @@ banctable_updateids <- function(){
376376

377377
# Get cell info table
378378
cat('reading cell info cave table...')
379-
info <- banc_cell_info() %>%
379+
info <- banc_cell_info(rawcoords = TRUE) %>%
380+
dplyr::mutate(pt_position = xyzmatrix2str(pt_position)) %>%
380381
dplyr::select(pt_root_id, pt_supervoxel_id,pt_position) %>%
381382
rbind(banc_backbone_proofread() %>%
382-
dplyr::select(pt_root_id, pt_supervoxel_id,pt_position)) %>%
383+
dplyr::select(pt_root_id, pt_supervoxel_id,pt_position) %>%
384+
dplyr::mutate(pt_position = xyzmatrix2str(pt_position))) %>%
385+
rbind(banc_neck_connective_neurons() %>%
386+
dplyr::select(pt_root_id, pt_supervoxel_id,pt_position) %>%
387+
dplyr::mutate(pt_position = xyzmatrix2str(pt_position))) %>%
383388
dplyr::mutate(pt_root_id=as.character(pt_root_id),
384389
pt_supervoxel_id=as.character(pt_supervoxel_id)) %>%
385-
dplyr::distinct(pt_supervoxel_id, .keep_all = TRUE)
390+
dplyr::distinct(pt_supervoxel_id, .keep_all = TRUE) %>%
391+
dplyr::rowwise()
386392

387393
# Get current table
388394
cat('reading banc meta table...')
389395
bc <- banctable_query(sql = 'select _id, root_id, supervoxel_id, position from banc_meta') %>%
390396
dplyr::select(root_id, supervoxel_id, position, `_id`)
397+
bc[bc=="0"] <- NA
398+
bc[bc==""] <- NA
391399

392400
# Update
393401
bc.new <- bc %>%
@@ -398,8 +406,8 @@ banctable_updateids <- function(){
398406
dplyr::select(-pt_root_id,-pt_position)
399407

400408
# Update root IDs directly where needed
401-
bc.new.rup <- banc_updateids(bc.new)
402-
bc.new.rup.joined <- bc.new.rup %>%
409+
bc.new <- banc_updateids(bc.new)
410+
bc.new <- bc.new %>%
403411
dplyr::left_join(info %>% dplyr::distinct(pt_root_id, .keep_all = TRUE),
404412
by = c("root_id"="pt_root_id")) %>%
405413
dplyr::mutate(supervoxel_id = ifelse(is.na(supervoxel_id),pt_supervoxel_id,supervoxel_id)) %>%
@@ -408,6 +416,8 @@ banctable_updateids <- function(){
408416

409417
# Update
410418
cat('updating banc meta table...')
419+
bc.new[is.na(bc.new)] <- ''
420+
bc.new[bc.new=="0"] <- ''
411421
banctable_update_rows(df = bc.new,
412422
base = "banc_meta",
413423
table = "banc_meta",
@@ -417,7 +427,6 @@ banctable_updateids <- function(){
417427

418428
# Return
419429
invisible()
420-
421430
}
422431

423432

R/ids.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,17 @@ banc_updateids <- function(x, ...){
215215
old[!bad] <- FALSE
216216
}
217217

218-
# update based on position
219-
if(any(c("position","pt_position")%in%colnames(x)) && sum(old)){
220-
cat('updating root_ids with a position ...')
221-
pos.col <- intersect(c("position","pt_position"),colnames(x))[1]
222-
update <- unname(pbapply::pbsapply(x[old,][[pos.col]], banc_xyz2id, rawcoords = TRUE, ...))
223-
bad <- is.na(update)|update=="0"
224-
update <- update[!bad]
225-
x[old,][[root.col]][!bad] <- update
226-
old[!bad] <- FALSE
227-
}
228-
old[is.na(old)] <- TRUE
218+
# # update based on position
219+
# if(any(c("position","pt_position")%in%colnames(x)) && sum(old)){
220+
# cat('updating root_ids with a position ...')
221+
# pos.col <- intersect(c("position","pt_position"),colnames(x))[1]
222+
# update <- unname(pbapply::pbsapply(x[old,][[pos.col]], banc_xyz2id, rawcoords = TRUE, ...))
223+
# bad <- is.na(update)|update=="0"
224+
# update <- update[!bad]
225+
# x[old,][[root.col]][!bad] <- update
226+
# old[!bad] <- FALSE
227+
# }
228+
# old[is.na(old)] <- TRUE
229229

230230
}else{
231231
cat('updating root_ids directly')

0 commit comments

Comments
 (0)