tskit-dev / pyslim

Tools for dealing with tree sequences coming to and from SLiM.
MIT License
27 stars 23 forks source link

Error with pyslim.load 'AttributeError: can't set attribute' #266

Closed asadrh8 closed 2 years ago

asadrh8 commented 2 years ago
image

Hi, I've been running into an issue with loading in TreeSeq files on CoLab (picture attached). I've instead tried using tskit.load, but following that I'm met with an error using msprime.sim_mutations() (The error is as follows: 'LibraryError: Existing allele(s) incompatible with mutation model alphabet.') Thanks, Asad

petrelharp commented 2 years ago

Ah-ha - this is an incompatibility between the new tskit release and the previous pyslim. In fact, in the next pyslim release, pyslim.load( ) is removed, as the functionality has shifted over to tskit. The beta release of pyslim 1.0: https://pypi.org/project/pyslim/1.0b1/ .

So, I'm guessing that the problem "incompatible with mutation model alphabet" occurs because you're trying to add nucleotide mutations to a tree sequence with SLiM mutations. (By default, sim_mutations( ) uses Jukes-Cantor, with ACGT alleles.) To get around this, you could either add mutations using the SLiMMutationModel, or you could first convert alleles to nucleotides (but be sure to read the caveats for the latter function).

Let me know if this fixes your problem?

TBooker commented 2 years ago

I don't know if this fixed Asad's problem, but I was having some issues that upgrading to the pyslim 1.0 beta resolved.

Specifically, I was finding that no matter what I did the individuals_alive_at() function could not be accessed/retrieved. Upgrading to the beta has fixed that!

petrelharp commented 2 years ago

For completeness, you'd install the beta with

pip install pyslim==1.0b1

I'll close this, please let us know if you've still got issues.

asadrh8 commented 2 years ago

Ah-ha - this is an incompatibility between the new tskit release and the previous pyslim. In fact, in the next pyslim release, pyslim.load( ) is removed, as the functionality has shifted over to tskit. The beta release of pyslim 1.0: https://pypi.org/project/pyslim/1.0b1/ .

So, I'm guessing that the problem "incompatible with mutation model alphabet" occurs because you're trying to add nucleotide mutations to a tree sequence with SLiM mutations. (By default, sim_mutations( ) uses Jukes-Cantor, with ACGT alleles.) To get around this, you could either add mutations using the SLiMMutationModel, or you could first convert alleles to nucleotides (but be sure to read the caveats for the latter function).

Let me know if this fixes your problem?

It worked! Thank you.