Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: natverse/coconatfly
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d6d0da1b4420e526890c1590f1ea0c9f6aafd935
Choose a base ref
..
head repository: natverse/coconatfly
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 895549d3ca7438879ee4646d4369c7c789b0742d
Choose a head ref
Showing with 118 additions and 56 deletions.
  1. +1 −1 DESCRIPTION
  2. +16 −0 NEWS.md
  3. +1 −0 R/datasets.R
  4. +4 −0 R/meta.R
  5. +19 −4 R/partners.R
  6. +17 −7 README.Rmd
  7. +48 −44 README.md
  8. +12 −0 tests/testthat/test-cosine.R
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: coconatfly
Type: Package
Title: Comparative Connectomics of Public and In Progress Drosophila Datasets
Version: 0.2.2
Version: 0.2.3.9000
Authors@R:
c(person(given = "Gregory",
family = "Jefferis",
16 changes: 16 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# coconatfly (development version)

* warn but still complete without errors when there are no partners at all for
inputs or ouptuts in `cf_partners()`. An example of when this happens is when
running `cf_cosine_plot()` for sensory neurons where all the inputs are below
threshold. #36

# coconatfly 0.2.3

* empty query fixes for all keys and banc metadata by @jefferis in https://github.com/natverse/coconatfly/pull/34
* Fix malecns class in `cf_partners()` by @jefferis in https://github.com/natverse/coconatfly/pull/35
* also support for rootSide in malecns in #35

**Full Changelog**: https://github.com/natverse/coconatfly/compare/v0.2.2...v0.2.3


# coconatfly 0.2.2

* support malecns superclass/class/subclass change. To stay backward compatible
1 change: 1 addition & 0 deletions R/datasets.R
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ match_datasets <- function(ds) {
#' @examples
#' abbreviate_datasets(c("flywire", "flywire", "hemibrain"))
abbreviate_datasets <- function(ds) {
if(length(ds)<1) return(ds)
ds=match_datasets(ds)
abbrevlist=c(hemibrain='hb', flywire='fw', manc='mv', fanc='fv', malecns='mc',
opticlobe='ol', banc='bc')
4 changes: 4 additions & 0 deletions R/meta.R
Original file line number Diff line number Diff line change
@@ -136,6 +136,10 @@ malecns_meta <- function(ids, ...) {
tres=malecns::mcns_neuprint_meta(ids)
tres <- tres %>%
mutate(side=malecns::mcns_soma_side(.)) %>%
mutate(side=case_when(
is.na(side) ~ rootSide,
T ~ side
)) %>%
mutate(pgroup=malecns::mcns_predict_group(.)) %>%
mutate(ptype=malecns::mcns_predict_type(.)) %>%
rename(otype=type, type=ptype, ogroup=group, group=pgroup) %>%
23 changes: 19 additions & 4 deletions R/partners.R
Original file line number Diff line number Diff line change
@@ -100,15 +100,20 @@ cf_partners <- function(ids, threshold=1L, partners=c("inputs", "outputs"),
chunk = neuprint.chunksize)
tres=do.call(malecns::mcns_connection_table, c(args, ma1))
# nb the type information we care about here is for partners
tres2=tres %>% dplyr::select(partner, type, name) %>% dplyr::rename(bodyid=partner)
tres2=tres %>%
dplyr::select(partner, type, name) %>%
dplyr::rename(bodyid=partner)

tres$type <- do.call(malecns::mcns_predict_type,
c(list(ids=tres2), ma2))
# set the soma side either from manually reviewed data
tres <- tres %>%
dplyr::mutate(side=dplyr::case_when(
!is.na(somaSide) & somaSide!='NA' & somaSide!='' ~ somaSide,
T ~ malecns::mcns_soma_side(., method = "instance")
))
)) |>
rename(class=superclass)

} else if (n=='fanc') {
args=list(fanc_ids(ids[[n]]),
partners = partners,
@@ -138,12 +143,22 @@ cf_partners <- function(ids, threshold=1L, partners=c("inputs", "outputs"),
))
}
tres=coconat:::standardise_partner_summary(tres)
tres$dataset=n
if(nrow(tres)>0) {
tres$dataset=n
} else {
tres$dataset=character()
warning("no ", partners, " found for `", n, "` dataset.")
}
tres$pre_key=keys(tres, idcol="pre_id")
tres$post_key=keys(tres, idcol='post_id')
res[[n]]=tres
}
if(isTRUE(bind.rows)) bind_rows2(res) else res
if(isTRUE(bind.rows)) {
res=bind_rows2(res)
# record the datasets we tried to find
attr(res, 'datasets')=names(ids)
res
} else res
}


24 changes: 17 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@ knitr::opts_chunk$set(
fig.path = "man/figures/README-",
out.width = "100%"
)
# use released flywire cell types even if you have access to in progress
# information
options(fafbseg.use_static_celltypes = TRUE)
```


@@ -62,15 +65,22 @@ anticipated late 2024.

## Installation

You can install the development version of **coconatfly** like so:
We recommend installing the latest version of **coconatfly** from github like so:

``` r
```{r eval=FALSE}
install.packages('natmanager')
natmanager::install(pkgs = 'coconatfly')
```

