Skip to content

How to disable module, enzyme, and gene names in the network? #24

Open

Description

@YonghuiDong

Dear developer,

Thanks for this amazing R package.

I want to display only the metabolite and pathway names as show in your original publication, how can I achieve that?

I did not find the corresponding parameter in plotGraph function.

Thanks a lot.

Dong

Screen Shot 2023-03-02 at 14 01 12

** Fig. 1** Figure from the original publication where only metabolite and pathway names were displayed.

Screen Shot 2023-03-02 at 14 00 33

Fig. 2 Figure produced using plotGraph function in which all names were shown in the plot.

Activity

  1. SergiPicart commented on Mar 5, 2023

    @SergiPicart
    Contributor

    Dear Dong,

    Please see if the code below helps. The original publication figure had small modifications with a graphical editor (e.g. putting a white background behind node labels for better readability) but you can tweak the plotting to hide node labels, change colours, etc

    Let me know if that helps
    Sergi

    # example on how to customise the plotting attributes of the sub-graph
    library(igraph)
    library(FELLA)
    
    data("FELLA.sample")
    data("input.sample")
    
    myAnalysis <- enrich(
      compounds = input.sample, 
      method = "diffusion", 
      approx = "normality", 
      data = FELLA.sample)
    
    # default FELLA plotting
    plot(myAnalysis, method = "diffusion", data = FELLA.sample)
    
    # export the graph
    g <- generateResultsGraph(object = myAnalysis, data = FELLA.sample)
    
    # again, default plotting
    plotGraph(g)
    
    # custom plotting
    # currently there is no way to get the default parameters for the graph 
    # and change them - would be a nice improvement to allow it
    # you can still find them by printing FELLA's plotting function
    print(FELLA::plotGraph)
    
    # see ?igraph.plotting for a list of options
    # Example customised parameters
    v.size <- c(
      "1" = 10,
      "2" = 6,
      "3" = 5,
      "4" = 4,
      "5" = 2
    )
    v.color <- stats::setNames(grDevices::palette()[1:5], 1:5)
    
    # default igraph plotting - no params
    plot(g)
    
    # igraph plotting - custom params
    plot(g, 
         vertex.size = v.size[V(g)$com], 
         vertex.color = v.color[V(g)$com], 
         vertex.label.dist = 1, 
         vertex.label.color = ifelse(V(g)$name %in% input.sample, 
                                     "indianred1", "gray20"), 
         edge.curved = TRUE, 
         edge.width = 3)
    
    
    # you can also remove text by setting labels to ""
    plot(g, 
         vertex.size = v.size[V(g)$com], 
         vertex.color = v.color[V(g)$com], 
         # only show level 1 (pathway) and 5 (compound)
         vertex.label = ifelse(V(g)$com %in% c(1, 5), V(g)$label, ""), 
         vertex.label.dist = 1, 
         vertex.label.color = ifelse(V(g)$name %in% input.sample, 
                                     "indianred1", "gray20"), 
         edge.width = 3)
  2. YonghuiDong commented on Mar 6, 2023

    @YonghuiDong
    Author

    Dear Sergi,

    Thanks a lot for your kind help!

    Dong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions