Entering edit mode
Hi everyone,
I'm new to the pathview R package, and the whole bioinformatics, but have dissent experience with R.
I'm trying to create maps for different pathways using pathview::pathview(), and only in some of pathways (running the same code) I'm getting an error with "negative length vectors are not allowed".
For what I looked around it seems to be a problem with the dimensions of the dataset exceeding R limits. Has anyone found a way around this? As I said I'm new to pathview and I can't think of any loops around this.
Any help would be very appreciated!
Mauricio
## Fold change matrix with gene ID as row names.
gene.m <- matrix(c(1,1,-1,-1,-1), ncol =1)
gene.IDs <- c("120661193", "120708446", "120705740", "120672880", "120690206")
rownames(gene.m) <- gene.IDs
## Plot metabolic map
pathview(gene.data = gene.m, pathway.id = "01200",
species = "pvir", out.suffix = "Cmet1", kegg.native = T)
Warning: No annotation package for the species pvir, gene symbols not mapped!
Info: Working in directory C:/Users/mauri/Desktop/pathviewMaps
Info: Writing image file pvir01200.Cmet1.png
Info: some node width is different from others, and hence adjusted!
Error in array(col.rgb[, i], dim(node.rgb)[3:1]) :
negative length vectors are not allowed
sessionInfo( )
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggalluvial_0.12.5 ggVennDiagram_1.2.3 cowplot_1.1.1 ggplot2_3.4.2 dplyr_1.1.2 pathview_1.37.1
loaded via a namespace (and not attached):
[1] Biobase_2.58.0 httr_1.4.6 pkgload_1.3.2 bit64_4.0.5 shiny_1.7.4
[6] stats4_4.2.2 blob_1.2.4 GenomeInfoDbData_1.2.9 remotes_2.4.2 sessioninfo_1.2.2
[11] pillar_1.9.0 RSQLite_2.3.1 glue_1.6.2 digest_0.6.31 promises_1.2.0.1
[16] XVector_0.38.0 RVenn_1.1.0 colorspace_2.0-3 htmltools_0.5.4 httpuv_1.6.7
[21] XML_3.99-0.14 pkgconfig_2.0.3 devtools_2.4.5 zlibbioc_1.44.0 purrr_1.0.0
[26] xtable_1.8-4 scales_1.2.1 processx_3.8.0 later_1.3.0 tibble_3.2.1
[31] KEGGREST_1.38.0 generics_0.1.3 IRanges_2.32.0 usethis_2.1.6 ellipsis_0.3.2
[36] cachem_1.0.6 withr_2.5.0 BiocGenerics_0.44.0 cli_3.5.0 magrittr_2.0.3
[41] crayon_1.5.2 mime_0.12 memoise_2.0.1 ps_1.7.2 KEGGgraph_1.58.3
[46] fs_1.5.2 fansi_1.0.3 pkgbuild_1.4.0 graph_1.76.0 profvis_0.3.7
[51] tools_4.2.2 prettyunits_1.1.1 org.Hs.eg.db_3.16.0 lifecycle_1.0.3 stringr_1.5.0
[56] S4Vectors_0.36.2 munsell_0.5.0 AnnotationDbi_1.60.2 callr_3.7.3 Biostrings_2.66.0
[61] compiler_4.2.2 GenomeInfoDb_1.34.9 rlang_1.1.1 grid_4.2.2 RCurl_1.98-1.12
[66] rstudioapi_0.14 htmlwidgets_1.6.0 miniUI_0.1.1.1 bitops_1.0-7 gtable_0.3.1
[71] DBI_1.1.3 curl_4.3.3 R6_2.5.1 fastmap_1.1.0 bit_4.0.5
[76] utf8_1.2.2 rprojroot_2.0.3 desc_1.4.2 Rgraphviz_2.42.0 stringi_1.7.8
[81] Rcpp_1.0.9 vctrs_0.6.3 png_0.1-8 tidyselect_1.2.0 urlchecker_1.0.1
You have raised an intriguing problem. I believe this is an issue specific for this pathway (i.e. 'Carbon metabolism'), but maybe also for other pathways; AFAIK this is likely caused by the way KEGG show/represent the graphical representation of this pathway in its corresponding KGML file.
If you for example check online the 'TCA Cycle' pathway on the KEGG website, you will see a so-called native KEGG map in which circles are connected by arrows. In this particular map the circles are metabolites, and the (black) arrows represent the genes coding for the enzymes/proteins that catalyze the reaction. For each arrow there is a box that shows the actual EC identifier (or name) of the corresponding gene/protein. Note that not all genes have been annotated for your organism (these are the white boxes). AFAIK, all these information, including the position on the map of the boxes, direction of arrows, etc, is stored in the KGML file. Note that for this pathway switchgrass-specific expression data can be overlaid on the native KEGG representation (see below).
If you then view online the (your) 'Carbon metabolism' pathway, you will see a native KEGG map in which circles are connected by arrows, but the boxes are missing. The EC identifier of the corresponding gene(s) is only visible if you mouse over the green arrows.
Thus, since there are no boxes present in the native KEGG view of the 'Carbon metabolism' pathway, it seems to me that information on their position on the map is absent in the KGML file. As a consequence,
pathview
isn't able to visualize/overlay the gene expression data on the native KEGG representation. I believe that is the reason you got that rather cryptic error.But... somehow this isn't the full story, because if you check the 'Biosynthesis of amino acids' pathway, you will see a similar representation as the 'Carbon metabolism' pathway (i.e. no boxes present). When you try to visualize expression data using default settings, you get the same error as for the 'Carbon metabolism' pathway'. Yet, if you set the argument
same.layer = FALSE
(default:same.layer = TRUE
), somehow a native KEGG representation of the map is exported (aspng
), on which (part of?) the expression data is overlaid. Admittedly, it is not a nice picture.To make it even more complex: if you would set
kegg.native = FALSE
(default:kegg.native = TRUE
), then a so-called de novo network-representation of the pathway is exported (asPDF
) on which the expression data is overlaid. This works for the 'Carbon metabolism' pathway, because it is now a network representation of the map, in which the nodes and edges do not have a fixed spatial position (as they rather have on the native KEGG map). Unfortunately, the layout of the network isn't nice, and AFAIK it can not be improved by e.g. exporting the resulting network to Cytoscape. So in the end, this network-representation may not be of much value...So, in the end I don't know how to solve your problem...
See post below for some code and pictures.
Post 2; with some example code + graphs to illustrate the points raised above.
Just ran into this same issue with ko01232 (Nucleotide metabolism)
Same for N-glycan metabolism-- fails with
same.layer = TRUE
, smudges and comet-like shading withsame.layer = FALSE
, crowded web withkegg.native = FALSE
,