PoisonAlien / maftools

Summarize, Analyze and Visualize MAF files from TCGA or in-house studies.
http://bioconductor.org/packages/release/bioc/html/maftools.html
MIT License
452 stars 222 forks source link

The get_col_df function seems to have a bug in the 6th line #1026

Closed canna1998 closed 2 months ago

canna1998 commented 5 months ago

Describe the issue

Thanks for your work and selfless sharing, I'd like to point out a bug.

The get_col_df function referenced in coBarplot seemingly has a bug in the sixth line.

ml = apply(createOncoMatrix(
    m = m, g = g, chatty = FALSE, add_missing = TRUE)[['oncoMatrix']],
    1, table, simplify = FALSE)

https://github.com/PoisonAlien/maftools/commit/f06d8e80fbfa2854402c795d3684ae7fa6a6e2d0

It seems that this commit should not be accepted and the old code should be restored. I was able to run coBarplot and get_col_df function with the original code.

But I can't understand why adding simplify results in errors no matter what the assignment is. I hope you can give me your advice.

I'm not comfortable giving the original Maf file, so I provide the middle result createOncoMatrix( m = m, g = g, chatty = FALSE, add_missing = TRUE)[['oncoMatrix']]

Command

get_col_df_sample_data.csv

t4 <- read_csv("output/get_col_df_sample_data.csv")
t4$...1 <- NULL

# this works
apply(t4, 1, table)

#  those didn't work
apply(t4, 1, table, simplify = F)
# Error in FUN(newX[, i], ...) : all arguments must have the same length

apply(t4, 1, table, simplify = T)
# Error in FUN(newX[, i], ...) : all arguments must have the same length

Session info

R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 13.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8

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

other attached packages:
 [1] RColorBrewer_1.1-3 maftools_2.20.1    readxl_1.4.0       forcats_0.5.2      stringr_1.5.0      dplyr_1.1.3        purrr_0.3.4        readr_2.1.2       
 [9] tidyr_1.2.0        tibble_3.2.1       ggplot2_3.3.6      tidyverse_1.3.2   

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0    DNAcopy_1.64.0      splines_4.0.5       haven_2.4.3         gargle_1.2.1        lattice_0.20-45     colorspace_2.0-3    vctrs_0.6.3        
 [9] generics_0.1.3      utf8_1.2.2          survival_3.3-1      rlang_1.1.1         pillar_1.9.0        glue_1.6.2          withr_2.5.0         DBI_1.1.3          
[17] bit64_4.0.5         dbplyr_2.2.1        modelr_0.1.9        lifecycle_1.0.3     munsell_0.5.0       gtable_0.3.1        cellranger_1.1.0    rvest_1.0.3        
[25] tzdb_0.3.0          parallel_4.0.5      fansi_1.0.3         broom_1.0.1         BiocManager_1.30.22 scales_1.2.1        backports_1.4.1     googlesheets4_1.0.1
[33] vroom_1.5.7         jsonlite_1.8.7      bit_4.0.4           fs_1.5.2            hms_1.1.2           stringi_1.7.6       grid_4.0.5          cli_3.6.1          
[41] tools_4.0.5         magrittr_2.0.3      crayon_1.5.2        pkgconfig_2.0.3     ellipsis_0.3.2      Matrix_1.4-1        data.table_1.14.2   xml2_1.3.3         
[49] reprex_2.0.2        googledrive_2.0.0   lubridate_1.8.0     assertthat_0.2.1    httr_1.4.7          rstudioapi_0.15.0   R6_2.5.1            compiler_4.0.5 
PoisonAlien commented 5 months ago

Hi,

Thank you for the issue. Could you please post the original command and the error?

canna1998 commented 5 months ago

Hi,

Thank you for the issue. Could you please post the original command and the error?

Of course.

coBarplot(m1 = a1_maf_cnv, m2 = a2_maf_cnv, m1Name = "A1", m2Name = "A2", genes = genes)
# Error in FUN(newX[, i], ...) : all arguments must have the same length

then I use debug() function and find problem in get_col_df function.

canna1998 commented 4 months ago

Well, I figured out what the problem is.

In the 4.0.5 base package, the apply function does not have simplify parameter, but in versions 4.1.0 and above, this code is fine.