Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lgatto committed Oct 28, 2024
1 parent f2b7063 commit 212d879
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 17 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: PSMatch
Title: Handling and Managing Peptide Spectrum Matches
Version: 1.9.0
Version: 1.9.1
Authors@R:
c(person(given = "Laurent", family = "Gatto",
email = "[email protected]",
Expand Down Expand Up @@ -54,7 +54,7 @@ Suggests:
License: Artistic-2.0
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
VignetteBuilder: knitr
BugReports: https://github.com/RforMassSpectrometry/PSM/issues
URL: https://github.com/RforMassSpectrometry/PSM
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ importFrom(igraph,V)
importFrom(igraph,cluster_louvain)
importFrom(igraph,components)
importFrom(igraph,graph_from_adjacency_matrix)
importFrom(igraph,graph_from_incidence_matrix)
importFrom(igraph,graph_from_biadjacency_matrix)
importFrom(igraph,groups)
importFrom(igraph,layout_nicely)
importFrom(igraph,modularity)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# PSMatch 1.9

## PSMatch 1.9.1

- Fix check errors.

## PSMatch 1.9.0

- New Bioc devel.

# PSMatch 1.7

## PSMatch 1.7.2
Expand Down
2 changes: 1 addition & 1 deletion R/ConnectedComponent-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ prioritiseConnectedComponents <- function(x) {
## community metrics
com_metrics <- t(vapply(cc_x,
function(xx) {
g <- graph_from_incidence_matrix(xx)
g <- graph_from_biadjacency_matrix(xx)
com <- cluster_louvain(g)
c(n_coms = length(com),
mod_coms = modularity(com))
Expand Down
4 changes: 2 additions & 2 deletions R/adjacencyMatrix-plot.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##' @importFrom igraph layout_nicely graph_from_incidence_matrix V V<- plot.igraph set_vertex_attr
##' @importFrom igraph layout_nicely graph_from_biadjacency_matrix V V<- plot.igraph set_vertex_attr
##'
##' @export
##'
Expand Down Expand Up @@ -37,7 +37,7 @@ plotAdjacencyMatrix <- function(m,
protColors = 0,
pepColors = NULL,
layout = igraph::layout_nicely) {
g <- graph_from_incidence_matrix(m)
g <- graph_from_biadjacency_matrix(m)
if (is.character(protColors)) {
## Expecting a named vector of colour characters
if (is.null(names(protColors)))
Expand Down
25 changes: 25 additions & 0 deletions man/PSMatch.Rd

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

23 changes: 12 additions & 11 deletions tests/testthat/test_ConnectedComponents.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,36 @@ test_that("ConnectedComponents works from PSM", {


test_that("prioritiseConnectedComponents() works", {
set.seed(1)
cc <- ConnectedComponents(adj)
set.seed(1)
p1 <- prioritiseConnectedComponents(cc)
set.seed(1)
p2 <- prioritizeConnectedComponents(cc)
expect_identical(p1, p2)
## Check CC 4
cc_i <- connectedComponents(cc, 4)
expect_equal(p1["4", "ncol"], ncol(cc_i))
expect_equal(p1["4", "nrow"], nrow(cc_i))
expect_identical(p1["4", "n"], sum(cc_i))
expect_identical(p1["4", "rs_min"], min(rowSums(cc_i)))
expect_identical(p1["4", "rs_max"], max(rowSums(cc_i)))
expect_identical(p1["4", "cs_min"], min(colSums(cc_i)))
expect_identical(p1["4", "cs_max"], max(colSums(cc_i)))
expect_identical(p1["4", "rs_min"], min(Matrix::rowSums(cc_i)))
expect_identical(p1["4", "rs_max"], max(Matrix::rowSums(cc_i)))
expect_identical(p1["4", "cs_min"], min(Matrix::colSums(cc_i)))
expect_identical(p1["4", "cs_max"], max(Matrix::colSums(cc_i)))
expect_identical(p1["4", "sparsity"], sum(cc_i == 0)/(ncol(cc_i) * nrow(cc_i)))
cl <- igraph::cluster_louvain(igraph::graph_from_incidence_matrix(cc_i))
cl <- igraph::cluster_louvain(igraph::graph_from_biadjacency_matrix(cc_i))
expect_identical(p1["4", "n_coms"], as.numeric(length(cl)))
expect_identical(p1["4", "mod_coms"], igraph::modularity(cl))
## Check CC 3
cc_i <- connectedComponents(cc, 3)
expect_equal(p1["3", "ncol"], ncol(cc_i))
expect_equal(p1["3", "nrow"], nrow(cc_i))
expect_identical(p1["3", "n"], sum(cc_i))
expect_identical(p1["3", "rs_min"], min(rowSums(cc_i)))
expect_identical(p1["3", "rs_max"], max(rowSums(cc_i)))
expect_identical(p1["3", "cs_min"], min(colSums(cc_i)))
expect_identical(p1["3", "cs_max"], max(colSums(cc_i)))
expect_identical(p1["3", "rs_min"], min(Matrix::rowSums(cc_i)))
expect_identical(p1["3", "rs_max"], max(Matrix::rowSums(cc_i)))
expect_identical(p1["3", "cs_min"], min(Matrix::colSums(cc_i)))
expect_identical(p1["3", "cs_max"], max(Matrix::colSums(cc_i)))
expect_identical(p1["3", "sparsity"], sum(cc_i == 0)/(ncol(cc_i) * nrow(cc_i)))
cl <- igraph::cluster_louvain(igraph::graph_from_incidence_matrix(cc_i))
cl <- igraph::cluster_louvain(igraph::graph_from_biadjacency_matrix(cc_i))
expect_identical(p1["3", "n_coms"], as.numeric(length(cl)))
expect_identical(p1["3", "mod_coms"], igraph::modularity(cl))
})

0 comments on commit 212d879

Please sign in to comment.