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

Background network randomization and graph expansion fix #6

Merged
merged 12 commits into from Mar 9, 2018

Conversation

koksal
Copy link
Owner

@koksal koksal commented Feb 11, 2018

Purpose
Introduce tooling for randomizing the background network. We use BiRewire to randomize the directed and undirected edges of the background network separately, shuffle the weights for each subset of edges, and produce weighted, randomized background networks with the same number of undirected and directed edges as the input. We additionally generate partial model files that correspond to the directed subgraph of each randomized background network.

Technical description

  • Introduced a shell script to help run the python script.
  • Introduced a python script to generate N randomized copies of the input network.
    • The script partitions the undirected and directed edges
    • It randomizes each subgraph by calling the corresponding R script
    • It shuffles the weights by sampling without replacement (assuming BiRewire does not produce randomized networks of bigger size than the original)
  • We have to generate two pseudo negative edges to make BiRewire work with directed graphs. When the negative signed subgraph is empty, BiRewire produces an error. We clean up the randomized negative edges before producing the final output.
  • The script also generates partial model files that correspond to each randomized background network.

Testing plan
I tested the workflow manually as I was debugging BiRewire, but I can also produce some tests to supplement them.

@agitter
Copy link
Collaborator

agitter commented Feb 24, 2018

I had problems with igraph in my R environment, so we decided to split the network randomization from the PCSF+TPS pipeline. Unlike the protein-peptide map permutation and bootstrapping, a separate script run_net_rand.sh first creates the randomized networks. Then net_rand_wrapper.sh runs PCSF+TPS on those networks.

@agitter
Copy link
Collaborator

agitter commented Feb 28, 2018

aa3d674 is a relaxation to allow self-edges in the TPS partial model file. The randomized networks can introduce self-edges, which we will note in the readme.

@koksal
Copy link
Owner Author

koksal commented Feb 28, 2018

Our relaxed assumption still breaks when the input has a self edge A -> A, where the protein A has multiple phosphosites. This is due to the Cartesian product of phosphosites generating pairs that violate the assumption, e.g. A#C -> A#B.

We remove this assertion and add code that explicitly handles the lexicographically-aware expansion and collapsing of peptide-level solutions.

@agitter agitter mentioned this pull request Mar 2, 2018
4 tasks
@koksal
Copy link
Owner Author

koksal commented Mar 7, 2018

We also added a fix to transformations between protein-level and peptide-level graphs, to handle cases where the protein-level network had self-edges.

@agitter , would you like to look at the python and R scripts to generate randomized networks, or should I go ahead and merge?

@koksal koksal changed the title WIP: Background network randomization Background network randomization and graph expansion fix Mar 7, 2018
@koksal koksal requested a review from agitter March 7, 2018 19:42
Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python and R code looks good to me. We're ready to merge.

@koksal koksal merged commit 7fe3272 into master Mar 9, 2018
@koksal koksal deleted the network_randomization branch March 9, 2018 05:32
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.

None yet

2 participants