multimersim_v02: Multimer Simulation Version 02

View source: R/rTEM_deprecated.R

multimersim_v02R Documentation

Multimer Simulation Version 02

Description

Under construction. See multimersim for stable version. Simulates multimers (groups of two/dimers, three/trimers, etc.) in underlying point pattern (upp) to match domain and number of points in guest_pattern.

Usage

multimersim_v02(
  guest_pattern = NULL,
  upp,
  output = "guest pattern type",
  n_guests = NA,
  min_thick = NA,
  max_thick = NA,
  ztrim = 0,
  group_size = 2,
  num_neighbors = 6,
  sample_method = "rank",
  weights = c(1, 1, 1),
  probs = c(1, 0, 0, 0),
  intensity_upp = NA
)

Arguments

guest_pattern

point pattern of class ppp or pp3. The final multtimer pattern will match this pattern in class, intensity, and domain. If this is left as NULL, then the domain will match that of upp, will be of the class specified in output, and have number of guests specified in n_guest

upp

point pattern of class ppp or pp3 to use as underlying point pattern. Multimers will be selected from these points.

output

leave as "guest pattern type" if specifying guest_pattern. Otherwise, set to "ppp" for 2D output or pp3 for 3D output

n_guests

leave as NA if specifying UPP. Otherwise, set to integer for number of guests in multimer pattern

min_thick

if guest_pattern is 2d (ppp) and upp is 3d (pp3) this determines the smallest z value to keep before collapsing into 2d.

max_thick

if guest_pattern is 2d (ppp) and upp is 3d (pp3) this determines the largest z value to keep before collapsing into 2d.

ztrim

a numeric. This will trim this amount from both top and bottom (positive and negative z) after multimers are generated and before pp3 pattern is collapsed into ppp. Only applies if upp is 3D (pp3)

group_size

size of clusters. If equal to 1, then all points will be independent of each other

num_neighbors

number of nearest neighbors to select from when forming dimers, trimers, etc..

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(-distances[ranks]))

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.

probs

vector of probabilities. Should sum to group_size-1. 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

intensity_upp

the upp will be rescaled to have this intensity before the marks are assigned. Leave as NA to use upp as it is

Details

algorithm steps:

  • Step 1: rescale upp to match intensity_upp

  • Step 2: Select points in the scaled upp that are inside the domain of guest_pattern.

  • Step 3: Determine number of guest groups or clusters (for dimers, this is number of guests / 2) and assign this many points in the scaled subsetted UPP to be guests. These are the "centroids"

  • Step 4: Take the num_neighbors closest point to each guest

  • Step 5: Rank each neighbor by weighted distance to centroid

  • Step 6: Using the probabilities in probs, select which neighbors are to be guests (so that the cluster size is now equal to group_size)

  • Step 7: For any duplicates, redo process so that correct number of guests are present

  • Step 8: If guest_pattern is 2D and UPP is 3D, remove Z coordinate to make new pattern 2D


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