Functions for condensing FOVs and tissues to minimize whitespace

visualization
Author
Affiliations

Patrick Danaher

NanoString, a Bruker Company

Github: patrickjdanaher

Published

January 26, 2024

Modified

April 17, 2024

Condensing cells in xy space for better plotting

Minimizing whitespace while plotting cells in xy space is a constant challenge. A single tissue will often have discontinuous FOVs, and aligning multiple tissues in a sensible way can be onerous.

Here, for example, are FOVs collected from core needle biopsies, where the cells can barely be seen against the vast expanse of white space.

As a partial solution, see the function consenseXY(), provided here.

The main wrapper function contains an algorithm for pulling together FOVs from the same tissue, and an algorithm for tiling tissues across a plot.

Here’s a toy example of FOV groups from two tissues before and after the algorithm (color denotes tissue ID):

It’s not perfect, but it’s an improvement on the original spacing with no thought or manual labor.

Warning: the FOV condensing code is inefficiently written and takes longer than it should, though it’s still faster than working by hand.