mutation(m2) {
effects = rnorm(n,0,sd=sqrt(sigma2));
mut.setValue("effect", effects);
return T;
}
Then here is one way I've tried to compute the G2 = \sum_j x_{ij}^2:
function (float)get_G2(o<Individual> inds) {
//get fixed effects
fixed_effects = float(n);
for (sub in sim.substitutions) {
fixed_effects = fixed_effects + sub.getValue("effect");
}
res = float(length(inds));
for (i in 0:(length(inds)-1)) {
muts = inds[i].genomes.mutationsOfType(m2);
effect = length(muts) ? muts.getValue("effect") else rep(0,n);
effect = matrix(effect,nrow=n);
G = apply(effect,0,"sum(applyValue);");
G = G + 2*fixed_effects;
G2 = G*G;
res[i] = sum(G2);
}
return res;
}
and the second way is
function (float)get_G2(o<Individual> inds) {
//get fixed effects
fixed_effects = float(n);
for (sub in sim.substitutions) {
fixed_effects = fixed_effects + sub.getValue("effect");
}
res = float(length(inds));
for (i in 0:(length(inds)-1)) {
muts = inds[i].genomes.mutationsOfType(m2);
cur_G = 0;
for (mut in muts) {
cur_effects = mut.getValue("effect");
cur_G = cur_G + cur_effects;
}
cur_G = cur_G + 2*fixed_effects; //NB THE 2 DUE TO DIPLOIDY
G2 = cur_G*cur_G;
res[i] = sum(G2);
}
return res;
}
Both are pretty excruciating---presumably it's the sum over individuals that's the big problem here. Do you think there's any way to speed this up?
Thanks!
PS: I'm using SLIM 4 since this is an update to some old scripts that were in SLIM 4, but I can port to SLIM 5 if you think that will help!
--
SLiM forward genetic simulation: http://messerlab.org/slim/
Before posting, please read http://benhaller.com/slim/bugs_and_questions.html
---
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 visit https://groups.google.com/d/msgid/slim-discuss/5e8ab68b-6b4a-4a49-aa38-e62f518bdfecn%40googlegroups.com.