waldronlab / TCGAutils

Toolbox package for organizing and working with TCGA data
https://bioconductor.org/packages/TCGAutils
22 stars 6 forks source link

TCGAsampleselect when sampleCode has length > 1 #16

Closed lwaldron closed 5 years ago

lwaldron commented 5 years ago

?TCGAsampleselect says that sampleCode must be a character or numeric vector of length one. However, vectors of length >1 appear to work but gives warnings and a wrong answer. Should either be permitted, or error immediately with informative error.

suppressPackageStartupMessages(library(TCGAutils))
example("TCGAbarcode", echo=FALSE)
(res1 <- TCGAsampleSelect(barcodes, c(10, 11)))
#> Warning in if (nchar(as.character(sampleCode)) == 1L) sampleCode <-
#> paste0("0", : the condition has length > 1 and only the first element will
#> be used
#> Warning in if (!sampleCode %in% sampleTypes[["Code"]]) stop("'sampleCode'
#> not in look up table"): the condition has length > 1 and only the first
#> element will be used
#> Selecting 'Blood Derived NormalSolid Tissue Normal' samples
#> Warning in barcodeSamples == sampleCode: longer object length is not a
#> multiple of shorter object length
#> [1] FALSE  TRUE  TRUE
(res2 <- TCGAsampleSelect(barcodes, 10) | TCGAsampleSelect(barcodes, 11))
#> Selecting 'Blood Derived Normal' samples
#> Selecting 'Solid Tissue Normal' samples
#> [1] TRUE TRUE TRUE