Skip to content

Commit

Permalink
Extra checks for bridging_graph arguments
Browse files Browse the repository at this point in the history
* closes #42
  • Loading branch information
jefferis committed Apr 16, 2020
1 parent c968edd commit 8896489
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions R/transformation.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,23 @@ allreg_dataframe<-function(regdirs=getOption('nat.templatebrains.regdirs')) {
#' @param reciprocal Sets the weight of reciprocal edges in the graph (and
#' thereby whether inverse registrations will be considered).
#' @inheritParams allreg_dataframe
#' @seealso \code{\link{allreg_dataframe}}
#' @seealso \code{\link{allreg_dataframe}}, \code{\link{xform_brain}}
#' @export
#' @importFrom igraph E E<- graph.edgelist
#' @examples
#' \dontrun{
#' plot(bridging_graph(), vertex.size=25, edge.arrow.size=0.5)
#' # with reciprocal edges
#' plot(bridging_graph(reciprocal=3), vertex.size=25)
#' # the same including
#' plot(bridging_graph(), vertex.size=25)
#' }
bridging_graph <- function(regdirs=getOption('nat.templatebrains.regdirs'), reciprocal=NA) {
df=allreg_dataframe(regdirs)
if(nrow(df)==0) return(NULL)
# just keep the bridging registrations

if(!is.na(reciprocal) && (!is.numeric(reciprocal) || !is.finite(reciprocal)))
stop("reciprocal must be NA or specify the weight for reverse edges!")

df=df[df$bridge & !df$dup,]
el=as.matrix(df[,c("sample","reference")])
if(is.na(reciprocal)){
Expand Down
6 changes: 3 additions & 3 deletions man/shortest_bridging_seq.Rd

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

0 comments on commit 8896489

Please sign in to comment.