flyconnectome/fancr

Error with cleft.threshold in fanc_partner_summary

Opened this issue · 6 comments

Running fanc_partner_summary with the cleft.threshold argument set to anything other than 0 returns the following error:

Error:
! Must subset rows with a valid subscript vector.
ℹ Logical subscripts must match the size of the indexed input.
x Input has size 12386 but subscript `res$cleft_score > cleft.threshold` has size 0.
Run `rlang::last_error()` to see where the error occurred.
Warning message:
Unknown or uninitialised column: `cleft_score`. 

Here's the output of rlang::last_trace() after running rlang::last_error()

<error/vctrs_error_subscript_size>
Error:
! Must subset rows with a valid subscript vector.
ℹ Logical subscripts must match the size of the indexed input.
x Input has size 12386 but subscript `res$cleft_score > cleft.threshold` has size 0.
---
Backtrace:
     ▆
  1. └─fancr::fanc_partner_summary(...)
  2.   ├─fancr::with_fanc(...)
  3.   │ └─base::force(expr)
  4.   └─fafbseg::flywire_partner_summary(...)
  5.     └─fafbseg:::flywire_partners_cave(...)
  6.       ├─res[res$cleft_score > cleft.threshold, , drop = FALSE]
  7.       └─tibble:::`[.tbl_df`(...)
  8.         └─tibble:::tbl_subset_row(xo, i = i, i_arg)
  9.           └─tibble:::vectbl_as_row_index(i, x, i_arg)
 10.             └─tibble:::vectbl_as_row_location(i, nr, i_arg, assign)
 11.               ├─tibble:::subclass_row_index_errors(...)
 12.               │ └─base::withCallingHandlers(...)
 13.               └─vctrs::vec_as_location(i, n)
 14.                 └─vctrs `<fn>`()
 15.                   └─vctrs:::stop_indicator_size(...)
 16.                     └─rlang::cnd_signal(new_error_subscript_size(i, n = n, ..., body = cnd_body_vctrs_error_indicator_size))

fanc_partner_summary runs without errors when the cleft.threshold argument is explicitly specified to be 0 in the function call or when it is not specified in the call and defaults to 0. The above error happens whenever cleft.threshold is set to a positive integer; negative values or non-integers fail the corresponding assertion statements and throw different errors.

Also, I've updated my installation for fafbseg and fancr, and the issue persists.

The issue seems to be the that there is no cleft score for FANC synapse data. You can filter synapses by score though. What would a good threshold be?

I have started to implement this in two branches, for fafbseg and for fancr.

If anyone else wants to finish implementing great - I ran out of time today, but will try to over weekend.

Thanks @yanghelenh. As Alex says there is no cleft.threshold information available for FANC. You could talk to @unidesigner about this. I left the implementation (which is inherited from FAFB) in the hope that it might one day be available.

@alexanderbates thanks for the work you mention re the plain connection_score. Unfortunately I have no indication that it does anything useful. For example I've looked there is no correlation between connection_score and cleft_score, but I know that high cleft_scores are predictive of true synapses. For example here are the input synapses onto a sample neuron (720575940621039145) plotted.
image

If I plot synapses above (green) and below (red) a cleft_score of 50 then you can clearly see a preponderance of red synapses in obviously incorrect places (eg the soma and axon shaft).
image

But I cannot find a connection_score that separates e.g. false synapses on the axon shaft from the arbours. You have generated a validated dataset with Imaan curating FAFB synapses so if you want to see if there is anything about connection_score that is predictive, I would be happy to hear it.

PS score in flywire_partners() = connection_score as returned by CAVE.

Thanks @jefferis and @alexanderbates for looking into this issue for me. It was clear from the error that cleft.threshold wasn't returning anything, but I didn't realize that it's because this information isn't available for FANC. I'll talk to @unidesigner about whether it could be implemented for FANC, or if there's some other way to filter the predicted synapses by confidence.

Hm... using the flywire_cave_query function of fafbseg to get a FANC neuron's output synapses returns a column called score, but unlike the connection_score, the values seem to range between 13 and 150ish with a mean around 30ish. It seems like the score for FANC predicted synapses might be its own thing.