Update liana_plot.R - #199
Open
Dataxplora wants to merge 1 commit into
Open
Conversation
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 (<span style='color:red;'>) for red text. Recombine genes into interaction labels (e.g., GENE1_<span style='color:red;'>GENE2</span> -> 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: 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.