Skip to content

Commit

Permalink
Merge pull request #33 from natverse/feature/malecns-lineage
Browse files Browse the repository at this point in the history
Feature/malecns lineage
  • Loading branch information
jefferis authored Nov 14, 2024
2 parents 93310ea + f1667a3 commit 84df465
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
12 changes: 11 additions & 1 deletion R/cosine.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ multi_cosine_matrix <- function(x, partners, nas, group='type') {
#' @param drop_dataset_prefix Whether to remove dataset prefix such as
#' \code{hb:} or \code{fw:} from dendrograms. This is useful when reviewing
#' neurons in interactive mode.
#' @param keep.all.meta Whether to keep all meta data information for the query
#' neurons to allow for more flexible labelling of the dendrogram (default
#' \code{TRUE} for convenience, so not really clear why you would want to set
#' to \code{FALSE}). See the \code{keep.all} argument of \code{\link{cf_meta}}
#' for details.
#' @inheritParams cf_partners
#' @inheritParams neuprintr::neuprint_cosine_plot
#'
Expand Down Expand Up @@ -141,6 +146,10 @@ multi_cosine_matrix <- function(x, partners, nas, group='type') {
#' ## on the build server, but similar queries could be run for multiple datasets
#' cf_cosine_plot(cf_ids(flywire="/type:LAL.+", malecns="/type:LAL.+"))
#'
#' # we can use a range of dataset-specific columns to decorate labels
#' cf_cosine_plot(cf_ids(flywire="/type:LAL0.+", hemibrain="/type:LAL0.+"),
#' labRow = "{top_nt}")
#'
#' cf_cosine_plot(cf_ids("/type:LAL.+", datasets='brain'))
#' # same as since the default is brain
#' cf_cosine_plot(cf_ids("/type:LAL.+"))
Expand Down Expand Up @@ -228,6 +237,7 @@ cf_cosine_plot <- function(ids=NULL, ..., threshold=5,
matrix=FALSE,
interactive=FALSE,
drop_dataset_prefix=FALSE,
keep.all.meta=TRUE,
min_datasets=Inf,
nas=c('zero','drop'),
method=c("ward.D", "single", "complete", "average",
Expand All @@ -243,7 +253,7 @@ cf_cosine_plot <- function(ids=NULL, ..., threshold=5,
cm <- multi_cosine_matrix(x, partners = partners, group=group, nas=nas)

if(is.character(labRow) && length(labRow)==1 && any(grepl("\\{", labRow))) {
tm=cf_meta(colnames(cm))
tm=cf_meta(colnames(cm), keep.all = keep.all.meta)
labRow <- glue::glue_data(labRow, .x = tm)
} else if(is.character(labRow)) {
# user has supplied labels but they are unlikely to be in the correct order
Expand Down
7 changes: 5 additions & 2 deletions R/meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cf_meta <- function(ids, bind.rows=TRUE, integer64=FALSE, keep.all=FALSE,
if(is.data.frame(ids)) {
stopifnot(bind.rows)
ss=split(ids$id, ids$dataset)
res=cf_meta(ss, integer64 = integer64, MoreArgs = MoreArgs)
res=cf_meta(ss, integer64 = integer64, MoreArgs = MoreArgs, keep.all=keep.all)
res=res[match(keys(ids), res$key),,drop=F]
return(res)
}
Expand Down Expand Up @@ -147,7 +147,10 @@ malecns_meta <- function(ids, ...) {
rename(id=bodyid) %>%
rename(class1=superclass, class2=class, subsubclass=subclass) %>%
rename(class=class1, subclass=class2) %>%
rename(lineage=hemilineage)
mutate(lineage=case_when(
!is.na(itoleeHl) & nzchar(itoleeHl) ~ itoleeHl,
T ~ trumanHl
))
tres
}

Expand Down
11 changes: 11 additions & 0 deletions man/cf_cosine_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 84df465

Please sign in to comment.