This came up during my multitrait testing; for a model with seven traits and three mutation types, I wanted to compare the distribution of effects and dominance coefficients, as generated by SLiM versus at the end of the simulation, for each trait/muttype. You can do this, with a mutation() callback, but for so many combinations, it becomes quite a pain. It would be nice to have a facility to automatically log this kind of information.
So I just did it, and it seems to work nicely. I'm making a new issue about it in case anybody has any comments/requests regarding this facility. Maybe @petrelharp @vsudbrack @jiseonmin @DrK-Lo might be interested. Note that I'm perfectly happy with the design as it stands now; don't feel a need to suggest changes just for the sake of saying something, "LGTM" is an entirely acceptable response. :-> But if I've dropped the ball here in some way, with respect to what people would like to be able to do with this sort of facility, please do let me know!
OK, so here is the doc for it:
– (fo<DataFrame>)loggedData(string$ kind, [logical$ id = F], [logical$ mutationTypeID = F], [logical$ chromosomeID = F], [logical$ position = F], [logical$ nucleotideValue = F], [logical$ originTick = F], [logical$ subpopID = F], [logical$ tag = F], [Niso<Trait> trait = NULL], [logical$ effect = F], [logical$ dominance = F], [logical$ hemizygousDominance = F])
Returns mutation data produced by the mutation type’s logging facility, as configured by logMutationData(). The data returned can be in the form of means across all logged mutations (for kind="mean"), standard deviations across all logged mutations (for kind="sd"), or separate values for each mutation (for kind="values"). If logging only of means was enabled (with the meanOnly=T option to logMutationData()), only kind="mean" is allowed, since separate values for each mutation are then not logged.
The remaining flags control which columns of data should be returned; see logMutationData() for a summary of the mutation properties they refer to. If only one data column is specified by the flags, a vector of values (or a mean or standard deviation) will be returned for that one specified data column. If more than one flag is set to T, a DataFrame object will be returned with named columns of values (or means, or standard deviations) for each specified data column. The trait property specifies which traits values should be returned for, with respect to the effect, dominance, and hemizygousDominance flags; see logMutationData() for further description. If all of these flags are F (the default), that is taken to mean that all logged data should be returned; in that case, a vector will be returned if only one column of data was logged, otherwise a DataFrame object will be returned, the same as when flags are specified explicitly. Flags set to T for data columns that were not actually logged will simply be ignored; similarly, traits specified by trait that were not actually logged will simply be ignored. See the Eidos manual for the DataFrame class documentation.
– (void)logMutationData(logical$ enable, [logical$ autogeneratedOnly = T], [logical$ meanOnly = F], [logical$ id = F], [logical$ mutationTypeID = F], [logical$ chromosomeID = F], [logical$ position = F], [logical$ nucleotideValue = F], [logical$ originTick = F], [logical$ subpopID = F], [logical$ tag = F], [Niso<Trait> trait = NULL], [logical$ effect = F], [logical$ dominance = F], [logical$ hemizygousDominance = F])
Starts or ends logging of data about new mutations belonging to the target mutation type. If autogeneratedOnly is T (the default), only new mutations generated automatically by SLiM will be logged (including mutations that are substituted in for an auto-generated mutation using a mutation() callback; that is still considered part of the auto-generation process). If autogeneratedOnly is F, mutations generated in script, such as with addNewMutation(), addNewDrawnMutation(), and reading from files such as VCF, MS, or .trees, will also be logged. The logged information can be obtained later with the loggedData() method. Once logging has been started with enable=T it cannot be modified, only stopped with enable=F; and if logging is subsequently resumed with enable=T, any previously logged data will be discarded. (This can be useful if you wish to limit the size of the in-memory data while continuing to log new data: periodically write the accumulated data to a file and then disable and re-enable logging to discard the old data.)
If meanOnly is F (the default), values for each new mutation will be kept separately. Beware: the memory usage entailed by this option can be extremely large! Alternatively, if meanOnly is T, only a running sum, used to compute a mean, will be kept for each type of data; the memory usage for this option will be small and constant, but of course a mean is more useful for some columns of data than others. If per-mutation data is desired for any one column, use meanOnly=F; this option cannot be controlled independently for the various columns of data being logged.
Next are parameters that control which mutation properties will be logged: id controls the id property; mutationTypeID controls the id property of the mutation’s mutation type (this will be the same for all mutations logged by a given MutationType, it can be useful if you combine datasets from more than one mutation type later); chromosomeID controls the id property of the mutation’s associated chromosome; position controls the position property; nucleotideValue controls the nucleotideValue property; originTick controls the originTick property; subpopID controls the subpopID property; and tag controls the tag property. Data columns will be added in the order of these parameters; the id column will be first, if requested, for example.
Last come parameters that control the logging of trait-associated data for the new mutations. The trait parameter controls which traits will be logged. The traits can be specified as integer indices or string names of traits in the species, or directly as Trait objects; NULL represents all of the traits in the species. For each specified trait, the effect parameter controls logging of the effect size, the dominance parameter controls the dominance, and the hemizygousDominance parameter controls the hemizygous dominance. Data columns for this trait-associated data will be grouped by trait; for example, if two traits named height and weight are specified, and the effect=T and dominance=T flags are specified, then columns heightEffect, heightDominance, weightEffect, and weightDominance will be added, in that order.
Note that logging occurs after all mutation() callbacks have been called, at the point when the new mutation is actually added to the simulation. If addition of a new mutation is prevented, by a mutation() callback or by the current stacking policy, that mutation will not be logged. The information logged will be the mutation’s properties at the moment that it is added; a tag value set by a mutation() callback will therefore be captured in the logged data, for example. Changes to mutations made after that point will not be preserved in the log; the log is a snapshot of the moment of each mutation’s addition to the simulation.
This has been committed to the multitrait branch, which seems to be working nicely so far actually, although a great deal of work remains. :-> Documentation for multitrait beyond what is provided in SLiMgui is not ready to share, though.
This came up during my multitrait testing; for a model with seven traits and three mutation types, I wanted to compare the distribution of effects and dominance coefficients, as generated by SLiM versus at the end of the simulation, for each trait/muttype. You can do this, with a
mutation()callback, but for so many combinations, it becomes quite a pain. It would be nice to have a facility to automatically log this kind of information.So I just did it, and it seems to work nicely. I'm making a new issue about it in case anybody has any comments/requests regarding this facility. Maybe @petrelharp @vsudbrack @jiseonmin @DrK-Lo might be interested. Note that I'm perfectly happy with the design as it stands now; don't feel a need to suggest changes just for the sake of saying something, "LGTM" is an entirely acceptable response. :-> But if I've dropped the ball here in some way, with respect to what people would like to be able to do with this sort of facility, please do let me know!
OK, so here is the doc for it:
This has been committed to the
multitraitbranch, which seems to be working nicely so far actually, although a great deal of work remains. :-> Documentation formultitraitbeyond what is provided in SLiMgui is not ready to share, though.