diff --git a/docs/_pages/gpm.rst b/docs/_pages/gpm.rst index 31db21f..07fce30 100644 --- a/docs/_pages/gpm.rst +++ b/docs/_pages/gpm.rst @@ -1,9 +1,9 @@ GenotypePhenotypeMap ==================== -The ``GenotypePhenotypeMap`` class is the primary tool provided by the ``gpmap`` package. -It creates intuitive and useful mapping on the fly. It appends methods and attributes -to make analyzing genotype-phenotype data easy. We've create other packages that +The ``GenotypePhenotypeMap`` class is main entry-point to the ``gpmap`` package. +It offers intuitive and useful methods and attributes +for analyzing genotype-phenotype data. We've also created a number of other packages that easily interact with the ``GenotypePhenotypeMap``. Example @@ -31,14 +31,7 @@ Interface BinaryMap --------- -Attached to the GenotypePhenotypeMap is a ``BinaryMap`` object. - -The ``BinaryMap`` class creates a binary representation of all genotypes and maps -them to a genotype-phenotype map. Binary representations are useful for many reasons, -like modeling evolutionary paths and analyzing epistatic interactions (see epistasis_) - All ``GenotypePhenotypeMap`` objects append a ``BinaryMap`` instance to a the ``binary`` -attribute. Most attributes in the ``GenotypePhenotypeMap`` also exist in under -the ``binary`` attribute, updated with the binary genotype representations. - -.. _epistasis: http://epicstasis.readthedocs.io/ +attribute. The ``BinaryMap`` class creates a binary representation of all genotypes and maps +them to a genotype-phenotype map. Most attributes in the ``GenotypePhenotypeMap`` also exist in +the ``binary`` object, updated with the binary genotype representations. diff --git a/docs/_pages/tutorials.rst b/docs/_pages/tutorials.rst index c945d64..6122153 100644 --- a/docs/_pages/tutorials.rst +++ b/docs/_pages/tutorials.rst @@ -38,4 +38,8 @@ Alternatively, you can load data from a json file (using the format defined `her Port to NetworkX object ----------------------- -A useful feature of the ``seqspace`` object +.. code-block:: python + + Graph = gpm.add_networkx() + +.. code-block:: python diff --git a/gpmap/gpm.py b/gpmap/gpm.py index 92d8a1f..29906f4 100644 --- a/gpmap/gpm.py +++ b/gpmap/gpm.py @@ -221,7 +221,7 @@ def write(self, fname, items, sep="\t", **kwargs): f.write(sep.join(row)) def sort(self, genotypes): - """Sort the genotype-phenotype map by genotypes + """Sort the genotype-phenotype map using a list of genotypes. """ if len(genotypes) != self.n: raise Exception("""genotypes argument must be the same length.""") diff --git a/gpmap/graph/draw/base.py b/gpmap/graph/draw/base.py index fa2eb0f..999c274 100644 --- a/gpmap/graph/draw/base.py +++ b/gpmap/graph/draw/base.py @@ -70,6 +70,13 @@ def path(G, pos, ax, path, scale=1, length=1, **kwargs): @checkG def network(G, scale=1, vertical=True, figsize=(5,5), **kwargs): """Draw a generic plot for a genotype-phenotype map. + + Parameters + ---------- + G : GenotypePhenotypeGraph object + genotype-phenotype network to plot + scale : + """ pos = positions.flattened(G, vertical=vertical, scale=scale) # separate keyword args. diff --git a/gpmap/graph/draw/ellipses.py b/gpmap/graph/draw/ellipses.py index e48a138..15ef802 100644 --- a/gpmap/graph/draw/ellipses.py +++ b/gpmap/graph/draw/ellipses.py @@ -1,3 +1,7 @@ +import numpy +import matplotlib as mpl +import networkx as nx + def draw_networkx_nodes_ellipses(G, pos, nodelist=None, height=20, diff --git a/gpmap/graph/draw/positions.py b/gpmap/graph/draw/positions.py index c80f985..87b0e66 100644 --- a/gpmap/graph/draw/positions.py +++ b/gpmap/graph/draw/positions.py @@ -7,6 +7,8 @@ def flattened(G, scale=1, vertical=False): ---------- G : GenotypePhenotypeGraph object A genotype-phenotype objects + scale : float (default=1) + density of the nodes. Returns ------- diff --git a/gpmap/simulate/__init__.py b/gpmap/simulate/__init__.py index e69de29..73333c8 100644 --- a/gpmap/simulate/__init__.py +++ b/gpmap/simulate/__init__.py @@ -0,0 +1 @@ +from .base import GenotypePhenotypeSimulation diff --git a/gpmap/simulate/base.py b/gpmap/simulate/base.py index c8a83a2..922ffe9 100644 --- a/gpmap/simulate/base.py +++ b/gpmap/simulate/base.py @@ -18,9 +18,11 @@ def random_mutation_set(length, alphabet_size=2): size = [alphabet_size for i in range(length)] else: size = alphabet_size - - alphabet = utils.AMINO_ACIDS[:size] - mutations = dict([(i, alphabet[i])for i in range(length)]) + # build mutations dictionary + mutations = {} + for i in range(length): + alphabet = utils.AMINO_ACIDS[:size[i]] + mutations[i] = alphabet return mutations class GenotypePhenotypeSimulation(GenotypePhenotypeMap): @@ -40,7 +42,7 @@ def __init__(self, wildtype, mutations, range=(0,1), *args, **kwargs): def set_random(self, range=(0,1)): """ Get a set of random """ - self.phenotypes = np.random.random(range[0], range[1], size=self.n) + self.phenotypes = np.random.uniform(range[0], range[1], size=self.n) @classmethod def from_length(cls, length, alphabet_size=2, *args, **kwargs): @@ -53,12 +55,11 @@ def from_length(cls, length, alphabet_size=2, *args, **kwargs): alphabet_size : int (optional) alphabet size - Returns ------- self : GenotypePhenotypeSimulation """ - mutations = random_mutations_set(lengths, alphabet_size=alphabet_size) - wildtype = ".join"([m[0] for m in mutations.values()]) + mutations = random_mutation_set(length, alphabet_size=alphabet_size) + wildtype = "".join([m[0] for m in mutations.values()]) self = cls(wildtype, mutations, *args, **kwargs) return self diff --git a/setup.py b/setup.py index 0538442..d6b1d9e 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,21 @@ except: from distutils.core import setup +# Packages and subpackages to install +packages = [ + 'gpmap', + 'gpmap.evolve', + 'gpmap.graph', + 'gpmap.graph.draw', + 'gpmap.simulate' +] + setup(name='gpmap', - version='0.1', + version='0.1.1', description='Data-structure for analyzing genotype-phenotype map data.', author='Zach Sailer', author_email='zachsailer@gmail.com', - packages=['gpmap'], + packages=packages, url="https://github.com/harmslab/gpmap", install_requires=[ 'networkx',