meichendong / SCDC

SCDC
42 stars 9 forks source link

Error running SCDC_prop_ONE() #19

Open bvieth opened 3 years ago

bvieth commented 3 years ago

Dear Meichen,

I am trying to run SCDC with only one reference single cell rna seq data set, i.e. only one subject, e.g. sample H2 in Segerstolpe example data set. SCDC_prop_ONE() runs until it encounters an error due to incompatible data in function SCDC_peval() line 258-260 on github, namely:

  if (!is.data.frame(ptrue)){
  ptrue <- as.data.frame.matrix(ptrue)
  }

The following error message is displayed:

Error in seq_len(ncols) : 
  argument must be coercible to non-negative integer
In addition: Warning message:
In seq_len(ncols) : first element used of 'length.out' argument

It would be great if you could adapt the SCDC_peval() function. It ran smoothly when I used the full Segerstolpe example data set with function SCDC_prop().

Best Beate

Here is my example workflow:

ct1 <- c("mediumorchid1","mediumpurple1","lightskyblue","seagreen1","yellow","tan1","azure3")
seger <- readRDS("segerstolpe.rds")
DemoPlot(seger, cluster = "cluster", sample = "sample", select.ct = c("alpha","beta","delta","gamma","ductal","acinar"), Palette = ct1)

# subset seger to one sample
seger
cnts <- exprs(seger)
dim(cnts)
fdata <- rownames(cnts)
pdata <- pData(seger) %>% 
  dplyr::filter(sample == "H2")
cnts.red <- cnts[,colnames(cnts) %in% rownames(pdata)]

eset <- getESET(cnts.red, fdata = fdata, pdata = pdata)

seger <- eset

seger.qc <- SCDC_qc_ONE(seger, ct.varname = "cluster", sample = "sample", scsetname = "Segerstolpe",
                    ct.sub = c("alpha","beta","delta","gamma","ductal","acinar"), qcthreshold = 0.7) 
seger.qc$heatfig

## using all single cells
pseudo.seger <- generateBulk_allcells(seger.qc$sc.eset.qc, 
                                         ct.varname = "cluster", 
                                         sample = "sample",
                                         ct.sub = c("alpha","beta","delta","gamma"))
bulkseger.scseger <- SCDC_prop_ONE(bulk.eset = pseudo.seger$pseudo_eset,
                                   sc.eset = seger.qc$sc.eset.qc, 
                                   ct.varname = "cluster",
                                   sample = "sample", 
                                   ct.sub = c("alpha","beta","delta","gamma"), 
                                   truep = pseudo.seger$truep)
meichendong commented 3 years ago

Thank you for pointing out the problem @bvieth ! I appreciate your feedback!