| singleStructureGenerator {MethEvolSIM} | R Documentation |
singleStructureGenerator
Description
an R6 class representing a single genomic structure
Methods
Public methods
Method 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.
Usage
singleStructureGenerator$init_neighbSt()
Returns
NULL
Method initialize_ratetree()
Public method: Initialization of $ratetree
This function initializes $ratetree
Usage
singleStructureGenerator$initialize_ratetree()
Returns
NULL
Method new()
Create a new singleStructureGenerator object.
Note that this object is typically generated withing a combiStructureGenerator object.
Usage
singleStructureGenerator$new( globalState, n, eqFreqs = NULL, combiStr = NULL, combiStr_index = NULL, params = NULL, testing = FALSE )
Arguments
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
Returns
A new singleStructureGenerator object.
Method get_seq()
Public method: Get object's methylation state sequence
Encoded with 1 for unmethylated, 2 for partially methylated and 3 for methylated
Usage
singleStructureGenerator$get_seq()
Returns
vector with equilibrium frequencies of unmethylated, partially methylated and methylated
Method get_seqFirstPos()
Public method: Get first sequence position methylation state
Usage
singleStructureGenerator$get_seqFirstPos()
Returns
numerical encoding of first position's methylation state
Method get_seq2ndPos()
Public method: Get second sequence position methylation state
Usage
singleStructureGenerator$get_seq2ndPos()
Returns
numerical encoding of second position's methylation state. NULL if position does not exist
Method get_seqLastPos()
Public method: Get first sequence position methylation state
Usage
singleStructureGenerator$get_seqLastPos()
Returns
numerical encoding of first position's methylation state
Method get_seq2ndButLastPos()
Public method: Get second but last sequence position methylation state
Usage
singleStructureGenerator$get_seq2ndButLastPos()
Returns
numerical encoding of second but last position's methylation state. NULL if position does not exist
Method get_combiStructure_index()
Public method: Get index in object of class combiStructureGenerator
Usage
singleStructureGenerator$get_combiStructure_index()
Returns
index in object of class combiStructureGenerator
Method 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
Usage
singleStructureGenerator$update_interStr_firstNeighbSt( leftNeighbSt, rightNeighbSt )
Arguments
leftNeighbSt$seq state of left neighbor (left neighbor is in previous singleStructureGenerator object)
rightNeighbSt$seq state of right neighbor
Returns
NULL
Method update_interStr_lastNeighbSt()
Public method: Update neighbSt of previous singleStructureGenerator object within combiStructureGenerator object
Usage
singleStructureGenerator$update_interStr_lastNeighbSt( leftNeighbSt, rightNeighbSt )
Arguments
leftNeighbSt$seq state of right neighbor (left neighbor is in next singleStructureGenerator object)
rightNeighbSt$seq state of right neighbor
Returns
NULL
Method get_eqFreqs()
Public method: Get object's equilibrium Frequencies
Usage
singleStructureGenerator$get_eqFreqs()
Returns
vector with equilibrium frequencies of unmethylated, partially methylated and methylated
Method SSE_evol()
Public method. Simulate how CpG dinucleotide methylation state changes due to the SSE process along a time step of length dt
Usage
singleStructureGenerator$SSE_evol(dt, testing = FALSE)
Arguments
dttime step length.
testinglogical value for testing purposes. Default FALSE.
Returns
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.
Method 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.
Usage
singleStructureGenerator$IWE_evol(testing = FALSE)
Arguments
testinglogical value for testing purposes. Default FALSE.
Details
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.
Returns
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.
Method get_alpha_pI()
Public Method.
Usage
singleStructureGenerator$get_alpha_pI()
Returns
Model parameter alpha_pI for sampling island equilibrium frequencies
Method get_beta_pI()
Public Method.
Usage
singleStructureGenerator$get_beta_pI()
Returns
Model parameter for sampling island equilibrium frequencies
Method get_alpha_mI()
Public Method.
Usage
singleStructureGenerator$get_alpha_mI()
Returns
Model parameter for sampling island equilibrium frequencies
Method get_beta_mI()
Public Method.
Usage
singleStructureGenerator$get_beta_mI()
Returns
Model parameter for sampling island equilibrium frequencies
Method get_alpha_pNI()
Public Method.
Usage
singleStructureGenerator$get_alpha_pNI()
Returns
Model parameter for sampling non-island equilibrium frequencies
Method get_beta_pNI()
Public Method.
Usage
singleStructureGenerator$get_beta_pNI()
Returns
Model parameter for sampling non-island equilibrium frequencies
Method get_alpha_mNI()
Public Method.
Usage
singleStructureGenerator$get_alpha_mNI()
Returns
Model parameter for sampling non-island equilibrium frequencies
Method get_beta_mNI()
Public Method.
Usage
singleStructureGenerator$get_beta_mNI()
Returns
Model parameter for sampling non-island equilibrium frequencies
Method get_alpha_Ri()
Public Method.
Usage
singleStructureGenerator$get_alpha_Ri()
Returns
Model parameter for gamma distribution shape to initialize the 3 $Ri_values
Method get_iota()
Public Method.
Usage
singleStructureGenerator$get_iota()
Returns
Model parameter for gamma distribution expected value to initialize the 3 $Ri_values
Method get_Ri_values()
Public Method.
Usage
singleStructureGenerator$get_Ri_values()
Returns
The 3 $Ri_values
Method get_Q()
Public Method.
Usage
singleStructureGenerator$get_Q( siteR = NULL, neighbSt = NULL, oldSt = NULL, newSt = NULL )
Arguments
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)
Returns
With NULL arguments, the list of rate matrices. With non NULL arguments, the corresponding rate of change.
Method get_siteR()
Public Method.
Usage
singleStructureGenerator$get_siteR(index = NULL)
Arguments
indexdefault NULL. Numerical value for the index of the CpG position within the singleStr instance
Returns
with NULL arguments, siteR vector. non NULL arguments, the corresponding siteR
Method get_neighbSt()
Public Method.
Usage
singleStructureGenerator$get_neighbSt(index = NULL)
Arguments
indexdefault NULL. Numerical value for the index of the CpG position within the singleStr instance
Returns
with NULL arguments, neighbSt vector. non NULL arguments, the corresponding neighbSt
Method update_ratetree_otherStr()
Public Method. Update ratetree from another singleStructure instance
Usage
singleStructureGenerator$update_ratetree_otherStr(position, rate)
Arguments
positionNumerical value for the index of the CpG position within the singleStr instance
rateRate of change to asign to that position
Returns
NULL
Method clone()
The objects of this class are cloneable with this method.
Usage
singleStructureGenerator$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.