Rsubread issue with featurecounts :----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref ---
1
0
Entering edit mode
@konstantinos-yeles-8961
Last seen 11 months ago
Italy

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?

Rsubread featurecounts coercion • 2.5k views
ADD COMMENT
1
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

Dear Yang, I'm running the code in a docker image that you can find here:

docker pull congelos/rocker_tidyverse_plus_de_pckages

here is the list:

list.BAM
[1] "BAM/random_1_R1_001.bam"                                                   
[2] "BAM/random_2_R1_001.bam"                                                   
[3] "BAM/random_3_R1_001.bam"                                                   
[4] "BAM/random_4_R1_001.bam"
[5] "BAM/random_5_S11_001.bam"
[6] "BAM/random_6_S1_001.bam"
[7] "BAM/random_7_S1.bam"   
[8] "BAM/random_8_R1_001.bam"  
[9] "BAM/random_9_R1_001.bam"

list.BAM %>% class
[1] "character"

An important notice is that when I run it in a different version of R(session below) it is running without issue

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=Italian_Italy.1252  LC_CTYPE=Italian_Italy.1252    LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C                  
[5] LC_TIME=Italian_Italy.1252    

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
 [1] DESeq2_1.28.1               SummarizedExperiment_1.18.2 DelayedArray_0.14.1         matrixStats_0.59.0        
 [5] Biobase_2.48.0              GenomicRanges_1.40.0        GenomeInfoDb_1.24.2         IRanges_2.22.2            
 [9] S4Vectors_0.26.1            BiocGenerics_0.34.0         forcats_0.5.1               stringr_1.4.0              
[13] dplyr_1.0.6                 purrr_0.3.4                 readr_1.4.0                 tidyr_1.1.3                
[17] tibble_3.1.2                ggplot2_3.3.3               tidyverse_1.3.1             Rsubread_2.2.6            

loaded via a namespace (and not attached):
 [1] httr_1.4.2             splines_4.0.2          bit64_4.0.5            jsonlite_1.7.2         modelr_0.1.8          
 [6] assertthat_0.2.1       BiocManager_1.30.15    blob_1.2.1             GenomeInfoDbData_1.2.3 cellranger_1.1.0      
[11] pillar_1.6.1           RSQLite_2.2.7          backports_1.2.1        lattice_0.20-44        glue_1.4.2            
[16] RColorBrewer_1.1-2     XVector_0.28.0         rvest_1.0.0            colorspace_2.0-1       Matrix_1.3-4          
[21] XML_3.99-0.6           pkgconfig_2.0.3        broom_0.7.6            haven_2.4.1            genefilter_1.70.0    
[26] zlibbioc_1.34.0        xtable_1.8-4           scales_1.1.1           BiocParallel_1.22.0    annotate_1.66.0      
[31] generics_0.1.0         ellipsis_0.3.2         cachem_1.0.5           withr_2.4.2            cli_2.5.0            
[36] survival_3.2-11        magrittr_2.0.1         crayon_1.4.1           readxl_1.3.1           memoise_2.0.0        
[41] fs_1.5.0               fansi_0.5.0            xml2_1.3.2             tools_4.0.2            hms_1.1.0            
[46] lifecycle_1.0.0        locfit_1.5-9.4         munsell_0.5.0          reprex_2.0.0           AnnotationDbi_1.50.3  
[51] compiler_4.0.2         rlang_0.4.11           grid_4.0.2             RCurl_1.98-1.3         rstudioapi_0.13      
[56] bitops_1.0-7           gtable_0.3.0           DBI_1.1.1              R6_2.5.0               lubridate_1.7.10      
[61] fastmap_1.1.0          bit_4.0.4              utf8_1.2.1             stringi_1.6.2          Rcpp_1.0.6            
[66] geneplotter_1.66.0     vctrs_0.3.8            dbplyr_2.1.1           tidyselect_1.1.1

I tried to run it in the docker inside a "new project" directory but I got the same issue.

the files are in the locations in the returned value

I confirm that.

Thanks for your time!!

ADD REPLY
1
Entering edit mode

Thanks for the further details!

I tried this command in all R instances:

if(is.na(c(NA,1)))print("AAA")

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.

ADD REPLY
2
Entering edit mode
Yang Liao ▴ 450
@yang-liao-6075
Last seen 10 days ago
Australia

I noticed that a setting of R in the Docker image (congelos/rocker_tidyverse_plus_de_pckages) is not default. In

/usr/local/lib/R/etc/Renviron.site

in the Docker image, there are a few lines of configuration. One line is

_R_CHECK_LENGTH_1_CONDITION_=verbose

This line doesn't exist in the configuration file of a normal R 4.1.0 installation. This line decides how R deals with multiple boolean values in an if statement. When this line is set to verbose, R will stop the program with a failure report. When this line is deleted, R allows multiple boolean values in the if statement (and only uses the first value) but reports a warning message. This setting caused the different behaviours of the R versions I tested and the R version in the Docker image.

After all, the right way is to use the any() or all() function to deal with the multiple boolean values. We have fixed this problem in the in-development version of Rsubread; you may use the in-development version for your study. We will also fix it in the release version shortly.

Thank you very much for the bug report.

ADD COMMENT
0
Entering edit mode

Thank you very much for following up and devoting time to identify the issue!

The Docker image I use is built on top of the one made in https://github.com/Bioconductor/bioconductor_docker.
My main purpose was to have as stable and "bugless" containers as possible :)

Great work and thank you again!

ADD REPLY

Login before adding your answer.

Traffic: 793 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6