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
)globalStateCharacter. Structure's favored global state: "M" for methylated (island structures) / "U" for unmethylated (non-island structures).
nNumerical Value. Number of CpG positions
eqFreqsDefault NULL. When given: numerical vector with structure's methylation state equilibrium frequencies (for unmethylated, partially methylated and methylated)
combiStrDefault NULL. When initiated from combiStructureGenerator: object of class combiStructureGenerator containing it
combiStr_indexDefault NULL. When initiated from combiStructureGenerator: index in Object of class combiStructureGenerator
paramsDefault NULL. When given: data frame containing model parameters
testingDefault 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)dttime step length.
testinglogical 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.
get_transMat()Public Method. Get a transition matrix
singleStructureGenerator$get_transMat(
old_eqFreqs,
new_eqFreqs,
info,
testing = FALSE
)old_eqFreqsnumeric vector with 3 frequency values (for old u, p and m)
new_eqFreqsnumeric vector with 3 frequency values (for new u, p and m)
infocharacter string to indicate where the method is being called
testinglogical value for testing purposes. Default FALSE.
Given a tripple of old equilibrium frequencies and new equilibrium frequencies, generates the corresponding transition matrix.
transMat. The transition matrix. 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:
transMattransition matrix
caseThe applied case.
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)testinglogical 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 flag 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:
eqFreqsChangelogical indicating if there was a change in the equilibrium frequencies.
old_eqFreqsOriginal equilibrium frequencies before the IWE event.
new_eqFreqsNew equilibrium frequencies after the IWE event.
old_obsFreqsOriginal observed frequencies before the IWE event.
new_obsFreqsNew observed frequencies after the IWE event.
IWE_caseDescription of the IWE event case.
MkTransition 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
get_Q()Public Method.
singleStructureGenerator$get_Q(
siteR = NULL,
neighbSt = NULL,
oldSt = NULL,
newSt = NULL
)siteRdefault NULL. Numerical value encoding for the sites rate of independent SSE (1, 2 or 3)
neighbStdefault NULL. Numerical value encoding for the sites neighbouring state (as in mapNeighbSt_matrix)
oldStdefault NULL. Numerical value encoding for the sites old methylation state (1, 2 or 3)
newStdefault NULL. Numerical value encoding for the sites new methylation state (1, 2 or 3)
With NULL arguments, the list of rate matrices. With non NULL arguments, the corresponding rate of change.
get_siteR()Public Method.
singleStructureGenerator$get_siteR(index = NULL)indexdefault NULL. Numerical value for the index of the CpG position within the singleStr instance
with NULL arguments, siteR vector. non NULL arguments, the corresponding siteR
get_neighbSt()Public Method.
singleStructureGenerator$get_neighbSt(index = NULL)indexdefault NULL. Numerical value for the index of the CpG position within the singleStr instance
with NULL arguments, neighbSt vector. non NULL arguments, the corresponding neighbSt
update_ratetree_otherStr()Public Method. Update ratetree from another singleStructure instance
singleStructureGenerator$update_ratetree_otherStr(position, rate)positionNumerical value for the index of the CpG position within the singleStr instance
rateRate of change to asign to that position
NULL
clone()The objects of this class are cloneable with this method.
singleStructureGenerator$clone(deep = FALSE)deepWhether to make a deep clone.