Skip to content

Update liana_plot.R - #199

Open
Dataxplora wants to merge 1 commit into
saezlab:masterfrom
Dataxplora:patch-1
Open

Update liana_plot.R#199
Dataxplora wants to merge 1 commit into
saezlab:masterfrom
Dataxplora:patch-1

Conversation

@Dataxplora

Copy link
Copy Markdown

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.

sample_updated_liana_plot sample_original_liana_plot

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant