prepare_coords_df_visium_hd.Rd
This function prepares a data frame of spatial coordinates for Visium HD analysis by adjusting the coordinates to form a grid of evenly sized squares and grouping them into larger aggregate squares. It ensures the grid dimensions are divisible by a given factor, and it predicts missing coordinates.
prepare_coords_df_visium_hd(coords_df, fct)
A data frame containing the original spatial coordinates.
It must include columns row
, col
, x_orig
, and y_orig
representing the
spatial grid positions and original coordinates.
An integer factor by which the dimensions of the grid should be divisible. This ensures the grid can be evenly divided into larger squares.
A data frame with adjusted spatial coordinates, new row and column groupings, predicted coordinates, and updated barcodes.
The function adjusts the input coordinates to form a perfect rectangular
grid of squares and groups them into larger squares based on the provided factor (fct
).
It ensures that both the row and column counts are divisible by fct
by expanding
the grid if necessary. The function then assigns new groupings to these aggregated
squares and predicts missing x
and y
coordinates using linear models based
on the original coordinates. The output is a data frame that includes these new
groupings and predicted coordinates.
The main steps include:
Calculating scaling factors for the columns and rows.
Adjusting the grid to ensure divisibility by fct
and equal lengths of rows and columns.
Creating new row and column groups and generating corresponding barcodes.
Predicting missing x
and y
coordinates using linear models.