Skip to content

Commit 897c2db

Browse files
author
Alexey Stukalov
committed
.formatColData(): simplify
remove quantCols argument since it is not used, and the rownames should be derived from colData$quantCols and colData$runCol
1 parent f745c38 commit 897c2db

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

R/readQFeatures.R

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ readQFeatures <- function(assayData,
336336
}
337337
if (removeEmptyCols) el <- .removeEmptyColumns(el)
338338
if (verbose) message("Formatting sample annotations (colData).")
339-
colData <- .formatColData(el, colData, runs, quantCols)
339+
colData <- .formatColData(el, colData, runs)
340340
if (verbose) message("Formatting data as a 'QFeatures' object.")
341341
ans <- QFeatures(experiments = el, colData = colData)
342342
if (!is.null(fnames)) {
@@ -494,31 +494,19 @@ readQFeatures <- function(assayData,
494494

495495
## This function will create a colData from the different (possibly
496496
## missing, i.e. NULL) arguments
497-
.formatColData <- function(el, colData, runs, quantCols) {
497+
.formatColData <- function(el, colData, runs) {
498498
sampleNames <- unlist(lapply(el, colnames), use.names = FALSE)
499499
if (is.null(colData))
500500
return(DataFrame(row.names = sampleNames))
501-
if (!length(runs)) {
502-
# assign colData rownames to match colData to sampleNames
503-
if ("quantCols" %in% colnames(colData)) {
504-
# use colData$quantCols as rownames
505-
# (quantCols argument is not guaranteed to match to colData rows)
506-
rownames(colData) <- colData$quantCols
507-
} else if (length(quantCols) == nrow(colData)) {
508-
# no colData$quantCols column
509-
# we assume the colData order matches quantCols argument
510-
rownames(colData) <- quantCols
511-
} else {
512-
# assume colData order matches sampleNames
513-
rownames(colData) <- sampleNames
514-
}
501+
# assign colData rownames to match colData to sampleNames
502+
# colData$quantCols presence was checked by .checkQuantCols
503+
if (is.null(runs)) {
504+
# use colData$quantCols as rownames
505+
rownames(colData) <- colData$quantCols
515506
} else {
516507
# run information is present, colData should match individual runs
517-
if (length(quantCols) == 1) {
518-
rownames(colData) <- colData$runCol
519-
} else {
520-
rownames(colData) <- paste0(colData$runCol, "_", colData$quantCols)
521-
}
508+
# the presence of colData$runCol was checked by .checkRunCol
509+
rownames(colData) <- paste0(colData$runCol, "_", colData$quantCols)
522510
}
523511
# match colData to sampleNames
524512
colData <- colData[sampleNames, , drop = FALSE]

0 commit comments

Comments
 (0)