R/spatial_exp_to_mif.R
spatial_exp_to_mif.Rd
Creates an MIF object for use in spatialIF functions using a Bioconductor SpatialExperiment object as input.
spatial_exp_to_mif(
spatial_exp,
markers,
x_coord = "cell_x_position",
y_coord = "cell_y_position",
patient_id = "patient_id",
sample_id = "sample_id",
cols_to_keep = NULL,
marker_pos_regex = "\\+"
)
A SpatialExperiment object to create a MIF from a SpatialExperiment Bioconductor object.
A character vector that contains the name(s) of the columns that contains +/- for markers. This will be used to recode these columns into logical vectors for presence or absence of the marker. By default looks for a + to indicate presence. But this can be altered using the
The name of the column in `spatialCoords` that contains the x coordinates for the cell. Default is "cell_x_position".
The name of the column in `spatialCoords` that contains the y coordinates for the cell. Default is "cell_y_position".
The name of the column in `colData` and `metadata` that contains the sample IDs. Default is "patient_id",
The name of the column in `colData` and `spatialCoords` that contains the sample IDs. Default is "sample_id".
(Optional) By default only the patient_id, markers, sample_id, and x and y coordinate columns will be kept. But if there is additional information that needs to be kept, you can add those column names here. Or say "everything" if you want all columns to be kept. This may not be advisable for large datasets.
By default will identify all markers columns as having a marker if a `+` is found in the data. But with this variable You can choose a different character to sort in presence/absence. Anything with the regex character given to this parameter will be labeled as positive and all other cells will be labeled as negative.
Returns a custom MIF
Data frame of clinical data
Data frame of sample data
Named list of spatial data
List of data derived using the MIF object
The column name for sample id in the sample data frame with the clinical data
The column name for sample id in the sample data frame to merge with the spatial data
# Create mif object
if (!("VectraPolarisData" %in% installed.packages())) {
BiocManager::install("VectraPolarisData")
}
ovarian <- VectraPolarisData::HumanOvarianCancerVP()
#> snapshotDate(): 2024-10-24
#> Warning: package ‘SingleCellExperiment’ was built under R version 4.4.2
#> Warning: package ‘MatrixGenerics’ was built under R version 4.4.2
#> Warning: package ‘IRanges’ was built under R version 4.4.2
#> Warning: package ‘GenomeInfoDb’ was built under R version 4.4.2
#> see ?VectraPolarisData and browseVignettes('VectraPolarisData') for documentation
#> loading from cache
ova_mif <- spatial_exp_to_mif(spatial_exp = ovarian,
patient_id = "sample_id",
markers = c("phenotype_cd68", "phenotype_cd3", "phenotype_cd8"))
spe_lung <- VectraPolarisData::HumanLungCancerV3()
#> see ?VectraPolarisData and browseVignettes('VectraPolarisData') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#>
#> loading from cache
spe_mif <- spatial_exp_to_mif(spatial_exp = spe_lung,
patient_id = "slide_id",
sample_id = "slide_id",
markers = c(
"phenotype_cd4",
"phenotype_cd8",
"phenotype_cd14",
"phenotype_cd19",
"phenotype_ck",
"phenotype_other"))