I am performing Reactome pathway analysis using the enrichPathway function in R on two different gene datasets. Although the analysis completes and generates pathway results, I'm encountering an issue when trying to visualize the data with a bar plot.
Here’s the workflow I’ve followed:
I used BiomaRt to convert Ensembl gene IDs to Entrez IDs for two datasets (data_sheet1 and data_sheet2). I ran enrichPathway on both datasets and obtained a reasonable number of pathways (1397 for sheet 1, 1539 for sheet 2). However, when I attempt to create a barplot using barplot(reactome_results_sheet1, showCategory = 10, title = "Top Reactome Pathways (Sheet 1)"), I get the following error: scss Copy code Error in ans[ypos] <- rep(yes, length.out = len)[ypos]: replacement has length zero Warning message: In rep(yes, length.out = len) : 'x' is NULL so the result will be NULL Despite this error, calling head(reactome_results_sheet1@result) shows that pathways were successfully enriched and reported.
Additional Information:
I have verified that both datasets contain valid gene IDs and the enrichment ran without any errors. I tried checking the length of reactome_results_sheet1@result$ID which returns the expected number of pathways. The issue seems to be with the plotting step. Could anyone suggest why this error might be occurring and how I can resolve it? I would appreciate any help on this.