blob.boundary: Find Blobs in 2 Dimensions

blob.boundaryR Documentation

Find Blobs in 2 Dimensions

Description

The idea is to compute the kernel density estimate of a 2D slice of a flowFrame, compute contours at a specified height, and then select that contour which is either (a) closest to a specified location, or (b) is the 'strongest' peak in the flowFrame. Optionally, you can specify that the contour be convex, in which case the function will attempt to find the largest convex contour at either location.

Usage

blob.boundary(
  ff,
  parameters = c("FSC-A", "SSC-A"),
  rotate = 0,
  x_range = NULL,
  y_range = NULL,
  location,
  strongest = FALSE,
  bandwidth = c(0.02, 0.02),
  gridsize = c(201, 201),
  height = 0.1,
  convex = FALSE,
  height1 = height,
  height2 = 0.05,
  delta_h = 0.01,
  log.transform = FALSE
)

Arguments

ff

The input flowFrame

parameters

Exactly 2 parameters included in ff

rotate

Rotation angle (in degrees) of the blob you're looking for

x_range

Range of x values to consider (default = NULL implies all x)

y_range

Range of y values to consider (default = NULL implies all y)

location

The target location of the blob (ignored if strongest = TRUE)

strongest

Logical, whether to look for the blob containing the highest density

bandwidth

2D measure of bandwidth used to compute the Kernel Density Estimate

gridsize

2D measure of gridsize used to compute the Kernel Density Estimate

height

The height at which to compute contours (height range is 0 - 1, 1 being the most dense peak)

convex

Logical, whether to find the largest convex polygon at the target location

height1

Starting height for searching for convex blob (only used if convex = TRUE)

height2

Ending height for searching for convex blob (only used if convex = TRUE)

delta_h

Step size used for searching for convex blob (only used if convex = TRUE)

log.transform

Logical, should we use the density or its logarithm

Details

blob.boundary uses contourLines to generate contours in density data. It can get confused in several circumstances. Sometimes it's hard to detect a weak blob in the presence of a very strong blob, particularly if they're close to each other and there's significant density connecting them. It's pretty easy to see why: contour lines will easily span between the two, effectively connecting them into one bigger blob. It is sometimes possible to pre-gate the data to eliminate dense regions known to be uninteresting, and which may interfere with blob finding.

It is sometimes useful to compute contours on the logarithm of density, rather than on the original density representation. If you set log.transform = TRUE, it's usually the case that a higher height parameter will work better than the smaller (default) value. This is because taking the log compresses the dynamic range, so effectively everything is sort of 'high'.

Value

A polygon, described as a 2-column matrix of coordinates. You can use this polygon to gate data using the flowCore function polygonGate(.gate = bb).


rogerswt/wadeTools documentation built on Feb. 16, 2023, 7:47 a.m.