While I was trying to run featurecounts on some bam files resulted from STAR I stumbled across this issue:
error message
----------- FAILURE REPORT --------------
--- failure: length > 1 in coercion to logical ---
--- srcref ---
:
--- package (from environment) ---
Rsubread
--- call from context ---
.check_and_NormPath(files, mustWork = T, opt = "files")
--- call from argument ---
is.na(files) || is.null(files)
--- R stacktrace ---
where 1: .check_and_NormPath(files, mustWork = T, opt = "files")
where 2: featureCounts(files = list.BAM[1:3], annot.ext = path_gtf, isGTFAnnotationFile = TRUE,
GTF.featureType = "exon", GTF.attrType.extra = c("gene_type",
"sRNA_id", "seq_RNA"), nthreads = 2, useMetaFeatures = TRUE,
allowMultiOverlap = TRUE, minOverlap = 10, largestOverlap = TRUE,
fraction = TRUE, strandSpecific = 0, verbose = TRUE, reportReads = "BAM",
reportReadsPath = file.path("report"))
--- value of length: 3 type: logical ---
[1] FALSE FALSE FALSE
--- function from context ---
function (files, mustWork = F, opt = NULL)
{
if (is.na(files) || is.null(files) || class(files) != "character") {
if (is.null(opt)) {
if (is.na(files) || is.null(files)) {
stop("Error: the file name is NA or NULL.")
}
else {
stop(paste0("Error: the file name must be a character vector. The current input is ",
class(files)))
}
}
else {
if (is.na(files) || is.null(files)) {
stop(paste0("Error: the argument to '", opt,
"' is NA or NULL."))
}
else {
stop(paste0("Error: the argument to '", opt,
"' must be a character vector. The current input is ",
class(files)))
}
}
}
rv <- normalizePath(files, mustWork = mustWork)
if (any(grepl(.R_param_splitor, rv))) {
stop(paste0("Error: the file path to '", opt, "' contains the internal splitor of featureCounts (\\027). The \\027 character is unallowd in the file names or in the paths."))
}
if (any(grepl("\t", rv))) {
stop(paste0("Error: the file path to '", opt, "' contains <TAB> character(s). The TAB character is unallowd in the file names or in the paths."))
}
if (any(grepl(.R_flist_splitor, rv))) {
stop(paste0("Error: the file path to '", opt, "' contains the internal splitor of featureCounts (\\026). The \\026 character is unallowd in the file names or in the paths."))
}
if (any(nchar(rv) >= .filepath_maximum_len)) {
errv <- rv[nchar(rv) >= .filepath_maximum_len]
stop(paste0("Error: the file name and path of ", opt,
" is longer than ", .filepath_maximum_len, " bytes. Beaware that all the file names are normalized to include the full path to the original file. The value is '",
errv[1], "'"))
}
return(rv)
}
<bytecode: 0x561d3079b5e0>
<environment: namespace:Rsubread>
--- function search by body ---
Function .check_and_NormPath in namespace Rsubread has this body.
----------- END OF FAILURE REPORT --------------
Error in is.na(files) || is.null(files) :
'length(x) = 3 > 1' in coercion to 'logical(1)'
sessionInfo( )
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rsubread_2.7.1 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.6 purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 tibble_3.1.2 ggplot2_3.3.3 tidyverse_1.3.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 cellranger_1.1.0 pillar_1.6.1 compiler_4.1.0 dbplyr_2.1.1 tools_4.1.0 lattice_0.20-44 jsonlite_1.7.2 lubridate_1.7.10
[10] lifecycle_1.0.0 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 Matrix_1.3-3 reprex_2.0.0 cli_2.5.0 rstudioapi_0.13 DBI_1.1.1
[19] haven_2.4.1 xml2_1.3.2 withr_2.4.2 httr_1.4.2 fs_1.5.0 generics_0.1.0 vctrs_0.3.8 hms_1.1.0 grid_4.1.0
[28] tidyselect_1.1.1 glue_1.4.2 R6_2.5.0 fansi_0.5.0 readxl_1.3.1 modelr_0.1.8 magrittr_2.0.1 backports_1.2.1 scales_1.1.1
[37] ellipsis_0.3.2 rvest_1.0.0 assertthat_0.2.1 colorspace_2.0-1 utf8_1.2.1 stringi_1.6.2 munsell_0.5.0 broom_0.7.6 crayon_1.4.1
run featureCounts
library(tidyverse)
library(Rsubread)
list.BAM <- list.files(path = file.path("BAM"),
pattern = ".bam$",
recursive = TRUE,
full.names = TRUE)
path_gtf <- file.path("GRCh38/sncRNA_piRNBnk_RNACent_GRCh38_v34.gtf")
todate <- format(Sys.time(), "%d_%b_%Y")
fc <- featureCounts(files = list.BAM[1:3],
annot.ext = path_gtf,
isGTFAnnotationFile = TRUE,
GTF.featureType = "exon",
GTF.attrType.extra = c("gene_type", "sRNA_id", "seq_RNA"),
nthreads = 2,
useMetaFeatures = TRUE,
allowMultiOverlap = TRUE,
minOverlap = 10,
largestOverlap = TRUE,
fraction = TRUE,
strandSpecific = 0,
verbose = TRUE,
reportReads = "BAM",
reportReadsPath = file.path("report"))
Strange thing is that the code was running 3-4 months ago without any issues. When I run the code with only one file it proceeds normally
fc <- featureCounts(files = list.BAM[1],
annot.ext = path_gtf,
isGTFAnnotationFile = TRUE,
GTF.featureType = "exon",
GTF.attrType.extra = c("gene_type", "sRNA_id", "seq_RNA"),
nthreads = 2,
useMetaFeatures = TRUE,
allowMultiOverlap = TRUE,
minOverlap = 10,
largestOverlap = TRUE,
fraction = TRUE,
strandSpecific = 0,
verbose = TRUE,
reportReads = "BAM",
reportReadsPath = file.path("report"))
I then detach featureCounts and run:
detach("package:Rsubread", unload = TRUE)
is.na(list.BAM)|| is.null(list.BAM)
----------- FAILURE REPORT --------------
--- failure: length > 1 in coercion to logical ---
--- srcref ---
:
--- package (from environment) ---
package:XML
--- call from context ---
NULL
--- call from argument ---
is.na(list.BAM) || is.null(list.BAM)
--- R stacktrace ---
--- value of length: 9 type: logical ---
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
--- function from context ---
--- function search by body ---
----------- END OF FAILURE REPORT --------------
Error in is.na(list.BAM) || is.null(list.BAM) :
'length(x) = 9 > 1' in coercion to 'logical(1)'
Has anyone else had the same issue? Is it a problem of R and not featureCounts?
Thanks for the bug report! I tried to reproduce the bug, but featureCounts ran as I expected in all the settings I tried.
Can you provide the return value of the list.files function? If it returns a list of files, can you also confirm that the files are in the locations in the returned value?
Dear Yang, I'm running the code in a docker image that you can find here:
here is the list:
An important notice is that when I run it in a different version of R(session below) it is running without issue
I tried to run it in the docker inside a "new project" directory but I got the same issue.
I confirm that.
Thanks for your time!!
Thanks for the further details!
I tried this command in all R instances:
All the R instances (v4.1.0 or v4.0.2, in R-studio or in command line, on Windows or Linux) can run it with no errors (but some warnings) and had "AAA" printed. Only the R version in the Docker image mentioned in your post reported an error and printed nothing. I noticed that some people reported the same behaviour of R in its nightly built version. I suspect if it was because the Docker image used a nightly built version of R, instead of the released R 4.1.0. I will try installing a nightly built version of R, and see if it can reproduce the error message.