extract_spatial_summary {mxfda}R Documentation

Summarise spatial data in mxFDA object

Description

Summarise spatial data in mxFDA object

Usage

extract_spatial_summary(mxFDAobject, columns, grouping_columns = NULL)

Arguments

mxFDAobject

object of class mxFDA

columns

character vector for column heading for cells to summarise

grouping_columns

character vector of other columns to use as grouping, such as region classification column

Details

[Experimental]

Currently this function is experimental as it only handles data that has text in the columns. Eventually, will be able to handle any data inputs such as those from HALO where cells are designated as positive (1) or negative (0) for a cell phenotypes.

Value

data frame with percent of total points per spatial sample columns. If multiple levels are present in columns columns, multiple output columns will be provided.

Author(s)

Alex Soupir alex.soupir@moffitt.org

Examples

#load data
data(lung_df)

#create data frames for `mxFDA` object
clinical = lung_df %>%
  dplyr::select(image_id, patient_id, patientImage_id, gender,
         age, survival_days, survival_status, stage) %>%
  dplyr::distinct()
#make small, just need to make sure it runs
spatial = lung_df %>%
  dplyr::select(-image_id, -gender, -age, -survival_days, -survival_status, -stage) %>%
  dplyr::filter(patientImage_id %in% clinical$patientImage_id[1:10])

#create `mxFDA` object
mxFDAobject = make_mxfda(metadata = clinical,
                         spatial = spatial,
                         subject_key = "patient_id",
                         sample_key = "patientImage_id")

#get markers
markers = colnames(mxFDAobject@Spatial) %>%
  grep("pheno", ., value = TRUE)

#extract summary
df = extract_spatial_summary(mxFDAobject, markers)


[Package mxfda version 0.2.1 Index]