BranchLengthStatCalculator

15 views
Skip to first unread message

Zachary Hancock

unread,
Apr 1, 2020, 6:33:40 PM4/1/20
to msprime-users
Hi all,

I'm attempting to run a package from Bradburd & Ralph (2019) to plot heterozygosity through time. The package calls from importing BranchLengthStatCalculator from msprime, but there doesn't seem to be any such package. Has this function been removed or renamed? 

Thanks,
Zach

Peter Ralph

unread,
Apr 1, 2020, 7:17:31 PM4/1/20
to Zachary Hancock, msprime-users

On Wed, Apr 1, 2020 at 5:44 PM Peter Ralph <petre...@gmail.com> wrote:
> That API was preliminary, the functionality is still there but is now a method of the tree sequence, see tskit documentation. Which script were you trying to run?
>
I was hoping to run the plot_heterozygosity.py (https://github.com/gbradburd/spgr/blob/master/plots/plot_heterozygosity.py). I didn't realize it had been moved to the tskit docs, I'll check them out. 

Ah, yep - well, this bit:
```
    bsc = msprime.BranchLengthStatCalculator(sts)
    new_targets = [sts.node(u[0]).individual for u in new_nodes]
    het = np.array([bsc.divergence([list(sts.individual(u).nodes)], [0.0, sts.sequence_length])[0][0]
            for u in new_targets])
```
can now be done like this:
```
    new_targets = [sts.node(u[0]).individual for u in new_nodes]
    het = sts.divergence([sts.individual(u).nodes for u in new_targets])
```

Also, most all the functionality that was in the spatial_slim module of that repository is now in pyslim, so you can replace
```
ts = sps.SpatialSlimTreeSequence(pyslim.load(treefile), dim=2)
```
with
```
ts = pyslim.load(treefile)
```
and
```
    alive = ts.individuals_alive(time)
```
with
```
    alive = ts.individuals_alive_at(time)
```

There may be some other modifications that need to be made, but that's at least very close.

Write back if you run into problems!

* peter

On Wed, Apr 1, 2020 at 4:02 PM Zachary Hancock <zach.h...@tamu.edu> wrote:
I was hoping to run the plot_heterozygosity.py (https://github.com/gbradburd/spgr/blob/master/plots/plot_heterozygosity.py). I didn't realize it had been moved to the tskit docs, I'll check them out. 

On Wed, Apr 1, 2020 at 5:44 PM Peter Ralph <petre...@gmail.com> wrote:
That API was preliminary, the functionality is still there but is now a method of the tree sequence, see tskit documentation. Which script were you trying to run?

--
You received this message because you are subscribed to the Google Groups "msprime-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msprime-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/msprime-users/7aba8762-9edd-48c0-9ea2-606f8672d2da%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages