Closed Huan-Jui-Chang closed 11 months ago
I think the work-around implemented to resolve this second issue (which simply colors all unaffected nodes white) cannot work in the case where the number of nodes in the pathway is larger. than a certain number. I'll try to check and confirm thiis over the weekend. see https://github.com/egeulgen/pathfindR/issues/125#issuecomment-1182004840
hello again. As I commented above, KEGG unfortunately restricts the number of nodes to color. In the function here: https://github.com/egeulgen/pathfindR/blob/master/R/visualization.R#L658 I had to discard the colors of background (unaffected, white) genes if the number is larger than 60 as KEGG refuses to handle this. Sorry for the inconvenience, I'll keep this in mind still and try to figure out a solution but it seems unlikely.
Meanwhile, my suggestion is to change the following argument when calling visualize_terms()
:
node_cols low, middle and high color values for coloring the pathway nodes
#' (default = \code{NULL}). If \code{node_cols=NULL}, the low, middle and high color
#' are set as "green", "gray" and "red"...
i.e. something like:
visualize_terms(
result_df = output_df,
input_processed = input_processed,
hsa_KEGG = TRUE
node_cols = c("purple", "gray", "red')
)
Hi,
I'm reopening this issue because I'm still having this problem. Even after changing the color gradient, all plots are still only colored as a light green. See below.
Hi @lucasrocmoreira
I suspected my above comment is (part of) the issue here:
KEGG unfortunately restricts the number of nodes to color.
In pathfindR, we use the KEGG REST API to color each input node(gene). We try to color the backgrounds of all non-input colours as white (some of these are light green in KEGG already, for your example, see here: https://www.kegg.jp/pathway/hsa00010). However, KEGG restricts the number of nodes we can colour through their API. As such, if the number of nodes to color (the input genes + background genes that may already be green), we discard any colour that is white (here in the source code). Currently, we don't have a good workaround for this as we have to rely on KEGG for this functionality. I will keep this issue updated if there is any possible resolution for this issue.
The input genes that you provide should still come up as coloured in the final image. Can't be sure why that is happening so it would good to debug further. Can you provide the input data/code so I can try to reproduce the issue and hopefully resolve it?
Thank you for the quick response, @egeulgen
This is my input file: input_df.csv
I ran the following commands:
output_df.KEGG.NvsH <- run_pathfindR(input_df.NvsH,
gene_sets = "KEGG",
p_val_threshold = 0.05,
output_dir = "pathfindR_KEGG.37vs41")
input_processed.NvsH <- input_processing(input_df.NvsH)
visualize_terms(
result_df = output_df.KEGG.NvsH,
input_processed = input_processed.NvsH,
hsa_KEGG = TRUE
)
It seems that this a more general problem.
It's how KEGGREST
(the R package that pathfindR
depends on for this functionality) interacts with KEGG, their KEGGREST::color.pathway.by.objects
function is not functioning properly any more. I'm not sure if it's resolvable but I will reach out to the maintainers with the bug.
it looks like KEGG does not allow fetching the coloured pathway diagrams directly through the POST requests any more, I don't think it's fixable. I'll try and see alternative solutions and keep you updated
@lucasrocmoreira thanks again for reporting this. The latest dev version of pathfindR
now uses ggkegg
instead of KEGGREST
for getting coloured KEGG pathway diagrams. You can download the latest dev version via:
install.packages("devtools") # if you have not installed "devtools"
devtools::install_github("egeulgen/pathfindR")
Note that visualize_terms()
will now return a list of ggraph
objects (essentially ggplot
objects) that contain the visualisations. You can save each visualisation in your desired format (example provided for pdf format):
gg_list <- visualize_terms(
result_df = output_df.KEGG.NvsH,
input_processed = input_processed.NvsH,
hsa_KEGG = TRUE
)
ggplot2::ggsave(
"pathway_vis.pdf", # path to output, format is determined by extension
gg_list$hsa00010, # what to plot
width = 5 # adjust width
height = 5 # adjust height
)
This will be part of the next release but until then is available in the dev version.
Describe the bug Hi! I'm using the visualize_terms() function to graph the enriched proteins onto KEGG pathway diagram. However I've encountered the following two issues:
UnableToReadFont `helvetica'
|====================================================================================| 100% Saving colored pathway diagrams of 10 KEGG pathways
| | 0%Error: rsession-arm64: UnableToReadFont `helvetica' @ error/annotate.c/RenderFreetype/1396
|====================================================================================| 100% Saving colored pathway diagrams of 10 KEGG pathways
|====================================================================================| 100%
KEGG proteins not showing the proper color
devtools::install_github("Bioconductor/KEGGREST")
Desktop (please complete the following information):
R Session Information:
Additional context Thanks in advanced for your help!