makeFeatures: Generating a list of genomic features

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/nucSim.R

Description

This function generates a list of genomic features for a single chromosome based on a Markov model.

Usage

1
2
3
4
5
6
makeFeatures(generator = defaultGenerator(), 
	transition = defaultTransition(), init = defaultInit(), 
	start = 1000, length, control = list(), 
	globals = list(minDist = 175), lastFeat = defaultLastFeat(), 
	experimentType = "NucleosomePosition", 
	truncate = FALSE, maxTries = 10, force=FALSE)

Arguments

generator

A named list providing functions to generate the parameters associated with each type of feature. The name of each element in the list is the name of the state the function should be associated with.

transition

Named list of transition probabilities. Each element is a (named) numeric vector giving the transition probabilities for the state indicated by the element's name, i.e., each element of the list is a row of the transition probability matrix but zero probabilities can be omitted.

init

Named numeric vector of initial state probabilities. The names have to correspond to state names of the model. Zero probabilities may be omitted.

start

Numeric value indicating the position at which the first feature should be placed.

length

Maximum length of DNA that should be covered with features.

control

Named list with additional arguments to generator functions (one list per generator). Again the names should be the same as the state names.

globals

List of global arguments to be passed to all generator functions.

lastFeat

Named logical vector indicating for each feature type whether it can be the last feature.

experimentType

Type of experiment the simulated features belong to. This is used as the class of the return value.

truncate

Logical value indicating whether the final feature should be truncated to ensure that total length does not exceed length (if FALSE, a feature that would be truncated is removed instead).

maxTries

Maximum number of attempts made to generate a valid sequence of features. If no valid sequence is generated during the first maxTries attempts the function will fail either silently (returning an empty sequence) or raise an error, depending on the value of force.

force

Logical indicating whether the function should be forced to return a feature sequence, even if no valid sequence was found. If this is TRUE an empty sequence will be returned in that case otherwise an error is raised.

Details

This function will generate features from any first order Markov model specified by init, transition and generator. If force is FALSE the returned feature sequence is guaranteed to contain at least one feature and end in a state that is indicated as possible end state in lastFeat. Note that the states for which lastFeat is TRUE are not end states in the sense that the chain is terminated once the state is entered or that the chain remains in the state once it is first entered. Instead this is a mechanism to ensure that some states cannot be the last in the sequence.

Due to the constrains on the total length of DNA covered by features as well as the possible constraint on the final feature of the sequence it is possible to specify models that cannot produce a legal sequence. In other cases it may be possible but unlikely to produce a feature sequence that satisfies both constraints. A serious attempt is made to satisfy both requirement, generating a new feature sequence or truncating an existing one if necessary. To ensure that this terminates eventually the number of attempts to generate a valid sequence are limited to maxTries.

In some cases it may be desirable to carry out some post-processing of the feature sequence to ensure that parameters of neighbouring features are compatible in some sense. For the default nucleosome positioning simulation the function reconcileFeatures provides this functionality and placeFeatures is an interface to makeFeatures that utilises reconcileFeatures.

Value

A list of features (with class determined by experimentType). Each feature is represented by a list of parameters and has a class with the same name as the state that generated the feature. In addition all features are of class SimulatedFeature.

Author(s)

Peter Humburg

See Also

Functions to generate default values for some of the arguments: defaultGenerator, defaultInit, defaultTransition, defaultLastFeat.

Use feat2dens to convert a feature sequence into feature densities.

placeFeatures is an interface to makeFeature for nucleosome positioning.

Examples

1
2
3
4
5
6
set.seed(1)
## generate a (relatively short) sequence of nucleosome features
features <- makeFeatures(length=1e6)

## check the total length of the features
sum(sapply(features, "[[", "length")) ## 995020 

ChIPsim documentation built on Nov. 8, 2020, 8:09 p.m.