dipetkov / eems

Estimating Effective Migration Surfaces
GNU General Public License v2.0
102 stars 28 forks source link

Grid input format #3

Closed BenjaminPeter closed 9 years ago

BenjaminPeter commented 9 years ago

It might be useful at some point to define custom grid points outside the eems executable.

We were talking about grid input formats, I suppose the easiest would be to use the same format as is currently output in demes.txt and edges.txt, i.e.

demes.txt:

x and y coordiante of deme location, implicit indexing (n_demes rows, 2 cols)

       0        0
0.741935        0
 2.22581        0
 2.96774        0
 6.67742        0
 8.90323        0
 9.64516        0
  11.129        0
0.370968   0.7625
 1.85484   0.7625
edges.txt:

line i contains indeces of demes which are connected to i, (n_demes rows) max_n_deme cols (max_n_deme=6?); 0 implies no connection

 0   0   9   2   0   0
 1   9  80  72   0   0
72  10  11   4   0   0
 3  11  81  73   0   0
76  85  86  77   0   0
78  13  14   7   0   0
 6  14  87  79   0   0
79  15  16   0   0   0
 0  17  18  80   2   1
80  88  19  11   3  72

I guess the easiest way to implement this would be to reimplement

void Graph : : make _triangular_grid(...)

as the other two functions you described should be exactly the same as if the grid was constructed within eems.

dipetkov commented 9 years ago

I have added an option to read the population grid from two input files: gridpath.demes and gridpath.edges. The assignment of samples to demes has to be provided as well in gridpath.ipmap.

gridpath.demes:

x and y (longitude and latitude) coordinate of each deme, with implicit indexing -- the line number is the deme id. The demes file has nDemes rows, 2 cols. That is, just as Ben described it.

gridpath.edges:

pairs of connected demes, using the implicit indexing in the demes file. The edges file has nEdges rows, 2 cols. It would be easy to provide a grid that is not triangular -- though, it must be connected. The edges file would look something like this (note that the indexing start at 1):

1 87 1 72 72 87 72 88 72 2 2 88 2 89 2 73

gridpath.ipmap:

the deme each individual is assigned to. The individuals are implicitly indexed -- the line number is the individual id. The integers are the corresponding deme id's. The ipmap file has nIndiv rows, 1 col.

1 1 1 2 2 2 3

To use the grid and assignment described by these three files, use the option gridpath = xxxxx in the parameter input file (*.ini).