create_groups: Create Multimers around guest type points

View source: R/rTEM_multimer_simulation.R

create_groupsR Documentation

Create Multimers around guest type points

Description

This is the function that is called within multimersim to create groups from single points.

Usage

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
)

Arguments

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 probs = c(p_1, p_2, p_3, p_4), the probability of the first NN being selected in p_1, the probability of the second is p_2, and so on

weights

vector of length equal to number of dimensions in upp. the weighted distance to each of num_neighbors nearest neighbors is calculated using \sqrt{w_1 x^2 + w_2 y^2 + w_3 z^2}, where weights = (w_1, w_2, w_3). Set to c(1, 1, 0) for vertical dimers. @param trans_plane plane for translating @param trans_frac fraction of distance in plane 'trans_plane' to reduce distance by

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])

Details

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'


rolandrolandroland/rTEM documentation built on March 29, 2025, 2:17 p.m.