Skip to content

Commit

Permalink
Add R CMD fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
btmonier committed Oct 11, 2023
1 parent 12ce6aa commit 61089a7
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 44 deletions.
5 changes: 0 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions R/class_haplotype_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion R/class_phg_con_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,7 +127,7 @@ PHGServerCon <- function(
stop("Cannot resolve mandatory endpoint: {serverinfo}", call. = FALSE)
}

new(
methods::new(
Class = "PHGServerCon",
phgType = "server",
host = host,
Expand Down
11 changes: 6 additions & 5 deletions R/class_phg_method.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
)
Expand Down Expand Up @@ -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
)
}

Expand Down
10 changes: 5 additions & 5 deletions R/read_hap_ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -74,7 +74,7 @@ hapIdsFromSever <- function(conObj, conMethod, conDemo) {
)

message(verbInfo[2])
pb <- txtProgressBar(
pb <- utils::txtProgressBar(
min = 0,
max = totalPages,
initial = 1,
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion R/stats_mutual_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/stats_num_haplotypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion R/stats_taxa_by_node.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/utilities_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}


Expand Down
6 changes: 3 additions & 3 deletions R/utilities_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)]}
Expand Down
2 changes: 1 addition & 1 deletion R/vis_plot_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion R/vis_plot_mutual_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions man/HaplotypeGraph-class.Rd

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

2 changes: 2 additions & 0 deletions man/PHGMethod-class.Rd

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

2 changes: 1 addition & 1 deletion man/PHGMethod.Rd

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

2 changes: 2 additions & 0 deletions man/PHGServerCon.Rd

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

2 changes: 1 addition & 1 deletion vignettes/rphg_installation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
18 changes: 1 addition & 17 deletions vignettes/rphg_walkthrough.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -144,20 +144,4 @@ configFile |>
readPHGDataSet()
```

## Analyzing and visualizing data

#

#

#

#

#

#

#

#

0 comments on commit 61089a7

Please sign in to comment.