reduceResolutionVisiumHD | R Documentation |
This function reduces the spatial resolution of Visium HD data by aggregating spatial
spots into larger units, recalculating the count matrix, and generating a new SPATA2
object with the reduced resolution.
reduceResolutionVisiumHD(
object,
res_new,
new_sample_name = "{sample_name}_redResHD",
genes = getGenes(object),
batch_size = 1000,
workers = 1,
verbose = NULL
)
object |
An object of class |
res_new |
Distance measure. The new spatial resolution in micrometers (um). It must be lower than the current resolution and divisible by the current resolution. |
new_sample_name |
Character string for the name of the new sample after
resolution reduction. Default is |
genes |
Character vector specifying which genes to include in the reduced
object. Reducing the number of genes can dramatically spead up the process.
See |
batch_size |
Integer specifying the number of spatial spots to process in each batch. Default is |
workers |
Integer specifying the number of parallel workers to use for processing. Default is |
verbose |
Logical. If (Warning messages will always be printed.) |
... |
Additional arguments passed to other methods. |
The reduceResolutionVisiumHD()
function reduces the spatial resolution of a Visium HD
dataset by aggregating neighboring spots into larger units and recalculating the count
matrix for the new resolution. The process involves the following key steps:
Resolution check: Ensures the new resolution (res_new
) is greater
than the current resolution and is divisible by it.
Coordinate preparation: Uses the prepare_coords_df_visium_hd()
function to adjust the spatial coordinates, creating a grid where both row and
column counts are divisible by a factor derived from the resolution change. This
function also ensures equal row and column lengths and predicts missing coordinates.
Resolution reduction: Applies the reduce_coords_df_visium_hd()
function to aggregate the prepared coordinates at the new resolution. This function
groups the data by new barcodes, summarizes the spot counts, and calculates the
theoretical versus actual number of spots in each aggregated unit.
(Since tissue is rarely a perfect rectangle, the new grid of squares often contains squares that, if located at the edge of the tissue, contain aggregated data of the fewer resolution squares than if not located on the tissue edge. This information is stored in the meta variables n_square_exp, n_square_actual and n_square_perc. See examples.)
Count matrix summarization: The count matrix is recalculated by summing up the counts of each new square. This step is optimized with parallel processing if multiple workers are specified.
SPATA2 object creation: A new SPATA2
object is generated
with the reduced resolution data, including updated spatial data and metadata.
The assignment of barcodes under high resolution and new barcodes under which
they have been aggrated is stored in a list in slot object@obj_info$reduceResolutionVisiumHD$aggregated_barcodes
.
The updated input object, containing the added, removed or computed results.
Only works on SPATA2
object for platform VisiumHD
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.