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

Make an initial pass at a data structure #17

Merged
merged 1 commit into from
Sep 29, 2023
Merged

Conversation

hyanwong
Copy link
Owner

@hyanwong hyanwong commented Sep 29, 2023

This sets up a table structure very roughly like that in tskit, but without any attempts at efficiency. I have attempted to mirror the tskit functions like add_row etc, so that it is easy to port e.g. the WF simulator from tskit-dev/tutorials#254 to a GIG version (see #16 (comment))

There's a lot missing here (it just deals with the table interface, and only a few tables at that), but one of the interesting things that you can do is convert a tree sequence into a GIG, using e.g.

import msprime
from GeneticInheritanceGraph import TableCollection
ts = msprime.sim_ancestry(10, sequence_length=1000)
GIGtables = TableCollection.from_tree_sequence(ts)

What do you think @duncanMR ?

@hyanwong
Copy link
Owner Author

hyanwong commented Sep 29, 2023

I'm sure we will soon want to be able to access the table data by columns as well as rows, returning numpy arrays, e.g. we should be able to do

print((tables.intervals.parent_left - tables.intervals.parent_right).mean()

@duncanMR
Copy link
Collaborator

duncanMR commented Sep 29, 2023

This is a great start! Besides the access by columns functions, I'll also work on implementing a function to add rows to the IntervalTable for a particular SV type. For example, something like add_structural_variant(type='deletion', interval=(0,2)). We'll need this to implement add_inheritance_paths in #16.

@hyanwong
Copy link
Owner Author

Shall I merge it, then? This is just a provisional API: we can replace all the structure underneath invisibly, I hope.

@hyanwong hyanwong force-pushed the initial_table_layout branch 2 times, most recently from 3305860 to 3a08eff Compare September 29, 2023 11:37
@duncanMR
Copy link
Collaborator

Shall I merge it, then? This is just a provisional API: we can replace all the structure underneath invisibly, I hope.

Yes, go for it!

@hyanwong
Copy link
Owner Author

Yes, go for it!

Done, and I stole the formatting from tskit(!):

Screenshot 2023-09-29 at 16 11 41

@hyanwong hyanwong merged commit bb1b54c into main Sep 29, 2023
@hyanwong hyanwong mentioned this pull request Sep 29, 2023
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.

2 participants