diff --git a/R/breakpointGraph.R b/R/breakpointGraph.R index c77da94..4833999 100644 --- a/R/breakpointGraph.R +++ b/R/breakpointGraph.R @@ -122,9 +122,10 @@ bp_count <- function(p_extended){ sum(abs(diff(p_extended)) != 1 ) } -#' Number of Cycles +#' Number of Non-Trivial Cycles #' -#' This function computes the number of cycles in a breakpoint graph. +#' This function computes the number of **non-trivial** cycles in a breakpoint graph. +#' Non-trivial cycles are cycles with more than 2 vertices, whereas trivial cycles are cycles with 2 vertices that represent common adjacencies. #' #' @param g The breakpoint graph. #' @@ -136,10 +137,30 @@ bp_count <- function(p_extended){ #' #' @family Breakpoint graph functions #' -cycle_count <- function(g){ +cycle_nontrivial_count <- function(g){ sum(components(g)$csize > 1) } +#' Number of Cycles +#' +#' This function computes the number of cycles (trivial and non-trivial) in a breakpoint graph. +#' Non-trivial cycles are cycles with more than 2 vertices, whereas trivial cycles are cycles with 2 vertices that represent common adjacencies. +#' +#' @param g The breakpoint graph. +#' +#' @return The number of cycles in a breakpoint graph. +#' +#' @importFrom igraph components +#' +#' @author Priscila Biller +#' +#' @family Breakpoint graph functions +#' +cycle_count <- function(g){ + isolated_vertices <- sum(degree(g) == 0) + cycle_nontrivial_count(g) + isolated_vertices/2 +} + #' Connected components #' #' Connected components of the breakpoint graph. @@ -542,7 +563,7 @@ is_fortress <- function(superhurdles){ #' @return A list containing the following properties of the breakpoint graph: #' 1. `N` : the total number of places where a breakpoint could occur (which is the same as the `number_aligned_blocks + 1`); #' 2. `nbBreakpoints` : the total number of breakpoints in the extended permutation; -#' 3. `nbCycles` : the total number of cycles in the breakpoint graph. +#' 3. `nbCycles` : the total number of cycles in the breakpoint graph (trivial and non-trivial cycles). #' #' @references Hannenhalli, Sridhar, and Pavel A. Pevzner. "Transforming cabbage into turnip: polynomial algorithm for sorting signed permutations by reversals." Journal of the ACM (JACM) 46.1 (1999): 1-27. #' diff --git a/R/inversionDistance.R b/R/inversionDistance.R index e5fc13d..c7e7ef4 100644 --- a/R/inversionDistance.R +++ b/R/inversionDistance.R @@ -71,6 +71,6 @@ inversionDistance <- function(x){ hurdles <- hurdles_count(bp_graph, p_extended) superhurdles <- superhurdles_count(hurdles, bp_graph, p_extended) - bp_count(p_extended) - cycle_count(bp_graph) + sum(hurdles$hurdle) + is_fortress(superhurdles) + bp_count(p_extended) - cycle_nontrivial_count(bp_graph) + sum(hurdles$hurdle) + is_fortress(superhurdles) } diff --git a/man/bp_count.Rd b/man/bp_count.Rd index 84f92c4..2aa4770 100644 --- a/man/bp_count.Rd +++ b/man/bp_count.Rd @@ -21,6 +21,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, diff --git a/man/breakpointGraphProperties.Rd b/man/breakpointGraphProperties.Rd index 568ea98..b40ae63 100644 --- a/man/breakpointGraphProperties.Rd +++ b/man/breakpointGraphProperties.Rd @@ -13,7 +13,7 @@ breakpointGraphProperties(gb) A list containing the following properties of the breakpoint graph: 1. \code{N} : the total number of places where a breakpoint could occur (which is the same as the \code{number_aligned_blocks + 1}); 2. \code{nbBreakpoints} : the total number of breakpoints in the extended permutation; -3. \code{nbCycles} : the total number of cycles in the breakpoint graph. +3. \code{nbCycles} : the total number of cycles in the breakpoint graph (trivial and non-trivial cycles). } \description{ Computes the breakpoint graph of a pair of chromosomes @@ -29,6 +29,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, diff --git a/man/breakpoint_graph.Rd b/man/breakpoint_graph.Rd index a6021ea..340ad62 100644 --- a/man/breakpoint_graph.Rd +++ b/man/breakpoint_graph.Rd @@ -24,6 +24,7 @@ Other Breakpoint graph functions: \code{\link[=breakpointGraphProperties]{breakpointGraphProperties()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, diff --git a/man/components_graph.Rd b/man/components_graph.Rd index f94e5c6..8089747 100644 --- a/man/components_graph.Rd +++ b/man/components_graph.Rd @@ -23,6 +23,7 @@ Other Breakpoint graph functions: \code{\link[=breakpointGraphProperties]{breakpointGraphProperties()}}, \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, diff --git a/man/cycle_count.Rd b/man/cycle_count.Rd index 4093960..4998db3 100644 --- a/man/cycle_count.Rd +++ b/man/cycle_count.Rd @@ -13,7 +13,8 @@ cycle_count(g) The number of cycles in a breakpoint graph. } \description{ -This function computes the number of cycles in a breakpoint graph. +This function computes the number of cycles (trivial and non-trivial) in a breakpoint graph. +Non-trivial cycles are cycles with more than 2 vertices, whereas trivial cycles are cycles with 2 vertices that represent common adjacencies. } \seealso{ Other Breakpoint graph functions: @@ -21,6 +22,7 @@ Other Breakpoint graph functions: \code{\link[=breakpointGraphProperties]{breakpointGraphProperties()}}, \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, @@ -28,6 +30,6 @@ Other Breakpoint graph functions: \code{\link[=superhurdles_count]{superhurdles_count()}} } \author{ -Bruna Fistarol +Priscila Biller } \concept{Breakpoint graph functions} diff --git a/man/cycle_nontrivial_count.Rd b/man/cycle_nontrivial_count.Rd new file mode 100644 index 0000000..f344781 --- /dev/null +++ b/man/cycle_nontrivial_count.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/breakpointGraph.R +\name{cycle_nontrivial_count} +\alias{cycle_nontrivial_count} +\title{Number of Non-Trivial Cycles} +\usage{ +cycle_nontrivial_count(g) +} +\arguments{ +\item{g}{The breakpoint graph.} +} +\value{ +The number of cycles in a breakpoint graph. +} +\description{ +This function computes the number of \strong{non-trivial} cycles in a breakpoint graph. +Non-trivial cycles are cycles with more than 2 vertices, whereas trivial cycles are cycles with 2 vertices that represent common adjacencies. +} +\seealso{ +Other Breakpoint graph functions: +\code{\link[=bp_count]{bp_count()}}, +\code{\link[=breakpointGraphProperties]{breakpointGraphProperties()}}, +\code{\link[=breakpoint_graph]{breakpoint_graph()}}, +\code{\link[=components_graph]{components_graph()}}, +\code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=extendedPermutation]{extendedPermutation()}}, +\code{\link[=hurdles_count]{hurdles_count()}}, +\code{\link[=is_fortress]{is_fortress()}}, +\code{\link[=is_interleaving]{is_interleaving()}}, +\code{\link[=superhurdles_count]{superhurdles_count()}} +} +\author{ +Bruna Fistarol +} +\concept{Breakpoint graph functions} diff --git a/man/extendedPermutation.Rd b/man/extendedPermutation.Rd index 67d8b03..be1cd8d 100644 --- a/man/extendedPermutation.Rd +++ b/man/extendedPermutation.Rd @@ -24,6 +24,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, \code{\link[=is_interleaving]{is_interleaving()}}, diff --git a/man/hurdles_count.Rd b/man/hurdles_count.Rd index ff898fc..a0a2ca5 100644 --- a/man/hurdles_count.Rd +++ b/man/hurdles_count.Rd @@ -21,6 +21,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=is_fortress]{is_fortress()}}, \code{\link[=is_interleaving]{is_interleaving()}}, diff --git a/man/is_fortress.Rd b/man/is_fortress.Rd index b27c768..6cd90ff 100644 --- a/man/is_fortress.Rd +++ b/man/is_fortress.Rd @@ -20,6 +20,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_interleaving]{is_interleaving()}}, diff --git a/man/is_interleaving.Rd b/man/is_interleaving.Rd index 312016e..55cabab 100644 --- a/man/is_interleaving.Rd +++ b/man/is_interleaving.Rd @@ -27,6 +27,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}}, diff --git a/man/superhurdles_count.Rd b/man/superhurdles_count.Rd index 0f9a5e5..018ec84 100644 --- a/man/superhurdles_count.Rd +++ b/man/superhurdles_count.Rd @@ -23,6 +23,7 @@ Other Breakpoint graph functions: \code{\link[=breakpoint_graph]{breakpoint_graph()}}, \code{\link[=components_graph]{components_graph()}}, \code{\link[=cycle_count]{cycle_count()}}, +\code{\link[=cycle_nontrivial_count]{cycle_nontrivial_count()}}, \code{\link[=extendedPermutation]{extendedPermutation()}}, \code{\link[=hurdles_count]{hurdles_count()}}, \code{\link[=is_fortress]{is_fortress()}},