ggcoverage icon indicating copy to clipboard operation
ggcoverage copied to clipboard

Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

Open pcantalupo opened this issue 11 months ago • 6 comments

Hello,

I'm trying to load a track file (bigWig) but am getting an error. The bigWig file comes from nfcore/rnaseq pipeline and is created by the UCSC program bedGraphtoBigWig. You can see that my SampleName matches the prefix of the bigWig filename. Not sure what I'm doing wrong.

Thank you

metadata = read.delim(opts$samplesheet)
metadata
            SampleName Type Group
1 24hpi_Dunlop.forward    A     B

list.files(opts$folder, pattern = metadata$SampleName)
[1] "24hpi_Dunlop.forward.bigWig"

track = LoadTrackFile(track.folder = opts$folder, format = "bw",
                      region = "chr16:67192155-67198918", meta.info = metadata)
Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

packageVersion("ggcoverage")
[1] ‘1.4.1’


> devtools::session_info()
─ Session info ───────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24)
 os       Red Hat Enterprise Linux
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/New_York
 date     2025-02-06
 rstudio  2023.03.0+386 Cherry Blossom (server)
 pandoc   2.5 @ /ihome/crc/install/pandoc/pandoc-2.5/bin/pandoc

─ Packages ───────────────────────────────────────────────────
 package              * version     date (UTC) lib source
 abind                  1.4-5       2016-07-21 [2] CRAN (R 4.4.0)
 Biobase                2.64.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 BiocGenerics         * 0.50.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 BiocIO                 1.14.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 BiocParallel           1.38.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 Biostrings             2.72.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 bitops                 1.0-7       2021-04-24 [2] CRAN (R 4.4.0)
 cachem                 1.1.0       2024-05-16 [2] CRAN (R 4.4.0)
 cli                    3.6.3       2024-06-21 [1] CRAN (R 4.4.0)
 codetools              0.2-20      2024-03-31 [2] CRAN (R 4.4.0)
 colorspace             2.1-0       2023-01-23 [2] CRAN (R 4.4.0)
 crayon                 1.5.3       2024-06-20 [1] CRAN (R 4.4.0)
 DelayedArray           0.30.1      2024-05-07 [2] Bioconductor 3.19 (R 4.4.0)
 devtools             * 2.4.5       2022-10-11 [2] CRAN (R 4.4.0)
 digest                 0.6.36      2024-06-23 [1] CRAN (R 4.4.0)
 dplyr                * 1.1.4       2023-11-17 [2] CRAN (R 4.4.0)
 ellipsis               0.3.2       2021-04-29 [2] CRAN (R 4.4.0)
 fansi                  1.0.6       2023-12-08 [2] CRAN (R 4.4.0)
 fastmap                1.2.0       2024-05-15 [2] CRAN (R 4.4.0)
 fs                     1.6.4       2024-04-25 [2] CRAN (R 4.4.0)
 generics               0.1.3       2022-07-05 [2] CRAN (R 4.4.0)
 GenomeInfoDb         * 1.40.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 GenomeInfoDbData       1.2.12      2024-05-18 [2] Bioconductor
 GenomicAlignments      1.40.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 GenomicRanges        * 1.56.0      2024-05-01 [2] Bioconductor 3.19 (R 4.4.0)
 getopt                 1.20.4      2023-10-01 [2] CRAN (R 4.4.0)
 ggcoverage           * 1.4.1       2025-02-06 [1] Github (showteeth/ggcoverage@6cd38ab)
 ggh4x                  0.3.0       2024-12-15 [1] CRAN (R 4.4.0)
 ggpattern            * 1.1.4       2025-01-29 [1] CRAN (R 4.4.0)
 ggplot2              * 3.5.1       2024-04-23 [2] CRAN (R 4.4.0)
 ggrepel                0.9.5       2024-01-10 [2] CRAN (R 4.4.0)
 glue                   1.7.0       2024-01-09 [2] CRAN (R 4.4.0)
 gridExtra              2.3         2017-09-09 [2] CRAN (R 4.4.0)
 gtable                 0.3.5       2024-04-22 [2] CRAN (R 4.4.0)
 htmltools              0.5.8.1     2024-04-04 [2] CRAN (R 4.4.0)
 htmlwidgets            1.6.4       2023-12-06 [2] CRAN (R 4.4.0)
 httpuv                 1.6.15      2024-03-26 [2] CRAN (R 4.4.0)
 httr                   1.4.7       2023-08-15 [2] CRAN (R 4.4.0)
 IRanges              * 2.38.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 jsonlite               1.8.8       2023-12-04 [2] CRAN (R 4.4.0)
 later                  1.3.2       2023-12-06 [2] CRAN (R 4.4.0)
 lattice                0.22-6      2024-03-20 [2] CRAN (R 4.4.0)
 lifecycle              1.0.4       2023-11-07 [2] CRAN (R 4.4.0)
 magrittr               2.0.3       2022-03-30 [2] CRAN (R 4.4.0)
 Matrix                 1.7-0       2024-03-22 [2] CRAN (R 4.4.0)
 MatrixGenerics         1.16.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 matrixStats            1.3.0       2024-04-11 [2] CRAN (R 4.4.0)
 memoise                2.0.1       2021-11-26 [2] CRAN (R 4.4.0)
 mime                   0.12        2021-09-28 [2] CRAN (R 4.4.0)
 miniUI                 0.1.1.1     2018-05-18 [2] CRAN (R 4.4.0)
 munsell                0.5.1       2024-04-01 [2] CRAN (R 4.4.0)
 optparse             * 1.7.5       2024-04-16 [2] CRAN (R 4.4.0)
 pacman                 0.5.1       2019-03-11 [2] CRAN (R 4.4.0)
 patchwork              1.2.0       2024-01-08 [2] CRAN (R 4.4.0)
 pillar                 1.9.0       2023-03-22 [2] CRAN (R 4.4.0)
 pkgbuild               1.4.4       2024-03-17 [2] CRAN (R 4.4.0)
 pkgconfig              2.0.3       2019-09-22 [2] CRAN (R 4.4.0)
 pkgload                1.3.4       2024-01-16 [2] CRAN (R 4.4.0)
 profvis                0.3.8       2023-05-02 [2] CRAN (R 4.4.0)
 promises               1.3.0       2024-04-05 [2] CRAN (R 4.4.0)
 purrr                  1.0.2       2023-08-10 [2] CRAN (R 4.4.0)
 R6                     2.5.1       2021-08-19 [2] CRAN (R 4.4.0)
 Rcpp                   1.0.12      2024-01-09 [2] CRAN (R 4.4.0)
 RCurl                  1.98-1.14   2024-01-09 [2] CRAN (R 4.4.0)
 remotes                2.5.0       2024-03-17 [2] CRAN (R 4.4.0)
 restfulr               0.0.15      2022-06-16 [2] CRAN (R 4.4.0)
 rjson                  0.2.21      2022-01-09 [2] CRAN (R 4.4.0)
 rlang                  1.1.4       2024-06-04 [1] CRAN (R 4.4.0)
 Rsamtools              2.20.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 rstudioapi             0.16.0      2024-03-24 [2] CRAN (R 4.4.0)
 rtracklayer          * 1.62.0      2023-10-24 [2] Bioconductor
 S4Arrays               1.4.0       2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 S4Vectors            * 0.42.1      2024-07-03 [1] Bioconductor 3.19 (R 4.4.0)
 scales                 1.3.0       2023-11-28 [2] CRAN (R 4.4.0)
 sessioninfo            1.2.2       2021-12-06 [2] CRAN (R 4.4.0)
 shiny                  1.8.1.1     2024-04-02 [2] CRAN (R 4.4.0)
 SparseArray            1.4.3       2024-05-07 [2] Bioconductor 3.19 (R 4.4.0)
 stringi                1.8.4       2024-05-06 [2] CRAN (R 4.4.0)
 stringr                1.5.1       2023-11-14 [2] CRAN (R 4.4.0)
 SummarizedExperiment   1.34.0      2024-05-01 [2] Bioconductor 3.19 (R 4.4.0)
 tibble                 3.2.1       2023-03-20 [2] CRAN (R 4.4.0)
 tidyselect             1.2.1       2024-03-11 [2] CRAN (R 4.4.0)
 UCSC.utils             1.0.0       2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 urlchecker             1.0.1       2021-11-30 [2] CRAN (R 4.4.0)
 usethis              * 2.2.3       2024-02-19 [2] CRAN (R 4.4.0)
 utf8                   1.2.4       2023-10-22 [2] CRAN (R 4.4.0)
 vctrs                  0.6.5       2023-12-01 [2] CRAN (R 4.4.0)
 withr                  3.0.0       2024-01-16 [2] CRAN (R 4.4.0)
 XML                    3.99-0.16.1 2024-01-22 [2] CRAN (R 4.4.0)
 xtable                 1.8-4       2019-04-21 [2] CRAN (R 4.4.0)
 XVector                0.44.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)
 yaml                   2.3.9       2024-07-05 [1] CRAN (R 4.4.0)
 zlibbioc               1.50.0      2024-04-30 [2] Bioconductor 3.19 (R 4.4.0)

 [1] /ihome//R/x86_64-pc-linux-gnu-library/4.4
 [2] /ihome/crc/install/gcc-12.2.0/r/4.4.0/lib64/R/library

