Sampling siblings

14 views
Skip to first unread message

Viv

unread,
Jun 27, 2024, 5:16:20 PM (6 days ago) Jun 27
to slim-discuss
Hi Ben,

I am looking to simulate a model in which each reproduction event generates non-identical twins, and then at the end of the simulation I'd like to sample some ratio of the siblings (e.g. say I sample 200 individuals with a 50/50 ratio, I'd have 100 twins sampled, whilst a 10/90 ratio would mean only 10 twins sampled, with 180 non-twins (for want of a better word!) sampled.

To generate non-identical twins I figured I'd just be able to use the reproduction callback from recipe 16.4:

reproduction() {
    for (i in 1:2)
        subpop.addCrossed(individual, subpop.sampleIndividuals(1));
}

However, I am not sure how to set up a sampling scheme as described above, where I can just input the ratios? How can I identify related and unrelated individuals?

Thanks for all the help!

Viv

Ben Haller

unread,
Jun 28, 2024, 3:20:46 AM (5 days ago) Jun 28
to Viv, slim-discuss
Hi Viv!

Non-identical twins are the same as regular siblings, genetically?  I should know that, lol.  If so, then your reproduction() callback looks fine.  Note that addCrossed() has a count parameter; so instead of the for loop you could do count=2 to achieve the same thing.

Relatedness back to the grandparent level can be assessed using pedigree tracking.  See the documentation for the keepPedigrees parameter to initializeSLiMOptions(), and the relatedness() and sharedParentCount() methods which use that pedigree tracking facility, for example.

I guess, given that information, you could implement your sampling with some kind of rejection sampling; sample pairs, determine which pairs are and are not twins, and keep the first N and M pairs to provide N twins and M non-twins, or some such.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University


Viv wrote on 6/27/24 10:16 PM:
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/c14f2270-8093-4e1f-9d80-c6db7e939742n%40googlegroups.com.

Message has been deleted

Viv

unread,
Jul 2, 2024, 4:23:38 AM (yesterday) Jul 2
to slim-discuss
Hi Ben,

That's great thank you! Does there happen to be a built-in function for outputting a relatendess matrix?

Best,

Viv

Ben Haller

unread,
Jul 2, 2024, 4:29:06 AM (yesterday) Jul 2
to slim-discuss
You could simply call:

apply(x, 0, "paste(applyValue, sep=',');")

to generate a string vector and pass the result to writeFile(), I suppose.  You might also look at the serialize() method of DataFrame (and Dictionary), but then you'd need your relatedness values in the form of a DataFrame (or Dictionary), so that's an extra step.

Cheers,
-B.

Benjamin C. Haller
Messer Lab
Cornell University

Reply all
Reply to author
Forward
0 new messages