From 212d879b2217e115644b296aff5ae30d3eb25807 Mon Sep 17 00:00:00 2001 From: Laurent Gatto Date: Mon, 28 Oct 2024 13:59:11 +0100 Subject: [PATCH] fix errors --- DESCRIPTION | 4 ++-- NAMESPACE | 2 +- NEWS.md | 10 +++++++++ R/ConnectedComponent-class.R | 2 +- R/adjacencyMatrix-plot.R | 4 ++-- man/PSMatch.Rd | 25 +++++++++++++++++++++++ tests/testthat/test_ConnectedComponents.R | 23 +++++++++++---------- 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 50f1c5e..9606685 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "laurent.gatto@uclouvain.be", @@ -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 diff --git a/NAMESPACE b/NAMESPACE index f2c98cc..846de00 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/NEWS.md b/NEWS.md index d5f34b6..82bd0f1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/ConnectedComponent-class.R b/R/ConnectedComponent-class.R index 46347f9..a58a798 100644 --- a/R/ConnectedComponent-class.R +++ b/R/ConnectedComponent-class.R @@ -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)) diff --git a/R/adjacencyMatrix-plot.R b/R/adjacencyMatrix-plot.R index cf67cd6..9413a22 100644 --- a/R/adjacencyMatrix-plot.R +++ b/R/adjacencyMatrix-plot.R @@ -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 ##' @@ -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))) diff --git a/man/PSMatch.Rd b/man/PSMatch.Rd index 667dff0..704d5ae 100644 --- a/man/PSMatch.Rd +++ b/man/PSMatch.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/PSMatch-package.R \docType{package} \name{PSMatch} +\alias{PSMatch-package} \alias{PSMatch} \title{PSMatch: Handling and Managing Peptide Spectrum Matches} \description{ @@ -75,3 +76,27 @@ the package's \href{https://rformassspectrometry.github.io/PSMatch/}{webpage}. } +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/RforMassSpectrometry/PSM} + \item Report bugs at \url{https://github.com/RforMassSpectrometry/PSM/issues} +} + +} +\author{ +\strong{Maintainer}: Laurent Gatto \email{laurent.gatto@uclouvain.be} (\href{https://orcid.org/0000-0002-1520-2268}{ORCID}) + +Authors: +\itemize{ + \item Johannes Rainer \email{Johannes.Rainer@eurac.edu} (\href{https://orcid.org/0000-0002-6977-7147}{ORCID}) + \item Sebastian Gibb \email{mail@sebastiangibb.de} (\href{https://orcid.org/0000-0001-7406-4443}{ORCID}) +} + +Other contributors: +\itemize{ + \item Samuel Wieczorek \email{samuel.wieczorek@cea.fr} [contributor] + \item Thomas Burger \email{thomas.burger@cea.fr} [contributor] +} + +} diff --git a/tests/testthat/test_ConnectedComponents.R b/tests/testthat/test_ConnectedComponents.R index 61edfcc..350e922 100644 --- a/tests/testthat/test_ConnectedComponents.R +++ b/tests/testthat/test_ConnectedComponents.R @@ -35,9 +35,10 @@ 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 @@ -45,12 +46,12 @@ test_that("prioritiseConnectedComponents() works", { 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 @@ -58,12 +59,12 @@ test_that("prioritiseConnectedComponents() works", { 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)) })