szhan / tsimpute

Genome-wide genotype imputation using tree sequences.
MIT License
0 stars 0 forks source link

Allow for adding sample paths of an individual to an existing tree sequence #97

Closed szhan closed 1 year ago

szhan commented 1 year ago

At the moment, sample paths are added one at a time when calling add_sample_to_tree_sequence. The proper way of adding a new diploid individual to an existing tree sequence should be to add two sets of sample edges to the tree sequence and then to reference the new sample nodes to the individual.

szhan commented 1 year ago

Rename the function to add_individual_to_tree_sequence, because it is more appropriate.

szhan commented 1 year ago

I think it is handy to encapsulate a sample path and associated metadata in a class, like this.

@dataclass
class SamplePath:
    """
    Class for storing the sample paths of an individual.

    individual: Name of individual
    samples: Sample path (just a list of sample ids)
    site_positions: Site positions corresponding to the path
    """
    individual: str
    samples: np.ndarray
    site_positions: np.ndarray

    def length(self):
        return(self.path.size)