YMa-lab / CARD

GNU General Public License v3.0
80 stars 20 forks source link

Imputation expression levels in plot #64

Open jebard opened 4 months ago

jebard commented 4 months ago

Afternoon, thanks very much for providing CARD to the community, its been very helpful.

I had one question regarding the imputation process as I am seeing some strange behaviors for a couple of genes. I have two 10x visium samples and ran the tutorial workflow on the data. For the bottom sample everything is behaving as expected, however for the top sample pictured, levels for Cd79b as show are considerably higher than I would expect based on the one or two spots that show expression in the loupe browser (and this tissue shouldn't have expression of this gene). Has anyone seen this before? CARD_EXP

Thanks for any advice

YMalab commented 4 months ago

Hi @jebard,

Thank you for your interest in our CARD package!

The imputation procedure will also be affected by the estimated cell type proportion. Does the cell type proportion also look reasonable to you for these two samples? Did you use reference based version or reference-free version of CARD?

Best, Ying

jebard commented 3 months ago

Thanks very much for following up! The cell type proportion does look a bit off to me, where it is over-estimating the population expressing Cd79b. That makes a lot of sense that the imputation is tied to the estimated proportion.

This was reference-based using the same single-cell set for both samples above. My assumption is that the quality of the top sample above might be insufficient for the analysis but it's hard to gauge.

I'll revisit the cell-type estimation steps and see if there is any thing I'm missing there, or how to clean up the data prior to moving forward in the pipeline.

Thanks! Jonathan

abasseville commented 2 months ago

Hi, Thanks for this great package, it is very helpful. I have exactly the same issue than @jebard, with several genes with a totally different expression pattern after the imputation process, see below for example and the code I used.

image

# se= seurat object with spatial transcriptomics

spatial_loc<-GetTissueCoordinates(se)
names(spatial_loc) <- c("x", "y")

ST_count <- se@assays[["Spatial"]]@layers$counts
rownames(ST_count) <-Features(se@assays[["Spatial"]])
colnames(ST_count) <-Cells(se@assays[["Spatial"]])

CARD_obj = createCARDObject(
  sc_count = scExpMat,
  sc_meta = scMetaData,
  spatial_count = ST_count,
  spatial_location = spatial_loc,
  ct.varname = "celltype_minor",
  ct.select = unique(scMetaData$celltype_minor),
  sample.varname = "Patient",
  minCountGene = 100,
  minCountSpot = 5) 
CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)
CARD_obj = CARD.imputation(CARD_obj,NumGrids = 2000,ineibor = 10,exclude = NULL)

smCARD_obj <- list(Prop_CARD=CARD_obj@Proportion_CARD, 
                   refined_prop=CARD_obj@refined_prop,
                   refined_expr=CARD_obj@refined_expression)

LocImp = cbind.data.frame(x=as.numeric(sapply(strsplit(rownames(smCARD_obj$refined_prop),split="x"),"[",1)),
                             y=as.numeric(sapply(strsplit(rownames(smCARD_obj$refined_prop),split="x"),"[",2)))
rownames(LocImp) = rownames(smCARD_obj$refined_prop)
names(LocImp) <- c("y", "x")
LocImp$x<- LocImp$x
LocImp$y<- -LocImp$y

names(spatial_loc) <- c("y", "x")
spatial_loc$x<- spatial_loc$x
spatial_loc$y<- -spatial_loc$y

gene.visualize <- c("ECEL1","CA12","CES1","AKR1C3")
NumCols=4

p1 <-Seurat::SpatialFeaturePlot(se, features = gene.visualize, 
                         keep.scale="feature",  
                         slot="data", ncol= NumCols,
                         alpha = c(1, 1),image.alpha = 0,
                         pt.size.factor = 6)

p2 <- CARD::CARD.visualize.gene(
  spatial_expression = ST_count,
  spatial_location = spatial_loc,
  gene.visualize = gene.visualize,
  colors = NULL,
  NumCols = NumCols)+ coord_fixed(ratio = 1 * min(spatial_loc$y)/max(spatial_loc$x))  +  
  theme(legend.position="right",
        legend.text=element_text(size=8),
        legend.title =element_text(size=8),
        strip.text.x = element_text(size = 8),legend.key.size = unit(4.5,"mm")) +
  guides(color = guide_colourbar(title = "sc expr.")) 

p3<- CARD::CARD.visualize.gene(
  spatial_expression = smCARD_obj$refined_exp,
  spatial_location = LocImp,
  gene.visualize = gene.visualize,
  colors = NULL,
  NumCols = NumCols)+ coord_fixed(ratio = 1 * min(spatial_loc$y)/max(spatial_loc$x))  +  
  theme(legend.position="right",
        legend.text=element_text(size=8),
        legend.title =element_text(size=8),
        strip.text.x = element_text(size = 8),legend.key.size = unit(4.5,"mm")) +
  guides(color = guide_colourbar(title = "sc expr."))