This function reduces a data frame of spatial coordinates for Visium HD samples by summarizing and aggregating the data at the new barcode level.

reduce_coords_df_visium_hd(coords_df_prep, fct)

Arguments

coords_df_red

The output data.frame of the prepare_coords_df_visium_hd() function.

Value

A summarized data frame with one row per new barcode, containing aggregated spatial coordinates and counts.

Details

The function aggregates the spatial coordinates based on the new barcodes created in the previous step. It calculates summary statistics for each new barcode group, including:

  • x_orig, y_orig: The original x and y coordinates at the new barcode level.

  • col, row: The numeric values of the column and row groups.

  • square_exp: The theoretical number of original spots that could fall into the new aggregated spot.

  • square_count: The actual number of non-missing spots observed.

  • square_perc: The relative number of observed spots as a proportion of the theoretical number.