singleStructureGenerator {MethEvolSIM} | R Documentation |
an R6 class representing a single genomic structure
init_neighbSt()
Public method: Initialization of $neighbSt
This fuction initiates each CpG position $neighbSt as encoded in $mapNeighbSt_matrix Positions at the edge of the entire simulated sequence use their only neighbor as both neighbors.
singleStructureGenerator$init_neighbSt()
NULL
initialize_ratetree()
Public method: Initialization of $ratetree
This function initializes $ratetree
singleStructureGenerator$initialize_ratetree()
NULL
new()
Create a new singleStructureGenerator object.
Note that this object is typically generated withing a combiStructureGenerator object.
singleStructureGenerator$new( globalState, n, eqFreqs = NULL, combiStr = NULL, combiStr_index = NULL, params = NULL, testing = FALSE )
globalState
Character. Structure's favored global state: "M" for methylated (island structures) / "U" for unmethylated (non-island structures).
n
Numerical Value. Number of CpG positions
eqFreqs
Default NULL. When given: numerical vector with structure's methylation state equilibrium frequencies (for unmethylated, partially methylated and methylated)
combiStr
Default NULL. When initiated from combiStructureGenerator: object of class combiStructureGenerator containing it
combiStr_index
Default NULL. When initiated from combiStructureGenerator: index in Object of class combiStructureGenerator
params
Default NULL. When given: data frame containing model parameters
testing
Default FALSE. TRUE for testing output
A new singleStructureGenerator
object.
get_seq()
Public method: Get object's methylation state sequence
Encoded with 1 for unmethylated, 2 for partially methylated and 3 for methylated
singleStructureGenerator$get_seq()
vector with equilibrium frequencies of unmethylated, partially methylated and methylated
get_seqFirstPos()
Public method: Get first sequence position methylation state
singleStructureGenerator$get_seqFirstPos()
numerical encoding of first position's methylation state
get_seq2ndPos()
Public method: Get second sequence position methylation state
singleStructureGenerator$get_seq2ndPos()
numerical encoding of second position's methylation state. NULL if position does not exist
get_seqLastPos()
Public method: Get first sequence position methylation state
singleStructureGenerator$get_seqLastPos()
numerical encoding of first position's methylation state
get_seq2ndButLastPos()
Public method: Get second but last sequence position methylation state
singleStructureGenerator$get_seq2ndButLastPos()
numerical encoding of second but last position's methylation state. NULL if position does not exist
get_combiStructure_index()
Public method: Get index in object of class combiStructureGenerator
singleStructureGenerator$get_combiStructure_index()
index in object of class combiStructureGenerator
update_interStr_firstNeighbSt()
Public method: Update neighbSt of next singleStructureGenerator object within combiStructureGenerator object
This function is used when the last $seq position of a singleStructureGenerator object changes methylation state to update the neighbSt position
singleStructureGenerator$update_interStr_firstNeighbSt( leftNeighbSt, rightNeighbSt )
leftNeighbSt
$seq state of left neighbor (left neighbor is in previous singleStructureGenerator object)
rightNeighbSt
$seq state of right neighbor
NULL
update_interStr_lastNeighbSt()
Public method: Update neighbSt of previous singleStructureGenerator object within combiStructureGenerator object
singleStructureGenerator$update_interStr_lastNeighbSt( leftNeighbSt, rightNeighbSt )
leftNeighbSt
$seq state of right neighbor (left neighbor is in next singleStructureGenerator object)
rightNeighbSt
$seq state of right neighbor
NULL
get_eqFreqs()
Public method: Get object's equilibrium Frequencies
singleStructureGenerator$get_eqFreqs()
vector with equilibrium frequencies of unmethylated, partially methylated and methylated
SSE_evol()
Public method. Simulate how CpG dinucleotide methylation state changes due to the SSE process along a time step of length dt
singleStructureGenerator$SSE_evol(dt, testing = FALSE)
dt
time step length.
testing
logical value for testing purposes. Default FALSE.
default NULL. If testing TRUE it returns a list with the number of events sampled and a dataframe with the position(s) affected, new state and old methylation state.
IWE_evol()
Public Method. Simulate IWE Events
Simulates how CpG Islands' methylation state frequencies change and simultaneous sites change methylation state along a branch of length t according to the SSE-IWE model.
singleStructureGenerator$IWE_evol(testing = FALSE)
testing
logical value for testing purposes. Default FALSE.
The function checks if the methylation equilibrium frequencies (eqFreqs
) and sequence observed
frequencies (obsFreqs
) change after the IWE event. If there is a change in either
frequencies, the corresponding change flags(eqFreqsChange
in the infoIWE
list will be set to TRUE
.
If testing = TRUE it returns a list. If there was a change in the equilibrium frequencies the list contains the following 7 elements, if not it contains the first 3 elements:
eqFreqsChange
logical indicating if there was a change in the equilibrium frequencies.
old_eqFreqs
Original equilibrium frequencies before the IWE event.
new_eqFreqs
New equilibrium frequencies after the IWE event.
old_obsFreqs
Original observed frequencies before the IWE event.
new_obsFreqs
New observed frequencies after the IWE event.
IWE_case
Description of the IWE event case.
Mk
Transition matrix used for the IWE event.
get_alpha_pI()
Public Method.
singleStructureGenerator$get_alpha_pI()
Model parameter alpha_pI for sampling island equilibrium frequencies
get_beta_pI()
Public Method.
singleStructureGenerator$get_beta_pI()
Model parameter for sampling island equilibrium frequencies
get_alpha_mI()
Public Method.
singleStructureGenerator$get_alpha_mI()
Model parameter for sampling island equilibrium frequencies
get_beta_mI()
Public Method.
singleStructureGenerator$get_beta_mI()
Model parameter for sampling island equilibrium frequencies
get_alpha_pNI()
Public Method.
singleStructureGenerator$get_alpha_pNI()
Model parameter for sampling non-island equilibrium frequencies
get_beta_pNI()
Public Method.
singleStructureGenerator$get_beta_pNI()
Model parameter for sampling non-island equilibrium frequencies
get_alpha_mNI()
Public Method.
singleStructureGenerator$get_alpha_mNI()
Model parameter for sampling non-island equilibrium frequencies
get_beta_mNI()
Public Method.
singleStructureGenerator$get_beta_mNI()
Model parameter for sampling non-island equilibrium frequencies
get_alpha_Ri()
Public Method.
singleStructureGenerator$get_alpha_Ri()
Model parameter for gamma distribution shape to initialize the 3 $Ri_values
get_iota()
Public Method.
singleStructureGenerator$get_iota()
Model parameter for gamma distribution expected value to initialize the 3 $Ri_values
get_Ri_values()
Public Method.
singleStructureGenerator$get_Ri_values()
The 3 $Ri_values
clone()
The objects of this class are cloneable with this method.
singleStructureGenerator$clone(deep = FALSE)
deep
Whether to make a deep clone.