From 87f13c34dc8cc1b56439b3eef33071d9aa540107 Mon Sep 17 00:00:00 2001 From: tonywu1999 Date: Thu, 25 Jul 2024 14:26:01 -0400 Subject: [PATCH] refactor(visualize): Change name of function visualizeSubnetwork to visualizeNetworks (#10) --- NAMESPACE | 2 +- ...ualizeSubnetwork.R => visualizeNetworks.R} | 6 ++--- ...lizeSubnetwork.Rd => visualizeNetworks.Rd} | 10 ++++---- ...eSubnetwork.R => test-visualizeNetworks.R} | 24 +++++++++---------- vignettes/MSstatsBioNet.Rmd | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) rename R/{visualizeSubnetwork.R => visualizeNetworks.R} (90%) rename man/{visualizeSubnetwork.Rd => visualizeNetworks.Rd} (73%) rename tests/testthat/{test-visualizeSubnetwork.R => test-visualizeNetworks.R} (70%) diff --git a/NAMESPACE b/NAMESPACE index 3085634..b0b6e51 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,7 @@ # Generated by roxygen2: do not edit by hand export(getSubnetworkFromIndra) -export(visualizeSubnetwork) +export(visualizeNetworks) importFrom(RCy3,createNetworkFromDataFrames) importFrom(RCy3,createVisualStyle) importFrom(RCy3,mapVisualProperty) diff --git a/R/visualizeSubnetwork.R b/R/visualizeNetworks.R similarity index 90% rename from R/visualizeSubnetwork.R rename to R/visualizeNetworks.R index ad70e3a..ddad431 100644 --- a/R/visualizeSubnetwork.R +++ b/R/visualizeNetworks.R @@ -17,13 +17,13 @@ #' package = "MSstatsBioNet" #' )) #' # subnetwork = getSubnetworkFromIndra(input) -#' # visualizeSubnetwork(subnetwork$nodes, subnetwork$edges) +#' # visualizeNetworks(subnetwork$nodes, subnetwork$edges) #' #' @return cytoscape visualization of subnetwork #' #' -visualizeSubnetwork <- function(nodes, edges, - pvalue_cutoff = 0.05, logfc_cutoff = 0.5) { +visualizeNetworks <- function(nodes, edges, + pvalue_cutoff = 0.05, logfc_cutoff = 0.5) { # Add additional columns for visualization nodes$logFC_color <- nodes$logFC nodes$logFC_color[nodes$pvalue > pvalue_cutoff | diff --git a/man/visualizeSubnetwork.Rd b/man/visualizeNetworks.Rd similarity index 73% rename from man/visualizeSubnetwork.Rd rename to man/visualizeNetworks.Rd index d94e4aa..6df7cc8 100644 --- a/man/visualizeSubnetwork.Rd +++ b/man/visualizeNetworks.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/visualizeSubnetwork.R -\name{visualizeSubnetwork} -\alias{visualizeSubnetwork} +% Please edit documentation in R/visualizeNetworks.R +\name{visualizeNetworks} +\alias{visualizeNetworks} \title{Create visualization of subnetwork in cytoscape} \usage{ -visualizeSubnetwork(nodes, edges, pvalue_cutoff = 0.05, logfc_cutoff = 0.5) +visualizeNetworks(nodes, edges, pvalue_cutoff = 0.05, logfc_cutoff = 0.5) } \arguments{ \item{nodes}{dataframe of nodes} @@ -29,6 +29,6 @@ input <- data.table::fread(system.file( package = "MSstatsBioNet" )) # subnetwork = getSubnetworkFromIndra(input) -# visualizeSubnetwork(subnetwork$nodes, subnetwork$edges) +# visualizeNetworks(subnetwork$nodes, subnetwork$edges) } diff --git a/tests/testthat/test-visualizeSubnetwork.R b/tests/testthat/test-visualizeNetworks.R similarity index 70% rename from tests/testthat/test-visualizeSubnetwork.R rename to tests/testthat/test-visualizeNetworks.R index c77e753..0fece93 100644 --- a/tests/testthat/test-visualizeSubnetwork.R +++ b/tests/testthat/test-visualizeNetworks.R @@ -1,30 +1,30 @@ -test_that("visualizeSubnetwork works correctly", { +test_that("visualizeNetworks works correctly", { input <- readRDS(system.file("processed_data/subnetwork.rds", package = "MSstatsBioNet" )) mock_createNetworkFromDataFrames <- mock() stub( - visualizeSubnetwork, "createNetworkFromDataFrames", + visualizeNetworks, "createNetworkFromDataFrames", mock_createNetworkFromDataFrames ) mock_mapVisualProperty <- mock() stub( - visualizeSubnetwork, "mapVisualProperty", + visualizeNetworks, "mapVisualProperty", mock_mapVisualProperty ) mock_createVisualStyle <- mock() stub( - visualizeSubnetwork, "createVisualStyle", + visualizeNetworks, "createVisualStyle", mock_createVisualStyle ) mock_setVisualStyle <- mock() stub( - visualizeSubnetwork, "setVisualStyle", + visualizeNetworks, "setVisualStyle", mock_setVisualStyle ) - expect_silent(visualizeSubnetwork(input$nodes, input$edges)) + expect_silent(visualizeNetworks(input$nodes, input$edges)) expect_called(mock_createNetworkFromDataFrames, 1) expect_called(mock_mapVisualProperty, 2) expect_called(mock_createVisualStyle, 1) @@ -32,33 +32,33 @@ test_that("visualizeSubnetwork works correctly", { }) -test_that("visualizeSubnetwork with p-value and logFC constraints works", { +test_that("visualizeNetworks with p-value and logFC constraints works", { input <- readRDS(system.file("processed_data/subnetwork.rds", package = "MSstatsBioNet" )) mock_createNetworkFromDataFrames <- mock() stub( - visualizeSubnetwork, "createNetworkFromDataFrames", + visualizeNetworks, "createNetworkFromDataFrames", mock_createNetworkFromDataFrames ) mock_mapVisualProperty <- mock() stub( - visualizeSubnetwork, "mapVisualProperty", + visualizeNetworks, "mapVisualProperty", mock_mapVisualProperty ) mock_createVisualStyle <- mock() stub( - visualizeSubnetwork, "createVisualStyle", + visualizeNetworks, "createVisualStyle", mock_createVisualStyle ) mock_setVisualStyle <- mock() stub( - visualizeSubnetwork, "setVisualStyle", + visualizeNetworks, "setVisualStyle", mock_setVisualStyle ) - expect_silent(visualizeSubnetwork(input$nodes, input$edges, + expect_silent(visualizeNetworks(input$nodes, input$edges, pvalue_cutoff = 0.01, logfc_cutoff = 2.5 )) expect_called(mock_createNetworkFromDataFrames, 1) diff --git a/vignettes/MSstatsBioNet.Rmd b/vignettes/MSstatsBioNet.Rmd index 056805f..b4c9d40 100644 --- a/vignettes/MSstatsBioNet.Rmd +++ b/vignettes/MSstatsBioNet.Rmd @@ -28,7 +28,7 @@ networks. The package is designed to be used in conjunction with the The package provides a function `getSubnetworkFromIndra` that retrieves a subnetwork of proteins from the INDRA database based on differential abundance -analysis results. The function `visualizeSubnetwork` then takes the output +analysis results. The function `visualizeNetworks` then takes the output of `getSubnetworkFromIndra` and visualizes the subnetwork. ```{r proteinNetworkDiscovery, eval=FALSE} @@ -38,5 +38,5 @@ input <- data.table::fread( ) ) subnetwork <- getSubnetworkFromIndra(input) -visualizeSubnetwork(subnetwork$nodes, subnetwork$edges) +visualizeNetworks(subnetwork$nodes, subnetwork$edges) ```