pcantalupo avatar Feb 06 '25 16:02 pcantalupo

Hi! Have you found a solution for the problem? if not, can you provide a reproducible example, maybe with a reduced example file of your data?

m-jahn avatar Feb 18 '25 07:02 m-jahn

No luck.

You can try any one of the BigWig files from the example output of the nfcore-rnaseq pipeline. I just tried the GM12878_REP1.forward.bigWig file found here https://nf-co.re/rnaseq/3.18.0/results/rnaseq/results-b96a75361a4f1d49aa969a2b1c68e3e607de06e8/aligner_star_salmon/star_salmon/bigwig/ and it failed with the same error:

> metadata = data.frame(SampleName = c("GM12878_REP1.forward"), Type = "A", Group = "B")
> metadata
            SampleName Type Group
1 GM12878_REP1.forward    A     B
> list.files(".", pattern = metadata$SampleName)
[1] "GM12878_REP1.forward.bigWig"
> track = LoadTrackFile(track.folder = ".", format = "bw",
+                       region = "16:67192155-67198918", meta.info = metadata)
Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column
> packageVersion("ggcoverage")
[1] ‘1.4.1’

[ P.S. I edited my original post...changed "chr16" to "16" to match the genome naming. You still get the error either way ]

pcantalupo avatar Feb 18 '25 11:02 pcantalupo

I think it is because of the file ending. Can you to rename that file to end with .bw instead of .bigwig? Currently ggcoverage is quite strict when it comes to file formats.

m-jahn avatar Feb 18 '25 12:02 m-jahn

If this is the problem I will push a fix that will allow different variations of file endings and give a warning for non-comploiant files.

edit: I can reproduce the error when using .bigwig

m-jahn avatar Feb 18 '25 12:02 m-jahn

I also renamed from .bigwig to .bw and it worked.

danhtruong avatar Feb 27 '25 18:02 danhtruong

I made a fix for this that will be merged soon.

m-jahn avatar Feb 28 '25 17:02 m-jahn