Skip to content

Instantly share code, notes, and snippets.

@cthoyt
Created April 9, 2016 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cthoyt/5fdc66b93f7a1cf9571c85db12573279 to your computer and use it in GitHub Desktop.
Save cthoyt/5fdc66b93f7a1cf9571c85db12573279 to your computer and use it in GitHub Desktop.
Generate a toy gene co-expression network
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