Connecting Spots and Objects to Cells - veeninglab/BactMAP GitHub Wiki

When you want to connect your object outlines detected using MicrobeJ to cell outlines detected using Morphometrics, or turn your spot x/y coordinates into relative coordinates, you can use spotsInBox and objectInBox. These functions determine for each spot/object whether it is laying inside a cell or not.


SpotsInBox

Put spots in boxes

Description

Takes a dataframe containing mesh x/y coordinates and a dataframe containing spots or objects x/y coordinates and returns the relative localization of the spots/objects inside the meshes, and the relative coordinates of the meshes from the mid-point of each mesh, where the longest axis of the cell is horizontal in the x/y plane.

Usage

spotsInBox(spotdata, meshdata, Xs = "x", Ys = "y", Xm = "X", Ym = "Y", meshInOutput=FALSE)

Arguments

Argument Description
spotdata dataframe containing spot coordinates. Needs at least the columns $frame, $x and $y.Possible to define x/y column names in the function input arguments Xs and Ys.
mesh dataframe containing mesh coordinates. Needs at least the columns$frame, $cell, $x and $y. Possible to define x/y column names in the function input arguments Xm and Ym.
Xs column in dataframe spotfile containing the x-coordinates of the spots or object points. Default = "x".
Ys column in dataframe spotfile containing the y-coordinates of the spots or object points. Default = "y".
Xm column in dataframe MESH containing the x-coordinates of the mesh outline points. Default = "X".
Ym column in dataframe MESH containing the y-coordinates of the mesh outline points. Default = "Y".
meshInOutput Default FALSE. In most cases, the mesh used in the input of this function is the same as the output. However, in some cases, new columns are added (like Xrot or max.length). When these are not there in your input mesh, it can be useful to set meshInOutput to TRUE to keep the modified mesh as well as the relative spot dataframe spots_relative.

Value

A list of two data frames:

spots_relative:

Variable Description
$x x-coordinate of the spot or object point (same as original dataframe)
$y y-coordinate of the spot or object point (same as original dataframe)
$cell identifies the cell the spot/object point belongs to
$frame frame number of original image stack
$max.width maximum cell width
$max.length length of the cell
$l relative location of the spot/object point to the length axis of the cell
$d relative location of the spot/object point to the width axis of the cell

mesh:

Variable Description
$X x-coordinate of the mesh contour point (same as original dataframe)
$Y y-coordinate of the mesh contour point (same as original dataframe)
$cell identifies the cell
$frame frame number of the original image stack
$max.width maximum cell width
$max.length length of the cell
$X_rot x-coordinate of the mesh point when the cell is turned with the length axis horizontally, midpoint at coordinate (0,0)
$Y_rot y-coordinate of the mesh point when the cell is turned with the length axis horizontally, midpoint at coordinate (0,0)

Examples

#use example datasets from veeninglab.com/bactmap
load("DnaX_tracks.rda")
load("DnaX_mesh.rda")

##get spot data from ISBatch
spots <- DnaX_tracks

##get mesh data from Oufti
mesh <- DnaX_mesh

##get relative spot and mesh locations
outlist <- spotsInBox(spots, mesh, Xm="x", Ym="y")

ObjectInBox

Connect detected objects to detected cell meshes; turn all objects & cells in the same orientation for relative comparison.

Description

ObjectInBox is a function based on spotsInBox - it returns a dataframe which has the same variables as the object_relative dataframe.

Usage

objectInBox(objectdata, meshdata, mag = "No_PixelCorrection")

Arguments

Argument Description
objectdata Object dataframe with at least the variables: "ob_x" & "ob_y"(object outline coordinates), "frame" and "obID" (object identifier).
meshdata mesh dataframe.
mag Magnification converter (see pixels2um).

Value

An object_relative dataframe (see objects).

Examples


#example data (https://veeninglab.com/bactmap):

load("VanFL_meshWT.rda")
load("VanFL_objWT.rda")

WTmesh <- vanFL_meshWT

WTobjects <- vanFL_objWT

#these objects are already connected to cells. but no harm in re-doing:

WTbox <- objectInBox(WTobjects, WTmesh, mag="100x_DVMolgen")