Some of the datasets exposed by **coconatfly** require authentication for access or
are still being annotated in private pre-release. Please consult individual
but you may also choose a specific
[released version](https://github.com/natverse/coconatfly/releases)
for enhanced reproducibility:
```{r eval=FALSE}
natmanager::install(pkgs = 'coconatfly@v0.2.2')
```

Some of the datasets exposed by **coconatfly** require authentication for access
or are still being annotated in private pre-release. Please consult individual
package dependencies for authentication details and do not be surprised if you
do not have access to all datasets at this time.

@@ -96,7 +106,7 @@ library(dplyr)

Two important functions are `cf_ids()` which allows you to specify a set of
neurons from one or more datasets and `cf_meta()` which fetches information
about the cell type.
about each neuron including its cell type.
For example let's fetch information about DA1 projection neurons:

```{r}
@@ -191,7 +201,7 @@ cell type of two cells / hemisphere (i.e. they should not have been split into
two cell types in the hemibrain).

You can also see that cells from one hemibrain hemisphere often cluster slightly
oddly (e.g. 387687146) - this is likely due to truncation of the axons or dendrites of these cells
oddly (e.g. `387687146`) - this is likely due to truncation of the axons or dendrites of these cells
or a paucity of partners from the left hand side of the hemibrain.

## Going further
@@ -208,7 +218,7 @@ In addition in order to justify continued development of natverse tools in gener
coconatfly in particular, we would appreciate two citations for

* For the natverse: [Bates et al eLife 2020](https://doi.org/10.7554/eLife.53350)
* For coconatfly: [Schlegel et al bioRxiv 2023](https://doi.org/10.1101/2023.06.27.546055)
* For coconatfly: [Schlegel et al Nature 2024](https://doi.org/10.1038/s41586-024-07686-5)

Should you make significant use of natverse packages in your paper
(e.g. multiple panels or >1 figure), we would also strongly
92 changes: 48 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -60,13 +60,22 @@ anticipated late 2024.

## Installation

You can install the development version of **coconatfly** like so:
We recommend installing the latest version of **coconatfly** from github
like so:

``` r
install.packages('natmanager')
natmanager::install(pkgs = 'coconatfly')
```

but you may also choose a specific [released
version](https://github.com/natverse/coconatfly/releases) for enhanced
reproducibility:

``` r
natmanager::install(pkgs = 'coconatfly@v0.2.2')
```

Some of the datasets exposed by **coconatfly** require authentication
for access or are still being annotated in private pre-release. Please
consult individual package dependencies for authentication details and
@@ -97,8 +106,8 @@ library(dplyr)

Two important functions are `cf_ids()` which allows you to specify a set
of neurons from one or more datasets and `cf_meta()` which fetches
information about the cell type. For example let’s fetch information
about DA1 projection neurons:
information about each neuron including its cell type. For example let’s
fetch information about DA1 projection neurons:

``` r
cf_meta(cf_ids('DA1_lPN', datasets = 'hemibrain'))
@@ -110,47 +119,44 @@ cf_meta(cf_ids('DA1_lPN', datasets = 'hemibrain'))
#> 5 722817260 701 2435 2435 5635 Traced Roughly traced 1104413432
#> 6 754534424 646 2364 2364 5309 Traced Roughly traced 1265805547
#> 7 754538881 623 2320 2320 4867 Traced Roughly traced 1217284590
#> cropped instance type lineage notes soma side class group dataset
#> 1 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> hemibrain
#> 2 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> hemibrain
#> 3 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> hemibrain
#> 4 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> FALSE R <NA> <NA> hemibrain
#> 5 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> FALSE R <NA> <NA> hemibrain
#> 6 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> hemibrain
#> 7 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> hemibrain
#> key
#> 1 hb:1734350788
#> 2 hb:1734350908
#> 3 hb:1765040289
#> 4 hb:5813039315
#> 5 hb:722817260
#> 6 hb:754534424
#> 7 hb:754538881
#> cropped instance type lineage notes soma side class subclass subsubclass
#> 1 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> <NA>
#> 2 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> <NA>
#> 3 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> <NA>
#> 4 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> FALSE R <NA> <NA> <NA>
#> 5 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> FALSE R <NA> <NA> <NA>
#> 6 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> <NA>
#> 7 FALSE DA1_lPN_R DA1_lPN AVM02 <NA> TRUE R <NA> <NA> <NA>
#> group dataset key
#> 1 <NA> hemibrain hb:1734350788
#> 2 <NA> hemibrain hb:1734350908
#> 3 <NA> hemibrain hb:1765040289
#> 4 <NA> hemibrain hb:5813039315
#> 5 <NA> hemibrain hb:722817260
#> 6 <NA> hemibrain hb:754534424
#> 7 <NA> hemibrain hb:754538881
```

We can also do that for multiple brain datasets

``` r
da1meta <- cf_meta(cf_ids('DA1_lPN', datasets = c('hemibrain', 'flywire')))
#> Updating 6641 ids
#> flywire_rootid_cached: Looking up 6641 missing keys
#> Updating 5480 ids
#> flywire_rootid_cached: Looking up 5480 missing keys
#> Loading required namespace: git2r
head(da1meta)
#> id side class type lineage group instance dataset
#> 1 720575940604407468 R central DA1_lPN ALl1_ventral <NA> DA1_lPN_R flywire
#> 2 720575940623543881 R central DA1_lPN ALl1_ventral <NA> DA1_lPN_R flywire
#> 3 720575940637469254 R central DA1_lPN ALl1_ventral <NA> DA1_lPN_R flywire
#> 4 720575940614309535 L central DA1_lPN ALl1_ventral <NA> DA1_lPN_L flywire
#> 5 720575940617229632 R central DA1_lPN ALl1_ventral <NA> DA1_lPN_R flywire
#> 6 720575940619385765 L central DA1_lPN ALl1_ventral <NA> DA1_lPN_L flywire
#> key
#> 1 fw:720575940604407468
#> 2 fw:720575940623543881
#> 3 fw:720575940637469254
#> 4 fw:720575940614309535
#> 5 fw:720575940617229632
#> 6 fw:720575940619385765
#> id side class subclass subsubclass type lineage
#> 1 720575940604407468 R central ALPN uniglomerular DA1_lPN ALl1_ventral
#> 2 720575940623543881 R central ALPN uniglomerular DA1_lPN ALl1_ventral
#> 3 720575940637469254 R central ALPN uniglomerular DA1_lPN ALl1_ventral
#> 4 720575940614309535 L central ALPN uniglomerular DA1_lPN ALl1_ventral
#> 5 720575940617229632 R central ALPN uniglomerular DA1_lPN ALl1_ventral
#> 6 720575940619385765 L central ALPN uniglomerular DA1_lPN ALl1_ventral
#> group instance dataset key
#> 1 <NA> DA1_lPN_R flywire fw:720575940604407468
#> 2 <NA> DA1_lPN_R flywire fw:720575940623543881
#> 3 <NA> DA1_lPN_R flywire fw:720575940637469254
#> 4 <NA> DA1_lPN_L flywire fw:720575940614309535
#> 5 <NA> DA1_lPN_R flywire fw:720575940617229632
#> 6 <NA> DA1_lPN_L flywire fw:720575940619385765
```

``` r
@@ -275,10 +281,8 @@ seems to work very well for this purpose.

``` r
cf_cosine_plot(cf_ids('/type:LAL0(08|09|10|42)', datasets = c("flywire", "hemibrain")))
#> Updating 6641 ids
#> Updating 5480 ids
#> Matching types across datasets. Dropping 510/1052 output partner types with total weight 9007/24134
#> Matching types across datasets. Dropping 793/1493 input partner types with total weight 11121/27588
#> Matching types across datasets. Keeping 542/1052 output connections with total weight 15127/24134 (63%)
#> Matching types across datasets. Keeping 700/1493 input connections with total weight 16467/27588 (60%)
```

<img src="man/figures/README-lal-cosine-cluster-1.png" width="100%" />
@@ -293,7 +297,7 @@ constitute a single cell type of two cells / hemisphere (i.e. they
should not have been split into two cell types in the hemibrain).

You can also see that cells from one hemibrain hemisphere often cluster
slightly oddly (e.g. 387687146) - this is likely due to truncation of
slightly oddly (e.g. `387687146`) - this is likely due to truncation of
the axons or dendrites of these cells or a paucity of partners from the
left hand side of the hemibrain.

@@ -313,8 +317,8 @@ we would appreciate two citations for

- For the natverse: [Bates et al eLife
2020](https://doi.org/10.7554/eLife.53350)
- For coconatfly: [Schlegel et al bioRxiv
2023](https://doi.org/10.1101/2023.06.27.546055)
- For coconatfly: [Schlegel et al Nature
2024](https://doi.org/10.1038/s41586-024-07686-5)

Should you make significant use of natverse packages in your paper
(e.g. multiple panels or \>1 figure), we would also strongly appreciate
12 changes: 12 additions & 0 deletions tests/testthat/test-cosine.R
Original file line number Diff line number Diff line change
@@ -33,3 +33,15 @@ test_that("cosine plots work", {
expect_equal(cf_cosine_plot(lalids, min_datasets = 1, heatmap = F),
hc1)))
})


test_that("cosine plot with no partners", {
op <- options(fafbseg.use_static_celltypes=T)
on.exit(options(op))

suppressWarnings(
suppressMessages(
expect_warning(cf_cosine_plot(cf_ids(hemibrain = 'ORN_DA1', flywire = 'ORN_DA1'), threshold = 8),
"no inputs.*flywire")
))
})