From 61089a7c6377f4d3216634d3fd64b9355e5b485b Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 11 Oct 2023 08:43:43 -0400 Subject: [PATCH] Add R CMD fixes --- DESCRIPTION | 5 ----- R/class_haplotype_graph.R | 1 + R/class_phg_con_server.R | 3 ++- R/class_phg_method.R | 11 ++++++----- R/read_hap_ids.R | 10 +++++----- R/stats_mutual_info.R | 2 +- R/stats_num_haplotypes.R | 2 +- R/stats_taxa_by_node.R | 2 +- R/utilities_general.R | 2 +- R/utilities_stats.R | 6 +++--- R/vis_plot_graph.R | 2 +- R/vis_plot_mutual_info.R | 2 +- man/HaplotypeGraph-class.Rd | 2 ++ man/PHGMethod-class.Rd | 2 ++ man/PHGMethod.Rd | 2 +- man/PHGServerCon.Rd | 2 ++ vignettes/rphg_installation.Rmd | 2 +- vignettes/rphg_walkthrough.Rmd | 18 +----------------- 18 files changed, 32 insertions(+), 44 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6716635..7151d9f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,20 +51,15 @@ URL: https://github.com/maize-genetics/rPHG, https://rphg.maizegenetics.net/ Imports: cli, - corrplot, curl, - GenomeInfoDb, GenomicRanges, ggplot2, httr, IRanges, jsonlite, - magrittr, methods, - parallel, rJava, rlang, - S4Vectors, tibble, visNetwork Depends: diff --git a/R/class_haplotype_graph.R b/R/class_haplotype_graph.R index 3740718..a9b21ac 100644 --- a/R/class_haplotype_graph.R +++ b/R/class_haplotype_graph.R @@ -6,6 +6,7 @@ #' a \code{HaplotypeGraph} object defined in the PHG API #' #' @slot methodID A \code{\linkS4class{PHGMethod}} object +#' @slot methodType The method type (e.g. PATHS, CONSENSUS, etc.) #' @slot nChrom Number of chromosomes #' @slot nNodes Number of nodes #' @slot nRefRanges Number of reference ranges diff --git a/R/class_phg_con_server.R b/R/class_phg_con_server.R index ee136cf..d958636 100644 --- a/R/class_phg_con_server.R +++ b/R/class_phg_con_server.R @@ -77,6 +77,7 @@ setValidity("PHGServerCon", function(object) { #' @description \code{PHGServerCon} is the primary container for housing BrAPI #' connection information. #' +#' @param host A user defined URL #' @param port The host port. If \code{NULL}, a default port (e.g. \code{80} or #' \code{443}) will be used depending on protocol. #' @param protocol Which protocol must be used to fetch the desired data? Must @@ -126,7 +127,7 @@ PHGServerCon <- function( stop("Cannot resolve mandatory endpoint: {serverinfo}", call. = FALSE) } - new( + methods::new( Class = "PHGServerCon", phgType = "server", host = host, diff --git a/R/class_phg_method.R b/R/class_phg_method.R index 67ae941..6944fe3 100644 --- a/R/class_phg_method.R +++ b/R/class_phg_method.R @@ -7,6 +7,7 @@ #' #' @slot methodID A PHG method identifier. #' @slot phgConObj A \code{\linkS4class{PHGCon}} object +#' @slot isDemo A logical indicating if this method is for demoing #' #' @name PHGMethod-class #' @rdname PHGMethod-class @@ -20,7 +21,7 @@ setClass( ), prototype = list( methodID = "test", - phgConObj = new("PHGCon", phgType = "local", host = "localHost"), + phgConObj = methods::new("PHGCon", phgType = "local", host = "localHost"), isDemo = FALSE ) ) @@ -70,22 +71,22 @@ setValidity("PHGMethod", function(object) { #' @param methodID A PHG method identifier. #' #' @export -PHGMethod <- function(phgConObj, methodId) { +PHGMethod <- function(phgConObj, methodID) { demoMethodId <- "DEMO" # For demo purposes only! (useful for workshops) trueMethodId <- ifelse( - test = methodId == demoMethodId, + test = methodID == demoMethodId, yes = "NAM_GBS_Alignments_PATHS", - no = methodId + no = methodID ) methods::new( Class = "PHGMethod", methodID = trueMethodId, phgConObj = phgConObj, - isDemo = methodId == demoMethodId + isDemo = methodID == demoMethodId ) } diff --git a/R/read_hap_ids.R b/R/read_hap_ids.R index 48f2948..c1b5162 100644 --- a/R/read_hap_ids.R +++ b/R/read_hap_ids.R @@ -50,7 +50,7 @@ hapIdsFromSever <- function(conObj, conMethod, conDemo) { ) message(verbInfo[1]) - initResp <- rPHG:::parseJSON(initRespUrl) + initResp <- parseJSON(initRespUrl) pageSizeDf <- initResp$result$pagination totalPages <- ifelse( @@ -74,7 +74,7 @@ hapIdsFromSever <- function(conObj, conMethod, conDemo) { ) message(verbInfo[2]) - pb <- txtProgressBar( + pb <- utils::txtProgressBar( min = 0, max = totalPages, initial = 1, @@ -84,8 +84,8 @@ hapIdsFromSever <- function(conObj, conMethod, conDemo) { ) i <- 2 for (url in respUrls) { - respVector[[i]] <- rPHG:::parseJSON(url) - setTxtProgressBar(pb, i) + respVector[[i]] <- parseJSON(url) + utils::setTxtProgressBar(pb, i) i <- i + 1 } close(pb) @@ -102,7 +102,7 @@ hapIdsFromSever <- function(conObj, conMethod, conDemo) { ) colnames(fullResp) <- paste0("R", seq_len(ncol(fullResp))) - rownames(fullResp) <- rPHG:::samplesFromServer(conObj, conMethod, conDemo) + rownames(fullResp) <- samplesFromServer(conObj, conMethod, conDemo) return(fullResp) } diff --git a/R/stats_mutual_info.R b/R/stats_mutual_info.R index c00ba12..098a80a 100644 --- a/R/stats_mutual_info.R +++ b/R/stats_mutual_info.R @@ -3,7 +3,7 @@ # # @param phgObj A `PHGDataSet` object calcMutualInfoFromPHGDataSet <- function(phgObj) { - phgHapIDMat <- t(assay(phgObj)) + phgHapIDMat <- t(SummarizedExperiment::assay(phgObj)) refRanges <- colnames(phgHapIDMat) nRanges <- length(refRanges) miMat <- matrix(NA, nrow = nRanges, ncol = nRanges) diff --git a/R/stats_num_haplotypes.R b/R/stats_num_haplotypes.R index be0d1f8..167aa1e 100644 --- a/R/stats_num_haplotypes.R +++ b/R/stats_num_haplotypes.R @@ -9,7 +9,7 @@ nHaploPerRefRangeFromPHGDataSet <- function(phgObj) { X = SummarizedExperiment::assay(phgObj), MARGIN = 1, FUN = function(x) { - length(unique(na.omit(x))) + length(unique(stats::na.omit(x))) } ) nHapDf <- data.frame( diff --git a/R/stats_taxa_by_node.R b/R/stats_taxa_by_node.R index 47396b3..5a25797 100644 --- a/R/stats_taxa_by_node.R +++ b/R/stats_taxa_by_node.R @@ -33,7 +33,7 @@ taxaByNodeCore <- function( as.numeric() # Get ref range data frame - refRangeDataMini <- rowRanges(hapTableMini) |> as.data.frame() + refRangeDataMini <- SummarizedExperiment::rowRanges(hapTableMini) |> as.data.frame() # Group taxa by hap ID and ref range taxaGroups <- lapply(seq_len(ncol(currentMatrix)), function(i) { diff --git a/R/utilities_general.R b/R/utilities_general.R index fd9f4a3..fcd2a0d 100644 --- a/R/utilities_general.R +++ b/R/utilities_general.R @@ -111,7 +111,7 @@ parseConfigFile <- function(file) { properties <- vapply(FIELDS, \(x) getProperty(conLines, x), character(1)) - return(setNames(as.list(properties), FIELDS)) + return(stats::setNames(as.list(properties), FIELDS)) } diff --git a/R/utilities_stats.R b/R/utilities_stats.R index 220bc87..923ee0a 100644 --- a/R/utilities_stats.R +++ b/R/utilities_stats.R @@ -31,14 +31,14 @@ mutualInfoPair <- function(phgHapIDMat, twoRanges) { # Sum p(x, y) mmi <- matrix( - data = colMeans(model.matrix( ~ -1 + hapID[, 1]:hapID[, 2])), + data = colMeans(stats::model.matrix( ~ -1 + hapID[, 1]:hapID[, 2])), nrow = nHap1, ncol = nHap2 ) # p(x)p(y) - mm1 <- colMeans(model.matrix( ~ -1 + hapID[, 1])) - mm2 <- colMeans(model.matrix( ~ -1 + hapID[, 2])) + mm1 <- colMeans(stats::model.matrix( ~ -1 + hapID[, 1])) + mm2 <- colMeans(stats::model.matrix( ~ -1 + hapID[, 2])) mmm <- tcrossprod(mm1, mm2) # Sum p(x, y) log{p(x, y) / [p(x)p(y)]} diff --git a/R/vis_plot_graph.R b/R/vis_plot_graph.R index 1567f88..bd0c3ed 100644 --- a/R/vis_plot_graph.R +++ b/R/vis_plot_graph.R @@ -46,7 +46,7 @@ plotGraphCore <- function( colnames(currentMatrix) <- as.numeric(gsub("R", "", colnames(currentMatrix))) # Get ref range data frame - refRangeDataMini <- as.data.frame(rowRanges(hapTableMini)) + refRangeDataMini <- as.data.frame(SummarizedExperiment::rowRanges(hapTableMini)) # Group taxa by hap ID and ref range taxaGroups <- lapply(seq_len(ncol(currentMatrix)), function(i) { diff --git a/R/vis_plot_mutual_info.R b/R/vis_plot_mutual_info.R index e2b869f..b85d15a 100644 --- a/R/vis_plot_mutual_info.R +++ b/R/vis_plot_mutual_info.R @@ -10,7 +10,7 @@ plotMutualInfoFromPHGDataSet <- function(phgObj) { mDf$X2 <- as.factor(as.numeric(gsub("R", "", mDf$X2))) p <- ggplot2::ggplot(mDf) + - ggplot2::aes(x = X1, y = X2, fill = mut) + + ggplot2::aes(x = rlang::.data$X1, y = rlang::.data$X2, fill = rlang::.data$mut) + ggplot2::geom_tile( color = "white", lwd = 0.5, diff --git a/man/HaplotypeGraph-class.Rd b/man/HaplotypeGraph-class.Rd index 1f50b9f..8c97dd5 100644 --- a/man/HaplotypeGraph-class.Rd +++ b/man/HaplotypeGraph-class.Rd @@ -23,6 +23,8 @@ class to the console \describe{ \item{\code{methodID}}{A \code{\linkS4class{PHGMethod}} object} +\item{\code{methodType}}{The method type (e.g. PATHS, CONSENSUS, etc.)} + \item{\code{nChrom}}{Number of chromosomes} \item{\code{nNodes}}{Number of nodes} diff --git a/man/PHGMethod-class.Rd b/man/PHGMethod-class.Rd index 469e363..c3b64b5 100644 --- a/man/PHGMethod-class.Rd +++ b/man/PHGMethod-class.Rd @@ -14,5 +14,7 @@ a "committed" PHG method to return data against. \item{\code{methodID}}{A PHG method identifier.} \item{\code{phgConObj}}{A \code{\linkS4class{PHGCon}} object} + +\item{\code{isDemo}}{A logical indicating if this method is for demoing} }} diff --git a/man/PHGMethod.Rd b/man/PHGMethod.Rd index fabcfee..f490366 100644 --- a/man/PHGMethod.Rd +++ b/man/PHGMethod.Rd @@ -4,7 +4,7 @@ \alias{PHGMethod} \title{Helper function to construct PHGMethod object} \usage{ -PHGMethod(phgConObj, methodId) +PHGMethod(phgConObj, methodID) } \arguments{ \item{phgConObj}{A \code{\linkS4class{PHGCon}} object.} diff --git a/man/PHGServerCon.Rd b/man/PHGServerCon.Rd index 19cea2e..c6fbedf 100644 --- a/man/PHGServerCon.Rd +++ b/man/PHGServerCon.Rd @@ -12,6 +12,8 @@ PHGServerCon( ) } \arguments{ +\item{host}{A user defined URL} + \item{port}{The host port. If \code{NULL}, a default port (e.g. \code{80} or \code{443}) will be used depending on protocol.} diff --git a/vignettes/rphg_installation.Rmd b/vignettes/rphg_installation.Rmd index 9e134d4..c087cdf 100644 --- a/vignettes/rphg_installation.Rmd +++ b/vignettes/rphg_installation.Rmd @@ -7,7 +7,7 @@ output: toc_float: true number_sections: false vignette: > - %\VignetteIndexEntry{Getting Start with rPHG} + %\VignetteIndexEntry{Installing and setting up rPHG and rJava} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} %\usepackage[utf8]{inputenc} diff --git a/vignettes/rphg_walkthrough.Rmd b/vignettes/rphg_walkthrough.Rmd index 4265dd7..2c64d49 100644 --- a/vignettes/rphg_walkthrough.Rmd +++ b/vignettes/rphg_walkthrough.Rmd @@ -7,7 +7,7 @@ output: toc_float: true number_sections: false vignette: > - %\VignetteIndexEntry{Getting Start with rPHG} + %\VignetteIndexEntry{Introduction to rPHG} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} %\usepackage[utf8]{inputenc} @@ -144,20 +144,4 @@ configFile |> readPHGDataSet() ``` -## Analyzing and visualizing data -# - -# - -# - -# - -# - -# - -# - -#