Skip to content

ts: Design a way to import or initiate ts in SP #5

@gregorgorjanc

Description

@gregorgorjanc

In #4 we discuss on how to generate or import tree sequence into R and to generate haplotypes for standard AlphaSimR simulation.

We also want to take the imported tree sequence and grow if further in AlphaSimR.

Assuming we have founderTs with multiple chromosomes (this functionality does not yet exist atm!) and converter asMapPop() from #4 then we could do:

# founderTs is obtained in an appropriate way
founderGenomes = asMapPop(founderTs, segSites = 3)
# asMapPop should recognise how many chromosomes (how many separate tree sequences we have in founderTs)
SP = SimParam$new(founderGenomes)
# Continue with AlphaSimR as usually with the "box of haplotype" approach and
# ignoring tree sequence entirely from this point onwards
# (it was used only to get base population haplotypes stored in founderGenomes)

But we could also create a new class MapPopTs which extends MapPop by also holding tree sequence, so that when we do:

founderGenomesTs = asMapPopTs(founderTs, segSites = 3)
SP = SimParam$new(founderGenomesTs)
SP$ts # place where ts will live in R/AlphaSimR
# Continue with AlphaSimR

we would have base population haplotypes and tree sequence in founderGenomesTs and by passing founderGenomesTs to SimParam$new(founderGenomesTs) we would also automatically set SP$setTrackTs(TRUE).

Alternative to using founderGenomesTs would be to do:

founderGenomes = asMapPop(founderTs, segSites = 3)
SP = SimParam$new(founderGenomes)
SP$setTrackTs(TRUE)
# this would initiate empty tree sequence (ignoring the past!) and we would grow it from this point onwards
SP$ts # place where ts will live in R/AlphaSimR
# Continue with AlphaSimR

or

founderGenomes = asMapPop(founderTs, segSites = 3)
SP = SimParam$new(founderGenomes)
SP$importTs(founderTs) # import the tree sequence
SP$setTrackTs(TRUE) # grow it from this point onwards
SP$ts # place where ts will live in R/AlphaSimR
# Continue with AlphaSimR

@LynxJinyangii @hannesbecher

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions