Update liana_plot.R
Summary This pull request introduces a gene highlighting feature to the liana_dotplot function, enabling users to highlight specific genes of interest in red within the interaction labels on the y-axis. The feature is optional, controlled by the new highlight_genes parameter, and maintains full backward compatibility with existing functionality.
Changes New Parameter: Added highlight_genes (character vector, default: NULL) to specify genes to be highlighted in red in the interaction labels.
Highlighting Logic: Implemented logic to:
Split ligand and receptor complexes into individual genes using stringr::strsplit. Format matching genes in highlight_genes with HTML () for red text. Recombine genes into interaction labels (e.g., GENE1_GENE2 -> GENE3).
Rendering: Used ggtext::element_markdown to enable HTML rendering of y-axis labels for highlighted genes.
Caption: Added a dynamic plot caption that appears when highlight_genes is provided, stating: "Red-colored genes indicate those specified in highlight_genes." Documentation: Updated Roxygen comments to:
Document the highlight_genes parameter and its usage. Describe the highlighting behavior in the @details section. Include new dependencies (stringr, ggtext).
Dependencies: Added imports for stringr::strsplit and ggtext::element_markdown to support the new functionality.
Inline Comments: Added # NEW: and # MODIFIED: comments to highlight changes and clarify the gene highlighting logic for reviewers.
Testing Tested with sample liana_res data to ensure:
liana_test %>% liana_dotplot(source_groups = c("B"), target_groups = c("NK", "CD8 T", "B"), ntop = 20, highlight_genes = c('LTB','ITGB2','CD48', 'CD2'))
Genes specified in highlight_genes are correctly highlighted in red on the y-axis. The plot renders as expected when highlight_genes = NULL, matching the original behavior. The caption appears only when highlight_genes is provided and correctly reflects the highlighting.