Skip to contents

supporting function for runPreprocess, fastReseg_internalRef and fastReseg_flag_all_errors to get unique IDs for cells and transcripts, and convert pixel coordinates to um; when drop_original = FALSE, the function will also return original per FOV based cell ID and coordinates under columns CellId, pixel_x, pixel_y, idx_z`.

Usage

prepare_perFOV_transDF(
  each_transDF,
  fov_centerLocs,
  prefix_vals = NULL,
  pixel_size = 0.18,
  zstep_size = 0.8,
  transID_coln = NULL,
  transGene_coln = "target",
  cellID_coln = "CellId",
  spatLocs_colns = c("x", "y", "z"),
  extracellular_cellID = NULL,
  drop_original = FALSE
)

Arguments

each_transDF

data.frame for raw transcript

fov_centerLocs

a named vector of fov 2D coordinates

prefix_vals

a named vector of values to be used as prefix in UMI_transID and UMI_cellID; when prefix_vals != NULL, unique transcript_id would be generated from prefix_vals and transID_coln in each_transDF

pixel_size

the micrometer size of image pixel listed in 1st and 2nd dimension of spatLocs_colns of each_transDF

zstep_size

the micrometer size of z-step for the optional 3rd dimension of spatLocs_colns of each_transDF

transID_coln

the column name of transcript_ID in transcript_df, default = NULL to use row index of transcript in each_transDF; when prefix_vals != NULL, unique transcript_id would be generated from prefix_vals and transID_coln in each_transDF

transGene_coln

the column name of target or gene name in each_transDF

cellID_coln

the column name of cell_ID in each_transDF; when prefix_colns != NULL, unique cell_ID would be generated from prefix_vals and cellID_coln in each transcript_df

spatLocs_colns

column names for 1st, 2nd and optional 3rd dimension of spatial coordinates in each_transDF

extracellular_cellID

a vector of cell_ID for extracellular transcripts which would be removed from the resegmention pipeline (default = NULL)

drop_original

flag to drop original per FOV based cell ID and coordinates under columns CellId, pixel_x, pixel_y, idx_z (default = FALSE)

Value

a list contains transcript_df for downstream process and extracellular transcript data.frame '

intraC

a data.frame for intracellular transcript, UMI_transID and UMI_cellID as column names for unique transcript_id and cell_id, target as column name for target gene name

extraC

a data.frame for extracellular transcript, same structure as the intraC data.frame in returned list