singleStructureGenerator | R Documentation |
an R6 class representing a single genomic structure
testing_output
Public attribute: Testing output for initialize
init_neighbSt()
Public method: Initialization of $neighbSt
This fuction initiates each CpG position $neighbSt as encoded in $mapNeighbSt_matrix
It uses $update_neighbSt which updates for each sequence index, the neighbSt of left and right neighbors This means that it updates position 2, then 1 and 3, then 2 and 4.. Therefore, if the combiStructure instance has several singleStr instances within and the first has length 1, the $neighbSt of that position of the first singleStr instance is initialized when the method is called from the second singleStr instance
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 writing in public field of new instance $testing_output
A new singleStructureGenerator
object.
set_myCombiStructure()
Public method: Set my_combiStructure. Assigns given combi instance to private field my_combiStructure
singleStructureGenerator$set_myCombiStructure(combi)
combi
instance of combiStructureGenerator
NULL
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( leftNeighb_seqSt, rightNeighb_seqSt )
leftNeighb_seqSt
$seq state of left neighbor (left neighbor is in previous singleStructureGenerator object)
rightNeighb_seqSt
$seq state of right neighbor
NULL
update_interStr_lastNeighbSt()
Public method: Update neighbSt of previous singleStructureGenerator object within combiStructureGenerator object
singleStructureGenerator$update_interStr_lastNeighbSt( leftNeighb_seqSt, rightNeighb_seqSt )
leftNeighb_seqSt
$seq state of right neighbor (left neighbor is in next singleStructureGenerator object)
rightNeighb_seqSt
$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 debugNov3.outnumber 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_eqFreqs
numeric vector with 3 frequency values (for old u, p and m)
new_eqFreqs
numeric vector with 3 frequency values (for new u, p and m)
info
character string to indicate where the method is being called
testing
logical 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:
transMat
transition matrix
case
The 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)
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 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:
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
get_Q()
Public Method.
singleStructureGenerator$get_Q( siteR = NULL, neighbSt = NULL, oldSt = NULL, newSt = NULL )
siteR
default NULL. Numerical value encoding for the sites rate of independent SSE (1, 2 or 3)
neighbSt
default NULL. Numerical value encoding for the sites neighbouring state (as in mapNeighbSt_matrix)
oldSt
default NULL. Numerical value encoding for the sites old methylation state (1, 2 or 3)
newSt
default 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)
index
default 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)
index
default 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)
position
Numerical value for the index of the CpG position within the singleStr instance
rate
Rate of change to asign to that position
NULL
get_Qi()
Public Method. Get list of matrices for SSE process
singleStructureGenerator$get_Qi(siteR = NULL, oldSt = NULL, newSt = NULL)
siteR
default NULL. Numerical value encoding for the sites rate of independent SSE (1, 2 or 3)
oldSt
default NULL. Numerical value encoding for the sites old methylation state (1, 2 or 3)
newSt
default NULL. Numerical value encoding for the sites new methylation state (1, 2 or 3)
With NULL arguments, the list of SSEi rate matrices. With non NULL arguments, the corresponding rate of change.
get_seqSt_leftneighb()
Public Method. Decode methylation state of left neighbor form owns neighbSt
singleStructureGenerator$get_seqSt_leftneighb(index)
index
Integer index value for the CpG position within the singleStr instance
decoded methylation state ($seq) of left neighbor (1, 2 or 3 for unmethylated, partially methylated or methylated)
get_seqSt_rightneighb()
Public Method. Decode methylation state of left neighbor form owns neighbSt
singleStructureGenerator$get_seqSt_rightneighb(index)
index
Integer index value for the CpG position within the singleStr instance
decoded methylation state ($seq) of right neighbor (1, 2 or 3 for unmethylated, partially methylated or methylated)
cftp_all_equal()
Public Method. Make a singleStructure with the same segment lengths and parameters as the focal one but where all states are m or u
singleStructureGenerator$cftp_all_equal(state, testing = FALSE)
state
Character value "U" or "M"
testing
default FALSE. TRUE for testing output
right neighbSt
set_seqSt_update_neighbSt()
Public Method. Set the methylation state of a sequence position and update the neighbor's neighbSt. It does NOT update RATETREE
singleStructureGenerator$set_seqSt_update_neighbSt( index, newSt, testing = FALSE )
index
Numerical value for the index of the CpG position within the singleStr instance
newSt
Numerical value encoding for the sites new methylation state (1, 2 or 3)
testing
default FALSE. TRUE for testing output
NULL when testing FALSE. Testing output when testing TRUE.
reset_seq()
Public Method. Resets the sequence states by resampling according to the instance's equilibrium frequencies.
singleStructureGenerator$reset_seq()
NULL. The sequence is updated in place.
clone()
The objects of this class are cloneable with this method.
singleStructureGenerator$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.