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

Projecting genes and KEGG Ortholgs on a pathway #35

Open
Rahul1711arora opened this issue Aug 1, 2024 · 1 comment
Open

Projecting genes and KEGG Ortholgs on a pathway #35

Rahul1711arora opened this issue Aug 1, 2024 · 1 comment

Comments

@Rahul1711arora
Copy link

Hi,

I have found this to be very interesting and played with some data. I'm wondering if I have a list of genes from DEA analysis and the KEGG Ortholog (KO) IDs from another analysis. How can I make sure that for a given pathway, I can project both and highlight which gene is from analysis A and KO is from analysis B but they work together in this pathway. Like glycolysis, how can I project that KO1, KO2, KO3 is from analysis B and the gene1, gene2, and gene3 is from analysis A are both working together in this glycolysis pathway and also label them?

Thanks in advance.

Best,
Rahul

@noriakis
Copy link
Owner

Hi,

Thank you very much for your interest in ggkegg. I apologize for the long delay in response.

Your use case is very important highlighting KO and gene simultaneously.

I think the projection can be achieved by merging the name of the KO-based pathway into the pathway of species of interest. For HSA, I briefly make an example code highlighting gene changes in red, and KO changes in blue.

library(ggkegg)
g <- pathway("hsa00010")
g2 <- pathway("ko00010")

## add KO names in the HSA pathway
g <- g %N>% mutate(name2=g2 %N>% pull(name))


## Random values
genes <- g %N>% filter(type=="gene") %>% pull(graphics_name) %>% strsplit(", ") %>% sapply("[", 1) %>% unlist() %>% unique()
kos <- g2 %N>% filter(type=="ortholog") %>% pull(name) %>% strsplit(" ") %>% unlist() %>% unique()
group1 <- sample(genes, 10)
group2 <- sample(kos, 10)
val1 <- runif(10) %>% setNames(group1)
val2 <- runif(10) %>% setNames(group2)

val1
#>        HK1       TPI1    ALDH3A1       FBP1     MINPP1        GCK    LDHAL6A 
#> 0.03388509 0.59546988 0.93749792 0.26126452 0.96379131 0.56503199 0.27043752 
#>      ADH1A      PDHA1      ALDH2 
#> 0.91943985 0.02604243 0.71127836
val2
#> ko:K12407 ko:K01834 ko:K03103 ko:K13980 ko:K00170 ko:K01223 ko:K01905 ko:K00172 
#> 0.4896457 0.9828648 0.2256395 0.5059643 0.3850336 0.4675857 0.9891956 0.6774298 
#> ko:K25026 ko:K01622 
#> 0.3978992 0.7771029

g <- g %N>% mutate(val1=node_numeric(val1, name = "graphics_name", sep=", ", remove_dot = TRUE),
                   val2=node_numeric(val2, name = "name2")) %>%
    mutate(width=(xmax-xmin)/2)

library(ggnewscale)
ggraph(g, x=x, y=y) +
    geom_node_rect(aes(fill=val1))+
    scale_fill_distiller(palette = "Reds")+
    new_scale_fill()+
    geom_node_rect(aes(xmin=xmin+width, fill=val2))+
    scale_fill_distiller(palette = "Blues")+
    theme_void()

Created on 2024-09-20 with reprex v2.1.1

Hope this helps your analysis.

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