Skip to contents

Select cell types to keep or exclude in the analysis. The output of this function also includes the original image size and cell count.

Usage

select_celltypes(
  sce_object,
  celltypes,
  feature_colname = "Phenotype",
  keep = TRUE
)

Arguments

sce_object

SingleCellExperiment object generated by format_image_to_sce.

celltypes

String Vector of celltypes of keep or exclude.

feature_colname

String. The column that has the interested cell types. If the cells of interest are specified in the rownames, use "rowname" for this arg.

keep

Boolean. TRUE if vector of `celltypes` are the cells that are going to be kept, FALSE if they are to be removed.

Value

A SingleCellExperiment object is returned. The original image size and cell count can be accessed by `attr(slim_sce, "original_cell_number")` and `attr(slim_sce, "range_of_coords")`.

Examples

data_subset <- select_celltypes(SPIAT::simulated_image,
celltypes = c("Tumour_marker","Immune_marker1","Immune_marker2","Immune_marker3","Immune_marker4"),
feature_colname = "Phenotype", keep=TRUE)
attr(data_subset, "original_cell_number") #cell number in the original image
#> [1] 4951
attr(data_subset, "range_of_coords")
#> [1]    0.1869877 1999.9512939    0.3243161 1998.9921875
dim(data_subset)[2] # this is the new image cell number
#> [1] 819