dmcable / spacexr

Spatial-eXpression-R: Cell type identification (including cell type mixtures) and cell type-specific differential expression for spatial transcriptomics
GNU General Public License v3.0
296 stars 72 forks source link

Using Bulk RNA-seq data as a reference for Full mode deconvolution of Visium #116

Closed moutazhelal closed 1 year ago

moutazhelal commented 1 year ago

Dear Authors,

Thank you for making such a wonderful tools.

I was wondering if I can use Bulk RNA-seq data as a reference to deconvolute a 10x Visium slide using your tools. I am thinking of using BlueprintEncode data set provided in Celldex R package. I wanted to make sure that my workflow is correct. I only had to reduce CELL_MIN_INSTANCE in create.RCTD and prior to that removed all labels that contain only one replicate.

I followed this :

#////////////////// Working on the ref data /////////////////////////////////////////

ref <- BlueprintEncodeData()
log_counts = assay(ref)
metadata = as_tibble(colData(ref), rownames= NA)
raw_counts = (2^log_counts)
metadata_new = metadata %>% rownames_to_column("Cells") 
cellltypes_to_include = c("Neutrophils", "Monocytes" ,"CD4+ T-cells" ,"NK cells"          
                          , "naive B-cells", "Macrophages" ,     "CD8+ T-cells"                  
                          , "Megakaryocytes"  ,  "Macrophages M1"  , "Macrophages M2" 
                          , "Endothelial cells"  ,   "Plasma cells"   
                          ,   "Fibroblasts"  , "Smooth muscle"  ,"Epithelial cells" ,"Skeletal muscle" 
                          ,  "mv Endothelial cells"  ,  "Adipocytes"  , "Pericytes"   , "Mesangial cells")

metadata_new =  metadata_new[metadata_new$label.fine %in% cellltypes_to_include, ]
cell_types <- metadata_new$label.fine; names(cell_types) <- metadata_new$Cells # create cell_types named list
cell_types <- as.factor(cell_types) # convert to factor data type

### Create the Reference object
reference <- Reference(raw_counts, cell_types, require_int = FALSE)
#//////////////////deconvolution ////////////////////////////////////////////////////
myRCTD <- create.RCTD(visium, reference, max_cores = 10, CELL_MIN_INSTANCE = 2)
myRCTD <- run.RCTD(myRCTD , doublet_mode = 'full')

Please could you confirm that my workflow is correct and if you have any suggestion to improve it

Thank you very much,

Best, Moutaz

dmcable commented 1 year ago

Yes, that looks good. I am assuming your conversion from log_counts to raw_counts is correct.