BDI-pathogens / phyloscanner

Phylogenetics between and within hosts at once, all along the genome.
GNU General Public License v3.0
44 stars 14 forks source link

classify_relationships.R Error in if (is.na(assocs[[node.no]])) { : argument is of length zero #43

Closed magosil86 closed 5 years ago

magosil86 commented 5 years ago

Hi Matthew,

I am getting an error when running phyloscanner's classify_relationships.R script as a part of the Phyloscanner.R.utilities workflow. It looks like the error occurs when the classify function calls the output.trans.tree function in collapsed_tree_methods.R. I might be missing something here, any suggestions? I have also attached some data to help reproduce the problem pty_19-04-28-19-03-59.zip

$ Rscript ~/phyloscanner-master/tools/classify_relationships.R "pty_19-04-28-19-03-59/ProcessedTree_s_ptyr5_" "pty_19-04-28-19-03-59/subgraphs_s_ptyr5_" "pty_19-04-28-19-03-59/ptyr5" --branchLengthNormalisation "pty_19-04-28-19-03-59/ptyr5_normconst.csv" --verbose

Reading tree file pty_19-04-28-19-03-59/ProcessedTree_s_ptyr5_InWindow_1525_to_1774.tree...
Reading annotations...
Reading splits file pty_19-04-28-19-03-59/subgraphs_s_ptyr5_InWindow_1525_to_1774.csv ...
Parsed with column specification:
cols(
  host = col_character(),
  subgraph = col_character(),
  tip = col_character()
)
Collecting tips for each host...
Collapsing subgraphs...
Error in if (is.na(assocs[[node.no]])) { : argument is of length zero
Calls: classify -> output.trans.tree
Execution halted

Session Info:

R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.3

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

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

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

other attached packages:
[1] kimisc_0.4          ggtree_1.14.6       phangorn_2.4.0     
[4] phytools_0.6-60     maps_3.3.0          ape_5.3            
[7] phyloscannerR_1.6.7 argparse_2.0.1     

loaded via a namespace (and not attached):
 [1] viridis_0.5.1           httr_1.4.0              tidyr_0.8.3            
 [4] jsonlite_1.6            viridisLite_0.3.0       network_1.14-377       
 [7] modelr_0.1.4            assertthat_0.2.1        expm_0.999-3           
[10] rvcheck_0.1.3           animation_2.6           cellranger_1.1.0       
[13] numDeriv_2016.8-1       pillar_1.3.1            backports_1.1.3        
[16] lattice_0.20-38         glue_1.3.1              quadprog_1.5-5         
[19] digest_0.6.18           RColorBrewer_1.1-2      rvest_0.3.2            
[22] colorspace_1.4-1        Matrix_1.2-16           plyr_1.8.4             
[25] pkgconfig_2.0.2         broom_0.5.1             haven_2.1.0            
[28] purrr_0.3.2             tidytree_0.2.4          scales_1.0.0           
[31] ff_2.2-14               tibble_2.1.1            combinat_0.0-8         
[34] generics_0.0.2          ggplot2_3.1.0           tidyverse_1.2.1        
[37] lazyeval_0.2.2          mnormt_1.5-5            magrittr_1.5           
[40] crayon_1.3.4            readxl_1.3.1            memoise_1.1.0          
[43] GGally_1.4.0            nlme_3.1-137            MASS_7.3-51.1          
[46] forcats_0.4.0           xml2_1.2.0              tools_3.5.2            
[49] hms_0.4.2               extraDistr_1.8.10       stringr_1.4.0          
[52] findpython_1.0.5        munsell_0.5.0           plotrix_3.7-4          
[55] compiler_3.5.2          clusterGeneration_1.3.4 rlang_0.3.2            
[58] grid_3.5.2              igraph_1.2.4            gtable_0.2.0           
[61] reshape_0.8.8           reshape2_1.4.3          R6_2.4.0               
[64] gridExtra_2.3           lubridate_1.7.4         dplyr_0.8.0.1          
[67] bit_1.1-14              fastmatch_1.1-0         treeio_1.6.2           
[70] readr_1.3.1             stringi_1.4.3           parallel_3.5.2         
[73] Rcpp_1.0.1              scatterplot3d_0.3-41    tidyselect_0.2.5       
[76] coda_0.19-2            
mdhall272 commented 5 years ago

This appears to be the result of a change in how treeio works, although I'm also confused by the lack of annotations for most nodes in the processed tree file you sent. Could you send me the command you used to generate that?

(We hope to retire phyloscanner.R.utilities imminently, by the way. The legacy scripts in /tools are also best avoided in favour of getting to grips with phyloscannerR.)

EDIT: less confused now, please disregard. I'll see what can be done.

mdhall272 commented 5 years ago

This was indeed due to a change to treeio that appeared a couple of weeks ago. Does it work now?

magosil86 commented 5 years ago

Yes, it works now, many thanks! With regards to phyloscanner.R.utilities, does that mean the functionality will be now integrated into phyloscannerR so that I can look out for updates in the phyloscanner manual? Also is the imminent retirement in terms weeks or months?

mdhall272 commented 5 years ago

All the functionality should move here. I'm not sure when exactly, but the code exists and it's just a matter of finalising it and merging.