View source: R/rTEM_multimer_simulation.R
create_groups | R Documentation |
This is the function that is called within multimersim
to create groups from single points.
create_groups(
num_neighbors = 6,
upp_guest,
upp_host,
probs = c(1, 0, 0, 0, 0, 0),
weights = c(1, 1, 1),
trans_plane = c("x", "y"),
trans_frac = 0.5,
sample_method = "rank",
group_size = 2,
exponent = 1
)
num_neighbors |
the number of nearest neighbors around each guest type point to to be considered consider. |
upp_guest |
The guest type points that groups will be created around Currently, the points in 'upp_guest' should not also be part of 'upp_host' |
upp_host |
The host type points that the multimers will be selected from |
probs |
vector of probabilities.
For |
weights |
vector of length equal to number of dimensions in upp.
the weighted distance to each of num_neighbors nearest neighbors
is calculated using |
sample_method |
if equal to "rank", the probability of a point of rank x being chosen as a guest is probs[x]. If equal to "exp", the probability of a point of rank x being chosen as a guest is probs[x] * exp(-exponent * distances[ranks])) |
group_size |
a numeric. How large will the groups be |
exponent |
a numeric. If sample_method = "exp", then this is the value of exponent in exp(-exponent * distances[ranks]) |
Algorithm Steps:
Step 1: Calculate 'num_neighbors' worth of nearest points in 'upp_host' to each point in 'upp_guest'
Step 2: Use get_ranks
to rank each of these neighbors by weighted distance to their
respective guest point. Note: If weights = c(1, 1, 1) for 3D patterns or c(1, 1) for 2D patterns,
then they will be ranked by distance.
Step 3: Use pick_neighbor
function to pick which of the neighbors will become
guest type.
Step 4: Deal with duplicates. If 'upp_guest' contains points that are close enough to each other, it is possible they will share nearest neighbors. If any point is selected twice, then another shall be selected to maintain the proper number of guests
Step 5: Translate. All selected neighbors are translated in the 'trans_plane' plane so that the distance to their respective guest point in the 'trans_plane' plane is reduced by a fraction of 'trans_frac'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.