Created
April 9, 2016 16:33
-
-
Save cthoyt/5fdc66b93f7a1cf9571c85db12573279 to your computer and use it in GitHub Desktop.
Generate a toy gene co-expression network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
# Represent different entities with these letters | |
letters = list("abcdefghjkmnopqrstuvwxyzABCDEFGHIJKLMN") | |
l = int(0.2 * np.square(len(letters))) | |
g = np.random.choice(letters, size=(l, 2)) | |
n = np.random.uniform(size=l).round(3) | |
d = [(a, b, c) for (a, b), c in zip(g, n) if a < b] | |
df = pd.DataFrame(d, columns=("gene_a", "gene_b", "correlation")) | |
df.to_csv("~/Desktop/toy.csv", index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment