This function adds spatial ecotype annotations to the metadata of single cells.
Arguments
- scmeta
- Data frame containing single-cell metadata. Two columns (X and Y) for spatial coordinates are required. 
- obj
- A Seurat object returned from SpatialEcoTyper function. 
- col
- Character string specifying the name of the column in `obj@meta.data` containing the spatial ecotype annotations. Default is `"SE"`. 
- dropcell
- Logical. If TRUE, cells that cannot be assigned to any spatial ecotype (outside the radius) will be removed from the returned metadata. Default is TRUE. 
Examples
library(data.table)
#> 
#> Attaching package: ‘data.table’
#> The following objects are masked from ‘package:dplyr’:
#> 
#>     between, first, last
library(Seurat)
library(SpatialEcoTyper)
library(googledrive)
drive_deauth() # no Google sign-in is required
## Download a single-cell meta data
drive_download(as_id("1CgUOQKrWY_TG61o5aw7J9LZzE20D6NuI"),
                    "HumanMelanomaPatient1_subset_scmeta.tsv",
                     overwrite = TRUE)
#> File downloaded:
#> • HumanMelanomaPatient1_subset_scmeta.tsv
#>   <id: 1CgUOQKrWY_TG61o5aw7J9LZzE20D6NuI>
#> Saved locally as:
#> • HumanMelanomaPatient1_subset_scmeta.tsv
## Obtain a Seurat object from SpatialEcoTyper result
drive_download(as_id("1nSPj2zRywFUdbo1fwiz77ds4NuM6bmV2"),
              "Melanoma1_subset_SpatialEcoTyper_results.rds", overwrite = TRUE)
#> Error in map(as_id(id), get_one_file_id): ℹ In index: 1.
#> Caused by error in `.f()`:
#> ! Client error: (404) Not Found
#> File not found: 1nSPj2zRywFUdbo1fwiz77ds4NuM6bmV2.
#> • message: File not found: 1nSPj2zRywFUdbo1fwiz77ds4NuM6bmV2.
#> • domain: global
#> • reason: notFound
#> • location: fileId
#> • locationType: parameter
scmeta <- read.table("HumanMelanomaPatient1_subset_scmeta.tsv",
                     sep = "\t", header = TRUE, row.names = 1)
head(scmeta)
#>                                         X         Y   CellType CellTypeName
#> HumanMelanomaPatient1__cell_3655 1894.706 -6367.766 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3657 1942.480 -6369.602 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3658 1963.007 -6374.026 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3660 1981.600 -6372.266 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3661 1742.939 -6374.851 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3663 1921.683 -6383.309 Fibroblast  Fibroblasts
#>                                  Region Dist2Interface
#> HumanMelanomaPatient1__cell_3655 Stroma      -883.1752
#> HumanMelanomaPatient1__cell_3657 Stroma      -894.8463
#> HumanMelanomaPatient1__cell_3658 Stroma      -904.1115
#> HumanMelanomaPatient1__cell_3660 Stroma      -907.8909
#> HumanMelanomaPatient1__cell_3661 Stroma      -874.2712
#> HumanMelanomaPatient1__cell_3663 Stroma      -903.6559
obj <- readRDS("Melanoma1_subset_SpatialEcoTyper_results.rds")$obj
## Transfer SE annotations to single cells
scmeta <- AnnotateCells(scmeta = scmeta, obj = obj, dropcell = TRUE)
head(scmeta)
#>                                         X         Y   CellType CellTypeName
#> HumanMelanomaPatient1__cell_3655 1894.706 -6367.766 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3657 1942.480 -6369.602 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3658 1963.007 -6374.026 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3660 1981.600 -6372.266 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3661 1742.939 -6374.851 Fibroblast  Fibroblasts
#> HumanMelanomaPatient1__cell_3663 1921.683 -6383.309 Fibroblast  Fibroblasts
#>                                  Region Dist2Interface  SE
#> HumanMelanomaPatient1__cell_3655 Stroma      -883.1752 SE0
#> HumanMelanomaPatient1__cell_3657 Stroma      -894.8463 SE6
#> HumanMelanomaPatient1__cell_3658 Stroma      -904.1115 SE6
#> HumanMelanomaPatient1__cell_3660 Stroma      -907.8909 SE6
#> HumanMelanomaPatient1__cell_3661 Stroma      -874.2712 SE0
#> HumanMelanomaPatient1__cell_3663 Stroma      -903.6559 SE0
