Skip to content

Commit

Permalink
Merge pull request #179 from mixOmicsTeam/issue-178
Browse files Browse the repository at this point in the history
Fix for Issue #178
  • Loading branch information
aljabadi authored Apr 10, 2022
2 parents cd29219 + f66c36d commit 35d7810
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/circosPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ circosPlot.block.splsda <- .circosPlot
#' @export
circosPlot.block.spls <- function(object, ..., group = NULL, Y.name = 'Y')
{
# when a block.spls object is supplied that uses the indY parameter, the name
# of the object$X component for this dataframe is its proper name
# for below checks, change it back to "Y"
if (is.null(object$X$Y)) {
names(object$X)[object$indY] <- "Y"
}

if (length(group) != nrow(object$X$Y))
stop("group must be a factor of length: nrow(object$X$Y) = ", nrow(object$X$Y), "\n")
object$Y <- factor(group)
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-circsPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,18 @@ test_that("circosPlot works with similar feature names in different blocks", cod
expect_is(cp_res, "matrix")
})

test_that("circosPlot works when using the indY parameter", code = {

data("breast.TCGA")
data = list(mrna = breast.TCGA$data.train$mrna,
mirna = breast.TCGA$data.train$mirna,
protein = breast.TCGA$data.train$protein)

list.keepX = list(mrna = rep(20, 2), mirna = rep(10,2), protein = rep(10, 2))
TCGA.block.spls = block.spls(X = data, indY = 3,
ncomp = 2, keepX = list.keepX, design = 'full')
cp_res <- circosPlot(TCGA.block.spls, cutoff = 0.7, group = breast.TCGA$data.train$subtype)

expect_is(cp_res, "matrix")
})

0 comments on commit 35d7810

Please sign in to comment.