Skip to content

Commit

Permalink
Reformat README
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Nov 8, 2023
1 parent b829efb commit b6d8fb5
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 121 deletions.
123 changes: 64 additions & 59 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -54,47 +54,51 @@ library(tidygraph)
library(dplyr)
pathway("ko01100") |>
process_line() |>
highlight_module(module("M00021")) |>
highlight_module(module("M00338")) |>
ggraph(x=x, y=y) +
geom_node_point(size=1, aes(color=I(fgcolor),
filter=fgcolor!="none" & type!="line"))+
geom_edge_link0(width=0.1, aes(color=I(fgcolor),
filter=type=="line"& fgcolor!="none"))+
with_outer_glow(
geom_edge_link0(width=1,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
)+
with_outer_glow(
geom_node_point(size=1.5,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
)+
geom_node_text(size=2,
aes(x=x, y=y,
label=graphics_name,
filter=name=="path:ko00270"),
repel=TRUE, family="sans", bg.colour="white")+
theme_void()
process_line() |>
highlight_module(module("M00021")) |>
highlight_module(module("M00338")) |>
ggraph(x=x, y=y) +
geom_node_point(size=1, aes(color=I(fgcolor),
filter=fgcolor!="none" & type!="line")) +
geom_edge_link0(width=0.1, aes(color=I(fgcolor),
filter=type=="line"& fgcolor!="none")) +
with_outer_glow(
geom_edge_link0(width=1,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
) +
with_outer_glow(
geom_node_point(size=1.5,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
) +
geom_node_text(size=2,
aes(x=x, y=y,
label=graphics_name,
filter=name=="path:ko00270"),
repel=TRUE, family="sans", bg.colour="white") +
theme_void()
```

You can use your favorite geoms to annotate raw KEGG map combining the functions.

```{r, message=FALSE, warning=FALSE, fig.width=8, fig.height=5}
m <- module("M00013")
g <- pathway("ko00640") |> mutate(mod=highlight_set_nodes(m@reaction_components,how="all"))
gg <- ggraph(g, layout="manual", x=x, y=y)+
geom_node_rect(fill="grey",aes(filter=type=="ortholog"))+
overlay_raw_map("ko00640")+
geom_node_point(aes(filter=type=="compound"), shape=21, fill="blue", color="black", size=2)+
ggfx::with_outer_glow(geom_node_point(aes(filter=mod, x=x, y=y), color="red",size=2),
colour="yellow",expand=5)+
theme_void()
gg
compounds <- c("cpd:C00100", "cpd:C00894", "cpd:C00894", "cpd:C05668",
"cpd:C05668", "cpd:C01013", "cpd:C01013", "cpd:C00222",
"cpd:C00222", "cpd:C00024")
g <- pathway("ko00640") |> mutate(mod=highlight_set_nodes(compounds, how="all"))
ggraph(g, layout="manual", x=x, y=y)+
geom_node_rect(fill="grey",aes(filter=type == "ortholog"))+
overlay_raw_map("ko00640")+
geom_node_point(aes(filter=type == "compound"),
shape=21, fill="blue", color="black", size=2)+
ggfx::with_outer_glow(
geom_node_point(aes(filter=mod, x=x, y=y), color="red",size=2),
colour="yellow",expand=5
)+
theme_void()
```

Or customize graphics based on `ggraph`.
Expand All @@ -105,27 +109,28 @@ pseudo_lfc <- sample(seq(0,3,0.1), length(V(g)), replace=TRUE)
names(pseudo_lfc) <- V(g)$name
ggkegg("hsa04110",
convert_org = c("pathway","hsa","ko"),
numeric_attribute = pseudo_lfc)+
geom_edge_parallel2(
aes(color=subtype_name),
arrow = arrow(length = unit(1, 'mm')),
start_cap = square(1, 'cm'),
end_cap = square(1.5, 'cm')) +
geom_node_rect(aes(filter=.data$type=="group"),
fill="transparent", color="red")+
geom_node_rect(aes(fill=numeric_attribute,
filter=.data$type=="gene"))+
geom_node_text(aes(label=converted_name,
filter=.data$type == "gene"),
size=2.5,
color="black")+
with_outer_glow(geom_node_text(aes(label=converted_name,
filter=converted_name=="PCNA"),
size=2.5, color="red"),
colour="white",
expand=4)+
scale_edge_color_manual(values=viridis::plasma(11))+
scale_fill_viridis(name="LFC")+
theme_void()
convert_org = c("pathway","hsa","ko"),
numeric_attribute = pseudo_lfc)+
geom_edge_parallel2(
aes(color=subtype_name),
arrow = arrow(length = unit(1, 'mm')),
start_cap = square(1, 'cm'),
end_cap = square(1.5, 'cm')) +
geom_node_rect(aes(filter=.data$type == "group"),
fill="transparent", color="red") +
geom_node_rect(aes(fill=numeric_attribute,
filter=.data$type == "gene")) +
geom_node_text(aes(label=converted_name,
filter=.data$type == "gene"),
size=2.5,
color="black") +
with_outer_glow(
geom_node_text(aes(label=converted_name,
filter=converted_name=="PCNA"),
size=2.5, color="red"),
colour="white", expand=4
) +
scale_edge_color_manual(values=viridis::plasma(11)) +
scale_fill_viridis(name="LFC") +
theme_void()
```
130 changes: 68 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Using `BiocManager`:
``` r
BiocManager::install("ggkegg")
```

Using `devtools`:

``` r
Expand All @@ -37,53 +38,57 @@ library(tidygraph)
library(dplyr)

pathway("ko01100") |>
process_line() |>
highlight_module(module("M00021")) |>
highlight_module(module("M00338")) |>
ggraph(x=x, y=y) +
geom_node_point(size=1, aes(color=I(fgcolor),
filter=fgcolor!="none" & type!="line"))+
geom_edge_link0(width=0.1, aes(color=I(fgcolor),
filter=type=="line"& fgcolor!="none"))+
with_outer_glow(
geom_edge_link0(width=1,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
)+
with_outer_glow(
geom_node_point(size=1.5,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
)+
geom_node_text(size=2,
aes(x=x, y=y,
label=graphics_name,
filter=name=="path:ko00270"),
repel=TRUE, family="sans", bg.colour="white")+
theme_void()
process_line() |>
highlight_module(module("M00021")) |>
highlight_module(module("M00338")) |>
ggraph(x=x, y=y) +
geom_node_point(size=1, aes(color=I(fgcolor),
filter=fgcolor!="none" & type!="line")) +
geom_edge_link0(width=0.1, aes(color=I(fgcolor),
filter=type=="line"& fgcolor!="none")) +
with_outer_glow(
geom_edge_link0(width=1,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
) +
with_outer_glow(
geom_node_point(size=1.5,
aes(color=I(fgcolor),
filter=(M00021 | M00338))),
colour="red", expand=5
) +
geom_node_text(size=2,
aes(x=x, y=y,
label=graphics_name,
filter=name=="path:ko00270"),
repel=TRUE, family="sans", bg.colour="white") +
theme_void()
```

<img src="man/figures/README-unnamed-chunk-2-1.png" width="2400" style="display: block; margin: auto;" />
<img src="man/figures/README-unnamed-chunk-3-1.png" width="2400" style="display: block; margin: auto;" />

You can use your favorite geoms to annotate raw KEGG map combining the
functions.

``` r
m <- module("M00013")
g <- pathway("ko00640") |> mutate(mod=highlight_set_nodes(m@reaction_components,how="all"))
gg <- ggraph(g, layout="manual", x=x, y=y)+
geom_node_rect(fill="grey",aes(filter=type=="ortholog"))+
overlay_raw_map("ko00640")+
geom_node_point(aes(filter=type=="compound"), shape=21, fill="blue", color="black", size=2)+
ggfx::with_outer_glow(geom_node_point(aes(filter=mod, x=x, y=y), color="red",size=2),
colour="yellow",expand=5)+
theme_void()
gg
compounds <- c("cpd:C00100", "cpd:C00894", "cpd:C00894", "cpd:C05668",
"cpd:C05668", "cpd:C01013", "cpd:C01013", "cpd:C00222",
"cpd:C00222", "cpd:C00024")
g <- pathway("ko00640") |> mutate(mod=highlight_set_nodes(compounds, how="all"))
ggraph(g, layout="manual", x=x, y=y)+
geom_node_rect(fill="grey",aes(filter=type == "ortholog"))+
overlay_raw_map("ko00640")+
geom_node_point(aes(filter=type == "compound"),
shape=21, fill="blue", color="black", size=2)+
ggfx::with_outer_glow(
geom_node_point(aes(filter=mod, x=x, y=y), color="red",size=2),
colour="yellow",expand=5
)+
theme_void()
```

<img src="man/figures/README-unnamed-chunk-3-1.png" width="2400" style="display: block; margin: auto;" />
<img src="man/figures/README-unnamed-chunk-4-1.png" width="2400" style="display: block; margin: auto;" />

Or customize graphics based on `ggraph`.

Expand All @@ -93,29 +98,30 @@ pseudo_lfc <- sample(seq(0,3,0.1), length(V(g)), replace=TRUE)
names(pseudo_lfc) <- V(g)$name

ggkegg("hsa04110",
convert_org = c("pathway","hsa","ko"),
numeric_attribute = pseudo_lfc)+
geom_edge_parallel2(
aes(color=subtype_name),
arrow = arrow(length = unit(1, 'mm')),
start_cap = square(1, 'cm'),
end_cap = square(1.5, 'cm')) +
geom_node_rect(aes(filter=.data$type=="group"),
fill="transparent", color="red")+
geom_node_rect(aes(fill=numeric_attribute,
filter=.data$type=="gene"))+
geom_node_text(aes(label=converted_name,
filter=.data$type == "gene"),
size=2.5,
color="black")+
with_outer_glow(geom_node_text(aes(label=converted_name,
filter=converted_name=="PCNA"),
size=2.5, color="red"),
colour="white",
expand=4)+
scale_edge_color_manual(values=viridis::plasma(11))+
scale_fill_viridis(name="LFC")+
theme_void()
convert_org = c("pathway","hsa","ko"),
numeric_attribute = pseudo_lfc)+
geom_edge_parallel2(
aes(color=subtype_name),
arrow = arrow(length = unit(1, 'mm')),
start_cap = square(1, 'cm'),
end_cap = square(1.5, 'cm')) +
geom_node_rect(aes(filter=.data$type == "group"),
fill="transparent", color="red") +
geom_node_rect(aes(fill=numeric_attribute,
filter=.data$type == "gene")) +
geom_node_text(aes(label=converted_name,
filter=.data$type == "gene"),
size=2.5,
color="black") +
with_outer_glow(
geom_node_text(aes(label=converted_name,
filter=converted_name=="PCNA"),
size=2.5, color="red"),
colour="white", expand=4
) +
scale_edge_color_manual(values=viridis::plasma(11)) +
scale_fill_viridis(name="LFC") +
theme_void()
```

<img src="man/figures/README-unnamed-chunk-4-1.png" width="3600" style="display: block; margin: auto;" />
<img src="man/figures/README-unnamed-chunk-5-1.png" width="3600" style="display: block; margin: auto;" />
Binary file removed man/figures/README-unnamed-chunk-2-1.png
Binary file not shown.
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b6d8fb5

Please sign in to comment.