Skip to content

Fst gives a NoneType error when no indices are given (the default) #250

Closed

Description

@gtsambos

I have a simulation that does the right thing when I explicitly specify pairs of indices:

ts.Fst(sample_sets = samples_list,
      indexes = [(0,2), (0,1)])

outputs

array([[0.12508121, 0.12780193]])

but that gives the following error if I remove the indexes input (and so use the default value of None)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-fbfb01290311> in <module>
----> 1 ts.Fst(sample_sets = samples_list)

/usr/local/lib/python3.7/site-packages/tskit/trees.py in Fst(self, sample_sets, indexes, windows, mode, span_normalise)
   3332         fst = np.repeat(1.0, np.product(divergences.shape))
   3333         fst.shape = divergences.shape
-> 3334         for i, (u, v) in enumerate(indexes):
   3335             denom = (diversities[:, :, u] + diversities[:, :, v]
   3336                      + 2 * divergences[:, :, i])

TypeError: 'NoneType' object is not iterable

Activity

  1. added this to the Python 0.2.0 milestone on Jul 2, 2019
  2. added
    bug
    on Jul 2, 2019
  3. jeromekelleher commented on Jul 3, 2019

    @jeromekelleher
    Member
  4. jeromekelleher commented on Aug 19, 2019

    @jeromekelleher
    Member

    I was looking into this @petrelharp, and it seems we don't have a lot of test coverage on Fst right now --- we're only testing the "site" version, essentially. Since this is a derived statistic it seems overboard to implement the full thing from scratch like the other stats, but we do need to get some sort of coverage here on "branch" and "node". Have you any suggestions for this?

  5. petrelharp commented on Aug 19, 2019

    @petrelharp
    Contributor

    I guess we just need to do some "does this run" sort of checks. I'll have a look.

  6. added a commit that references this issue on Aug 19, 2019
    6ee84e6
  7. petrelharp commented on Aug 19, 2019

    @petrelharp
    Contributor

    Currently our default for indexes=None is indexes=[(0, 1)] for pairwise stats. We can't do this here because users might think that the single Fst value returned is the between-all-pops Fst value. I also don't want to just return the full matrix by default because it's not clear what order it should be in. So, I'm making the user specify.

  8. jeromekelleher commented on Aug 20, 2019

    @jeromekelleher
    Member

    Currently our default for indexes=None is indexes=[(0, 1)] for pairwise stats. We can't do this here because users might think that the single Fst value returned is the between-all-pops Fst value. I also don't want to just return the full matrix by default because it's not clear what order it should be in. So, I'm making the user specify.

    I see. What if [(0, 1)] was the default when we have two sample sets, but we raise a ValueError if there's more than 2 sample sets and indexes is None? We want to make the common case easy and simple.

  9. added a commit that references this issue on Aug 20, 2019
    e72993b
  10. petrelharp commented on Aug 20, 2019

    @petrelharp
    Contributor

    Oh, that's a good idea.

  11. petrelharp commented on Aug 20, 2019

    @petrelharp
    Contributor

    I've done this, although similar defaults could be set for many other statistics, which we should probably do at some point...

  12. added a commit that references this issue on Aug 20, 2019
    4b7e3ac
  13. jeromekelleher commented on Aug 20, 2019

    @jeromekelleher
    Member

    I've had a change of heart here, and think maybe we should hold off on specifying a default for this---see the comment in #313

  14. petrelharp commented on Aug 20, 2019

    @petrelharp
    Contributor

    Whoops; missed this. Let's discuss at #315 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions