Open SavKilPat opened 6 days ago
Hi, try getSpatAnnBarcodes(object)
. This function returns a character vector of barcodes of the specified annotations. If you want to work with getCoordsDfSA()
, this works, too. But you have to subset it such that only the spots remain that are located inside the annotations - rel_loc == 'core'. See the example below:
library(SPATA2)
library(tidyverse)
object <- loadExampleObject("UKF313T", process = T, meta = T)
getSpatAnnIds(object)
bcs_necr_area <- getSpatAnnBarcodes(object, ids = "necrotic_area")
ids_all <- c("necrotic_area", "necrotic_edge", "necrotic_edge2")
bcs_necr_all <- getSpatAnnBarcodes(object, ids = ids_all)
coords_df <- getCoordsDfSA(object, ids = ids_all)
coords_df$necr_area <- coords_df$barcodes %in% bcs_necr_area
coords_df$necr_all <- coords_df$barcodes %in% bcs_necr_all
plotSurface(coords_df, "necr_area")
plotSurface(coords_df, "necr_all")
plotSurface(coords_df, color_by = "id") # closest to which annotation?
plotSurface(coords_df, color_by = "rel_loc")
dplyr::filter(coords_df, rel_loc == "core") %>% plotSurface(object = ., color_by = "id")
Does that help?
Hey, for some reason I only see your reply by mail not in this issue. But I'll answer here anyway.
First of all: This error here...
coords_df <- getCoordsDfSA(FAM3WT_Init3, ids = ids_all)
...makes me believe that you are currently working in the master branch and not in the dev-branch. Because what causes this error does not exist any longer in the dev-branch. Can you make sure to have the dev-branch installed and loaded? The function currentSpata2Version()
should output a list with $major == 3, $minor == 1, $patch == 0. And then try getCoordsDfSA()
again.
If the error "Error in ma@mtr_proc[[nm]][, bcs_keep] : incorrect number of dimensions" remains during subsetting. Can you give me the output of assay <- getAssay(object); purrr::map(assay@mtr_proc, .f = str)
.
Hi Milo lab,
Thanks very much for providing such a user-friendly tool for annotating spatial transcriptomics.
I've been attempting to isolate/subset specific cell types within a region of interest created with the
createImageAnnotations
function. The cell types are interest are from my previous Seurat-processed dataset, which I'm able to isolate successfully using thesubsetSpataObject
function. However, I cannot seem to isolate the regions of interest using a similar approach. I'm met with the following error :Which presumably is because the spatial annotation barcodes are pulled from a different part of the metadata. Below is my code to get the error.
So far I have tried the following:
addMetaDataObs
error, and the object comes back as
I'm hopeful I can proceed with some form of subsetting or
asSeurat
option as I'll likely have to do this in the future with the object for CellChat analysis.Do you have any suggestions on how to proceed? Thanks as always!!
Sincerely,
Savannah
PS if context helps, I'm trying to isolate cells pre- and post-migration and perform DEG analysis between them and other genotypes.