Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monarch plot theme #40

Open
5 tasks
bschilder opened this issue Aug 23, 2024 · 2 comments
Open
5 tasks

monarch plot theme #40

bschilder opened this issue Aug 23, 2024 · 2 comments

Comments

@bschilder
Copy link
Contributor

bschilder commented Aug 23, 2024

I think it would be nice to have a theme_monarch function that gives plots some useful attributes.
Relates to #24.

1.

  • Provide consistent colors for categories, predicates, etc. Atm the colors are just the ggplot defaults, which randomly assign the default colors to whichever variable comes first. This makes it harder to compare plots with semi-overlapping sets of categories.

For example

immune <- monarch_search("immune system",  category = "biolink:Disease")|>
	expand(predicates = "biolink:subclass_of") |>
	expand(predicates = "biolink:has_phenotype",
         categories = "biolink:PhenotypicFeature") |>
	expand(categories = "biolink:Gene")
immune|>
	activate(nodes)|> 
	filter(pcategory %in% c("biolink:Disease", "biolink:PhenotypicFeature")) |> 
	activate(edges)|>
  filter(tidygraph::edge_is_between(which(nodes(g)$pcategory=="biolink:Disease"),
  																	which(nodes(g)$pcategory=="biolink:Disease"), 
  																	ignore_dir=TRUE)) |>
	activate(nodes) |>
	filter(!node_is_isolated()) |>
	plot(layout="fr")

PhenotypicFeature is turquoise:
image

immune|>
	activate(nodes)|> 
	sample_n(1000) |>
	activate(edges)|>
  filter(tidygraph::edge_is_between(which(nodes(g)$pcategory=="biolink:Disease"),
  																	which(nodes(g)$pcategory=="biolink:Disease"), 
  																	ignore_dir=TRUE)) |>
	activate(nodes) |>
	filter(!node_is_isolated()) |>
	plot(layout="fr")

PhenotypicFeature is now blue:
image

2.

  • Use different palettes for categories vs. predicates vs. etc. This avoids using the same colors to indicates different concepts.

3.

palette <- c("#2c8c9a","#79e4e7","#a7ecf3","#fafafa","white")

Screenshot 2024-08-23 at 11 55 30

4.

  • Could even use the same icons that Monarch uses for Phenotypes/Disease/Genes/etc. Image resources here.

Screenshot 2024-08-23 at 11 35 38

5.

  • Pretty layouts, especially when plotting in different common use cases (eg gene-pheno-disease relationships with lots of connections). Edge bundling with gggraph::geom_edge_bundle_force2 can be very helpful here for making hairballs more manageable.
@oneilsh
Copy link
Collaborator

oneilsh commented Aug 27, 2024

Very much agreed and great ideas, thanks for working on this! One challenge might be that different KGs have different category/relationship labels, so hard-coding a palette against them could be tricky. One option is to use the kg prefs feature (I'm starting to wonder how much to lean on that...).

Another trick I've used in the past for similar issues is to generate a largish palette, and then hash labels and map them to an int mod the palette size to identify a psuedo-random color choice that is repeatable.

@bschilder
Copy link
Contributor Author

Very much agreed and great ideas, thanks for working on this! One challenge might be that different KGs have different category/relationship labels, so hard-coding a palette against them could be tricky. One option is to use the kg prefs feature (I'm starting to wonder how much to lean on that...).

Very true, I was thinking of only using the hard-coded palette when the KG is the official Monarch KG.

Another trick I've used in the past for similar issues is to generate a largish palette, and then hash labels and map them to an int mod the palette size to identify a psuedo-random color choice that is repeatable.

For all other KGs, doing something like this seems like the best way to go.

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

No branches or pull requests

2 participants