Skip to content

Commit

Permalink
readGct support for duplicate column names
Browse files Browse the repository at this point in the history
  • Loading branch information
assaron committed Aug 28, 2024
1 parent 3e4299f commit eb17a1d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: phantasusLite
Type: Package
Title: Loading and annotation RNA-seq counts matrices
Version: 1.3.2
Version: 1.3.3
Authors@R: c(person("Rita", "Sablina", role = "aut"),
person("Maxim", "Kleverov", role = "aut"),
person("Alexey", "Sergushichev", email = "[email protected]", role = c("aut", "cre")))
Expand All @@ -22,7 +22,7 @@ biocViews: GeneExpression, Transcriptomics, RNASeq
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Suggests:
testthat (>= 3.0.0),
knitr,
Expand Down
8 changes: 8 additions & 0 deletions R/gct.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ readGct <- function(gct) {
exp <- as.matrix(t[, exp.cols, with=FALSE])
rownames(exp) <- rn

cn <- colnames(exp)
if (any(duplicated(cn))) {
warning(sprintf("duplicated row IDs: %s; they were renamed",
paste0(cn[head(which(duplicated(cn)))], collapse = " ")))
cn <- make.unique(cn)
colnames(exp) <- cn
}



fdata <- makeAnnotated(t[, seq_len(ann.row + 1), with=FALSE])
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-gct.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ test_that("readGct works with gct #1.2", {
expect_true(ncol(t) == 4)
})

test_that("readGct works with duplicate row names", {
test_that("readGct works with duplicate row or column names", {
gctFile <- system.file("extdata/testdata/gct/test_dup.gct", package="phantasusLite")
expect_warning(t <- readGct(gctFile), "duplicate")
expect_true(!is.null(t))

gctFile <- system.file("extdata/testdata/gct/test_dupcol.gct", package="phantasusLite")
expect_warning(t <- readGct(gctFile), "duplicate")
expect_true(!is.null(t))
})

test_that("writeGct and readGct work", {
Expand Down

0 comments on commit eb17a1d

Please sign in to comment.