YMa-lab / CARD

GNU General Public License v3.0
101 stars 21 forks source link

Error in Deconvolution dim(X) #13

Closed juliaryann closed 2 years ago

juliaryann commented 2 years ago

Hi! When running the deconvolution step of CARD I get this error, I am not sure what the issue is and how dim(X) could be negative.

 CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)
## create reference matrix from scRNASeq...
## Select Informative Genes! ...
Error in apply(temp, 1, var) : dim(X) must have a positive length

Thank you!

YingMa0107 commented 2 years ago

Hi @juliaryann,

Thank you for your interest in our package. Could you please provide more information for me? Can you try to check the following things:

  1. Check the gene names in the CARD_obj@sc_eset and CARD_obj@spatial_countMat, they should have overlap
  2. check if ct.select(not be NULL), ct.varname (not be NULL), and sample.varname (this could be NULL) the arguments you provided make sense in your CARD_obj@sc_eset data.
  3. check if there are NA values in your cell type in the sc_meta data: print(unique(sc_meta[,ct.select]))
  4. check if the following code can run your data:
    
    sc_eset = CARD_obj@sc_eset
    ct.varname = CARD_obj@info_parameters$ct.varname
    ct.select = CARD_obj@info_parameters$ct.select
    ##### check if the ct.select existing in the single cell RNAseq reference
    print(ct.select  %in% colData(sc_eset)[,ct.varname])

There might be something wrong when creating the reference basis matrix using the scRNASeq dataset. 

Hope these help! 
juliaryann commented 2 years ago

Hi! I tried these things and I am still getting errors. There is overlap between the gene names in sc_eset and epatial_countMat. However ct.select, ct.varname, and sample.varname can not be found, and 'CARD_object' can also not be found when running the code. What should I do from here? Thank you for the help!

YingMa0107 commented 2 years ago

Hi @juliaryann,

I have updated the previous answer since it should be CARD_obj if you follow the tutorial to create the CARD_obj first. And I also updated the package to add one more NA value removal in the input cell types, please re-install the package first and try your code, and check those steps that I mentioned in the previous answer!

Let me know if it works or not! Thanks!

Best, Ying

juliaryann commented 2 years ago

Ying, When I run that code, I run into this issue

> sc_eset = CARD_obj@sc_eset
> ct.varname = CARD_obj@info_parameters$ct.varname
> ct.select = CARD_obj@info_parameters$ct.select
> ##### check if the ct.select existing in the single cell RNAseq reference
> print(ct.select  %in% colData(sc_eset)[,ct.varname])
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'table' in selecting a method for function '%in%': could not find function "colData"

There are no NA in the sc_meta cell types and ct.select and ct.varname are not Null (sample.varname does not exist however). I wasn't able to find any info on this error, any help would be appreciated.

-Julia

YingMa0107 commented 2 years ago

Hi @juliaryann,

Thank you for the details, when you run that code, the error indicates that there is no function of the colData, so please run library(SingleCellExperiment) before checking the code. Sorry I did not specify it earlier.

Could you please check the following code after you create a CARD object?

library(SingleCellExperiment)
library(CARD)
ct.select = CARD_object@info_parameters$ct.select
print(ct.select)
ct.varname = CARD_object@info_parameters$ct.varname
sample.varname = CARD_object@info_parameters$sample.varname 
sc_eset = CARD_object@sc_eset
print(unique(colData(sc_eset)[,ct.varname])) ### check if there are NA in your sc_eset 
print(table(colData(sc_eset)[,ct.varname],useNA = "ifany")) ### check number of cells in each cell type
Basis_ref = createscRef(sc_eset, ct.select, ct.varname, sample.varname)
Basis = Basis_ref$basis
print(colnames(Basis)) ##### check the column names of the matrix to see if it matched with ct.select
Basis = Basis[,colnames(Basis) %in% ct.select]
Basis = Basis[,match(ct.select,colnames(Basis))]
print(head(Basis))
spatial_count = CARD_object@spatial_countMat
commonGene = intersect(rownames(spatial_count),rownames(Basis))
print(head(commonGene)) ##### check how many common genes in spatial and single cell count
##### code ends

Thanks!

juliaryann commented 2 years ago

Hi! With the SingleCellExperiment library, the first set of code you sent me outputs all TRUE. This is the output I get from the second block of code:

 ct.select = CARD_obj@info_parameters$ct.select
> print(ct.select)
 [1] "myCAF"     "iCAF"      "High_Ribo" "prolifCAF" "i+myCAF"   "my+iCAF"  
 [7] "Epi+Fib"   "my+apCAF"  "ap+myCAF"  "apCAF"    
> ct.varname = CARD_obj@info_parameters$ct.varname
> sample.varname = CARD_obj@info_parameters$sample.varname 
> sc_eset = CARD_obj@sc_eset
> print(unique(colData(sc_eset)[,ct.varname])) ### check if there are NA in your sc_eset 
 [1] "myCAF"     "prolifCAF" "i+myCAF"   "my+iCAF"   "Epi+Fib"   "iCAF"     
 [7] "my+apCAF"  "ap+myCAF"  "apCAF"     "High_Ribo"
> Basis_ref = createscRef(sc_eset, ct.select, ct.varname, sample.varname)
> Basis = Basis_ref$basis
> print(colnames(Basis)) ##### check the column names of the matrix to see if it matched with ct.select
 [1] "myCAF"     "prolifCAF" "i+myCAF"   "my+iCAF"   "Epi+Fib"   "iCAF"     
 [7] "my+apCAF"  "ap+myCAF"  "apCAF"     "High_Ribo"
> Basis = Basis[,colnames(Basis) %in% ct.select]
> Basis = Basis[,match(ct.select,colnames(Basis))]
> print(head(Basis))
             myCAF        iCAF  High_Ribo   prolifCAF     i+myCAF     my+iCAF
Sox17   -0.1024250  0.23249925 -0.1400711 -0.10495387 -0.05346745 -0.10018066
Mrpl15   0.1195730  0.38659817  0.3490624  0.30754635  0.10228034  0.03458952
Lypla1   0.1276162 -1.30475192 -0.5337000  0.14123192  0.12036852  0.11451268
Tcea1    0.1375324 -0.15995621  0.3729047  0.25912451 -0.07079306  0.03690285
Atp6v1h  0.1650600 -0.08187377 -0.5670838  0.01479993 -0.15242780  0.10582656
Rb1cc1   0.1242610 -0.79372336 -0.8836268 -0.05298836  0.09367701  0.17011826
           Epi+Fib    my+apCAF     ap+myCAF      apCAF
Sox17   1.30628654 -0.01962047 -0.018588151 -0.1226581
Mrpl15  0.44570355  0.21061670  0.170325193  0.3157341
Lypla1  0.06961614 -0.05532176 -0.080294108  0.2478926
Tcea1   0.06556051  0.10777459  0.005205425  0.1509514
Atp6v1h 0.00703218  0.06694386  0.264598235  0.2796918
Rb1cc1  0.13432530  0.36139456  0.103994680  0.1082567
> spatial_count = CARD_obj@spatial_countMat
> commonGene = intersect(rownames(spatial_count),rownames(Basis))
> print(head(commonGene)) ##### check how many common genes in spatial and single cell count
[1] "Sox17"   "Lypla1"  "Tcea1"   "Atp6v1h" "Rb1cc1"  "Pcmtd1" 
> ##### code ends

With these results, how should I proceed with deconvolution from here?

Thank you so much for your time, Julia

rimelof commented 2 years ago

Hello,

I am getting the same error. I also run the same debug codes with similar result. Any idea on how to proceed with the analysis?

Thanks!

YingMa0107 commented 2 years ago

Hi @juliaryann,

Based on your output, it seems that the basis matrix contain negative values. Is your scRNAseq log normalized or does it contain negative values? Ideally, the data for the single cell data and the spatial data should be count data since we construct the reference basis matrix utilizing the relation ship between mean gene expression (reference basis matrix) and the mixed gene expression (spatial data). And both the scRNAseq data and the spatial data should always be nonnegative since CARD is a NMF based model! More details please see my previous answer in the post: https://github.com/YingMa0107/CARD/issues/14

Thanks!

YingMa0107 commented 2 years ago

Hi @rimelof,

Thank you for your interest! If you also observed negative value in the Basis matrix, please use the scRNASeq reference data in the count format. Thank you!

Best, Ying

rimelof commented 2 years ago

Hi @YingMa0107 ,

Thank you for the reply.

I did not had negative values. I will share the actual output:

> sc_eset = CARD_obj@sc_eset
> ct.varname = CARD_obj@info_parameters$ct.varname
> ct.select = CARD_obj@info_parameters$ct.select
> ##### check if the ct.select existing in the single cell RNAseq reference
> print(ct.select  %in% colData(sc_eset)[,ct.varname])
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[24] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[47] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[70] TRUE TRUE TRUE TRUE
> ct.select = CARD_object@info_parameters$ct.select
Error: object 'CARD_object' not found
> print(ct.select)
 [1] "EC-PTC"  "C-TAL"   "MAC-M2"  "PT-S1"   "EC-DVR"  "aPT"     "C-PC"    "dM-FIB"  "DTL1"    "EC-GC"   "T"      
[12] "dM-TAL"  "dM-PC"   "IMCD"    "M-TAL"   "aTAL1"   "C-IC-A"  "dPT"     "M-IC-A"  "M-PC"    "POD"     "PT-S3"  
[23] "IC-B"    "dPT-DTL" "MD"      "VSMC-P"  "EC-AVR"  "DCT"     "CNT"     "dATL"    "B"       "MDC"     "MYOF"   
[34] "dC-TAL"  "dFIB"    "DTL2"    "VSMC"    "PL"      "aTAL2"   "dC-IC-A" "tPC-IC"  "M-FIB"   "PEC"     "FIB"    
[45] "dPOD"    "aFIB"    "ATL"     "PT-S2"   "PapE"    "EC-LYM"  "dVSMC"   "MC"      "EC-AEA"  "dIMCD"   "DTL3"   
[56] "dCNT"    "cycEC"   "dDCT"    "NKT"     "dDTL3"   "dEC-PTC" "dEC"     "cycPT"   "N"       "SC-NEU"  "ncMON"  
[67] "cycCNT"  "pDC"     "MAST"    "cycDCT"  "cycMNP"  "REN"     "cDC"    
> ct.select = CARD_obj@info_parameters$ct.select
> print(ct.select)
 [1] "EC-PTC"  "C-TAL"   "MAC-M2"  "PT-S1"   "EC-DVR"  "aPT"     "C-PC"    "dM-FIB"  "DTL1"    "EC-GC"   "T"      
[12] "dM-TAL"  "dM-PC"   "IMCD"    "M-TAL"   "aTAL1"   "C-IC-A"  "dPT"     "M-IC-A"  "M-PC"    "POD"     "PT-S3"  
[23] "IC-B"    "dPT-DTL" "MD"      "VSMC-P"  "EC-AVR"  "DCT"     "CNT"     "dATL"    "B"       "MDC"     "MYOF"   
[34] "dC-TAL"  "dFIB"    "DTL2"    "VSMC"    "PL"      "aTAL2"   "dC-IC-A" "tPC-IC"  "M-FIB"   "PEC"     "FIB"    
[45] "dPOD"    "aFIB"    "ATL"     "PT-S2"   "PapE"    "EC-LYM"  "dVSMC"   "MC"      "EC-AEA"  "dIMCD"   "DTL3"   
[56] "dCNT"    "cycEC"   "dDCT"    "NKT"     "dDTL3"   "dEC-PTC" "dEC"     "cycPT"   "N"       "SC-NEU"  "ncMON"  
[67] "cycCNT"  "pDC"     "MAST"    "cycDCT"  "cycMNP"  "REN"     "cDC"    
> CARD_object <- CARD_obj
> ct.select = CARD_object@info_parameters$ct.select
> print(ct.select)
 [1] "EC-PTC"  "C-TAL"   "MAC-M2"  "PT-S1"   "EC-DVR"  "aPT"     "C-PC"    "dM-FIB"  "DTL1"    "EC-GC"   "T"      
[12] "dM-TAL"  "dM-PC"   "IMCD"    "M-TAL"   "aTAL1"   "C-IC-A"  "dPT"     "M-IC-A"  "M-PC"    "POD"     "PT-S3"  
[23] "IC-B"    "dPT-DTL" "MD"      "VSMC-P"  "EC-AVR"  "DCT"     "CNT"     "dATL"    "B"       "MDC"     "MYOF"   
[34] "dC-TAL"  "dFIB"    "DTL2"    "VSMC"    "PL"      "aTAL2"   "dC-IC-A" "tPC-IC"  "M-FIB"   "PEC"     "FIB"    
[45] "dPOD"    "aFIB"    "ATL"     "PT-S2"   "PapE"    "EC-LYM"  "dVSMC"   "MC"      "EC-AEA"  "dIMCD"   "DTL3"   
[56] "dCNT"    "cycEC"   "dDCT"    "NKT"     "dDTL3"   "dEC-PTC" "dEC"     "cycPT"   "N"       "SC-NEU"  "ncMON"  
[67] "cycCNT"  "pDC"     "MAST"    "cycDCT"  "cycMNP"  "REN"     "cDC"    
> ct.varname = CARD_object@info_parameters$ct.varname
> sample.varname = CARD_object@info_parameters$sample.varname 
> sc_eset = CARD_object@sc_eset
> print(unique(colData(sc_eset)[,ct.varname])) ### check if there are NA in your sc_eset 
 [1] "EC-PTC"  "C-TAL"   "MAC-M2"  "PT-S1"   "EC-DVR"  "aPT"     "C-PC"    "dM-FIB"  "DTL1"    "EC-GC"   "T"      
[12] "dM-TAL"  "dM-PC"   "IMCD"    "M-TAL"   "aTAL1"   "C-IC-A"  "dPT"     "M-IC-A"  "M-PC"    "POD"     "PT-S3"  
[23] "IC-B"    "dPT-DTL" "MD"      "VSMC-P"  "EC-AVR"  "DCT"     "CNT"     "dATL"    "B"       "MDC"     "MYOF"   
[34] "dC-TAL"  "dFIB"    "DTL2"    "VSMC"    "PL"      "aTAL2"   "dC-IC-A" "tPC-IC"  "M-FIB"   "PEC"     "FIB"    
[45] "dPOD"    "aFIB"    "ATL"     "PT-S2"   "PapE"    "EC-LYM"  "dVSMC"   "MC"      "EC-AEA"  "dIMCD"   "DTL3"   
[56] "dCNT"    "cycEC"   "dDCT"    "NKT"     "dDTL3"   "dEC-PTC" "dEC"     "cycPT"   "N"       "SC-NEU"  "ncMON"  
[67] "cycCNT"  "pDC"     "MAST"    "cycDCT"  "cycMNP"  "REN"     "cDC"    
> Basis_ref = createscRef(sc_eset, ct.select, ct.varname, sample.varname)
> Basis = Basis_ref$basis
> print(colnames(Basis)) ##### check the column names of the matrix to see if it matched with ct.select
 [1] "EC-PTC"  "C-TAL"   "MAC-M2"  "PT-S1"   "EC-DVR"  "aPT"     "C-PC"    "dM-FIB"  "DTL1"    "EC-GC"   "T"      
[12] "dM-TAL"  "dM-PC"   "IMCD"    "M-TAL"   "aTAL1"   "C-IC-A"  "dPT"     "M-IC-A"  "M-PC"    "POD"     "PT-S3"  
[23] "IC-B"    "dPT-DTL" "MD"      "VSMC-P"  "EC-AVR"  "DCT"     "CNT"     "dATL"    "B"       "MDC"     "MYOF"   
[34] "dC-TAL"  "dFIB"    "DTL2"    "VSMC"    "PL"      "aTAL2"   "dC-IC-A" "tPC-IC"  "M-FIB"   "PEC"     "FIB"    
[45] "dPOD"    "aFIB"    "ATL"     "PT-S2"   "PapE"    "EC-LYM"  "dVSMC"   "MC"      "EC-AEA"  "dIMCD"   "DTL3"   
[56] "dCNT"    "cycEC"   "dDCT"    "NKT"     "dDTL3"   "dEC-PTC" "dEC"     "cycPT"   "N"       "SC-NEU"  "ncMON"  
[67] "cycCNT"  "pDC"     "MAST"    "cycDCT"  "cycMNP"  "REN"     "cDC"    
> Basis = Basis[,colnames(Basis) %in% ct.select]
> Basis = Basis[,match(ct.select,colnames(Basis))]
> print(head(Basis))
              EC-PTC       C-TAL     MAC-M2       PT-S1     EC-DVR         aPT        C-PC    dM-FIB       DTL1
A1BG     0.000000000 0.000000000 0.00000000 0.000000000 0.25463146 0.002387295 0.005932253 0.0000000 0.00000000
A1BG-AS1 0.003740591 0.002511485 0.01126066 0.000000000 0.00000000 0.000000000 0.000000000 0.0000000 0.02095882
A1CF     0.000000000 0.174133705 0.00000000 0.269342701 0.02035328 0.406850594 0.000000000 0.0000000 0.02869956
A2M      0.648263433 0.079812301 0.26262589 0.080127538 2.91261233 0.024777035 0.000000000 0.2639489 0.06297961
A2M-AS1  0.000000000 0.028365908 0.00000000 0.000000000 0.00000000 0.003086297 0.062850349 0.0000000 0.00000000
A2ML1    0.000000000 0.006828321 0.00000000 0.005611257 0.00000000 0.002820775 0.000000000 0.0000000 0.00000000
             EC-GC          T      dM-TAL       dM-PC       IMCD      M-TAL       aTAL1     C-IC-A          dPT
A1BG     0.0000000 0.00000000 0.002337973 0.000000000 0.08357750 0.00360073 0.079464019 0.00000000 0.0000000000
A1BG-AS1 0.0000000 0.04590476 0.000000000 0.024124371 0.02145274 0.00000000 0.000000000 0.00000000 0.0202197439
A1CF     0.0000000 0.00000000 0.014244650 0.000000000 0.00000000 0.01169403 0.031899302 0.02318748 0.2267581534
A2M      0.3679104 0.47299705 0.036304238 0.113595174 0.01769903 0.03177766 0.113867425 0.02624066 0.0354575414
A2M-AS1  0.0000000 0.00000000 0.000000000 0.000000000 0.00000000 0.00000000 0.000000000 0.00000000 0.0002489599
A2ML1    0.0000000 0.00000000 0.000000000 0.004124833 0.00000000 0.02370139 0.007108579 0.00000000 0.0158324948
              M-IC-A       M-PC        POD       PT-S3       IC-B    dPT-DTL         MD      VSMC-P    EC-AVR
A1BG     0.017870123 0.00000000 0.01198843 0.002294264 0.00000000 0.00000000 0.00000000 0.095516044 0.0000000
A1BG-AS1 0.000000000 0.00000000 0.03483828 0.000000000 0.00000000 0.00000000 0.06855951 0.003298152 0.0000000
A1CF     0.000000000 0.00000000 0.05342523 0.315413004 0.01403608 0.49622760 0.01935754 0.000000000 0.0000000
A2M      0.006441087 0.03427977 0.31885107 0.029490512 0.02142450 0.01506387 0.00000000 0.526198616 0.9006502
A2M-AS1  0.000000000 0.00000000 0.00000000 0.000000000 0.00000000 0.00000000 0.00000000 0.000000000 0.0000000
A2ML1    0.000000000 0.02941184 0.00000000 0.000000000 0.00000000 0.00000000 0.00000000 0.003298152 0.0000000
                 DCT         CNT       dATL          B       MDC       MYOF      dC-TAL     dFIB       DTL2       VSMC
A1BG     0.002962689 0.037786343 0.14833319 0.00000000 0.0000000 0.00000000 0.008788317 0.000000 0.00000000 0.00000000
A1BG-AS1 0.000000000 0.017507425 0.07128283 0.00000000 0.0000000 0.00000000 0.000000000 0.000000 0.03185492 0.04624312
A1CF     0.022084138 0.005668575 0.00000000 0.00000000 0.0142038 0.03008573 0.000000000 0.000000 0.06774153 0.04624312
A2M      0.028794656 0.018147334 0.00000000 0.00000000 0.2083162 0.54463362 0.131902295 4.234205 0.31783259 0.72263971
A2M-AS1  0.008892006 0.008770292 0.00000000 0.00000000 0.0000000 0.00000000 0.000000000 0.000000 0.00000000 0.04624312
A2ML1    0.000000000 0.000000000 0.00000000 0.01104408 0.0000000 0.00000000 0.000000000 0.000000 0.00000000 0.00000000
                PL      aTAL2    dC-IC-A   tPC-IC       M-FIB        PEC        FIB dPOD       aFIB       ATL
A1BG     0.0000000 0.00000000 0.00000000 1.140661 0.021492233 0.02753930 0.00000000    0 0.00000000 0.0000000
A1BG-AS1 0.0000000 0.00000000 0.00000000 0.000000 0.034637298 0.00000000 0.01308623    0 0.00000000 0.0000000
A1CF     0.0000000 0.00000000 0.49314159 0.000000 0.000000000 0.00000000 0.01397983    0 0.03873773 0.0000000
A2M      0.1004598 0.05761169 0.04269647 0.000000 4.127738477 0.00455573 1.18997067    0 0.90354573 0.1242609
A2M-AS1  0.0000000 0.02097630 0.00000000 0.000000 0.008934893 0.00000000 0.00000000    0 0.00000000 0.0000000
A2ML1    0.1004598 0.00000000 0.00000000 0.000000 0.001481529 0.00000000 0.00000000    0 0.00000000 0.0000000
              PT-S2      PapE    EC-LYM     dVSMC        MC   EC-AEA      dIMCD       DTL3      dCNT     cycEC
A1BG     0.01089144 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.06676868 0.12945572 0.0000000 0.0000000
A1BG-AS1 0.01198492 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.00000000 0.04063035 0.0440070 0.0000000
A1CF     0.44469562 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.00000000 0.00000000 0.0000000 0.0000000
A2M      0.05764818 0.3333333 0.3407352 0.1283216 0.9752014 2.120005 0.06375269 0.17620954 0.1582867 0.5863352
A2M-AS1  0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.00000000 0.08700691 0.0000000 0.0000000
A2ML1    0.00000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.00000000 0.00000000 0.0676412 0.0000000
              dDCT       NKT      dDTL3 dEC-PTC       dEC      cycPT N SC-NEU      ncMON cycCNT pDC MAST cycDCT cycMNP
A1BG     0.0000000 0.0000000 0.05414412       0 0.0000000 0.00000000 0      0 0.00000000      0   0    0      0      0
A1BG-AS1 0.0000000 0.0000000 0.00000000       0 0.0000000 0.00000000 0      0 0.00000000      0   0    0      0      0
A1CF     0.0000000 0.0000000 0.00000000       0 0.0000000 0.48134502 0      0 0.00000000      0   0    0      0      0
A2M      0.2773698 0.5144594 0.05414412       0 0.6116508 0.05015412 0      0 0.05981637      0   0    0      0      0
A2M-AS1  0.0000000 0.2128414 0.05414412       0 0.0000000 0.00000000 0      0 0.10347680      0   0    0      0      0
A2ML1    0.0000000 0.0000000 0.00000000       0 0.0000000 0.00000000 0      0 0.00000000      0   0    0      0      0
         REN cDC
A1BG       0   0
A1BG-AS1   0   0
A1CF       0   0
A2M        0   0
A2M-AS1    0   0
A2ML1      0   0
> spatial_count = CARD_object@spatial_countMat
> commonGene = intersect(rownames(spatial_count),rownames(Basis))
> print(head(commonGene)) ##### check how many common genes in spatial and single cell count
[1] "AL627309.1" "AL669831.5" "LINC00115"  "FAM41C"     "AL645608.1" "SAMD11"

How could I proceed with the analysis?

Thanks!

YingMa0107 commented 2 years ago

Hi @rimelof,

could you please check the number of common genes and also run the following script to see if it can run?

print(length(commonGene))
genes = c()
for(ict in ct.select){
print(ict)
rest = rowMeans(Basis[,colnames(Basis) != ict])
FC = log((Basis[,ict] + 1e-06)) - log((rest + 1e-06))
tmp = rownames(Basis)[FC > 1.25 & Basis[,ict] > 0]
print(length(tmp))
genes = c(genes,tmp)
}
genes  = unique(genes)
genes1 = intersect(genes,commonGene)
print(length(commonGene))

As your current output looks normal to me, so I can not figure out where the error comes from. Please run the above code! Hope we can find out where the error comes from.

Thank you!

Best, Ying

rimelof commented 2 years ago

Hi @YingMa0107,

Thank you for the prompt response!

Here is the output: `

print(length(commonGene)) [1] 17132 genes = c() for(ict in ct.select){

  • print(ict)
  • rest = rowMeans(Basis[,colnames(Basis) != ict])
  • FC = log((Basis[,ict] + 1e-06)) - log((rest + 1e-06))
  • tmp = rownames(Basis)[FC > 1.25 & Basis[,ict] > 0]
  • print(length(tmp))
  • genes = c(genes,tmp)
  • } [1] "EC-PTC" [1] 859 [1] "C-TAL" [1] 1896 [1] "MAC-M2" [1] 657 [1] "PT-S1" [1] 1001 [1] "EC-DVR" [1] 1381 [1] "aPT" [1] 2246 [1] "C-PC" [1] 946 [1] "dM-FIB" [1] 292 [1] "DTL1" [1] 1483 [1] "EC-GC" [1] 728 [1] "T" [1] 736 [1] "dM-TAL" [1] 1103 [1] "dM-PC" [1] 2356 [1] "IMCD" [1] 4150 [1] "M-TAL" [1] 2174 [1] "aTAL1" [1] 1941 [1] "C-IC-A" [1] 1728 [1] "dPT" [1] 1216 [1] "M-IC-A" [1] 2020 [1] "M-PC" [1] 2669 [1] "POD" [1] 1463 [1] "PT-S3" [1] 1313 [1] "IC-B" [1] 1072 [1] "dPT-DTL" [1] 1330 [1] "MD" [1] 1247 [1] "VSMC-P" [1] 775 [1] "EC-AVR" [1] 1108 [1] "DCT" [1] 1476 [1] "CNT" [1] 1520 [1] "dATL" [1] 3064 [1] "B" [1] 873 [1] "MDC" [1] 961 [1] "MYOF" [1] 1134 [1] "dC-TAL" [1] 363 [1] "dFIB" [1] 708 [1] "DTL2" [1] 1485 [1] "VSMC" [1] 1261 [1] "PL" [1] 863 [1] "aTAL2" [1] 3380 [1] "dC-IC-A" [1] 1483 [1] "tPC-IC" [1] 4112 [1] "M-FIB" [1] 1577 [1] "PEC" [1] 948 [1] "FIB" [1] 809 [1] "dPOD" [1] 409 [1] "aFIB" [1] 1769 [1] "ATL" [1] 1959 [1] "PT-S2" [1] 1600 [1] "PapE" [1] 1365 [1] "EC-LYM" [1] 1431 [1] "dVSMC" [1] 216 [1] "MC" [1] 604 [1] "EC-AEA" [1] 1764 [1] "dIMCD" [1] 4499 [1] "DTL3" [1] 2666 [1] "dCNT" [1] 2162 [1] "cycEC" [1] 1557 [1] "dDCT" [1] 1971 [1] "NKT" [1] 946 [1] "dDTL3" [1] 2028 [1] "dEC-PTC" [1] 1716 [1] "dEC" [1] 476 [1] "cycPT" [1] 1421 [1] "N" [1] 367 [1] "SC-NEU" [1] 194 [1] "ncMON" [1] 974 [1] "cycCNT" [1] 3823 [1] "pDC" [1] 467 [1] "MAST" [1] 430 [1] "cycDCT" [1] 2228 [1] "cycMNP" [1] 278 [1] "REN" [1] 533 [1] "cDC" [1] 1604 genes = unique(genes) genes1 = intersect(genes,commonGene) print(length(commonGene)) [1] 17132 `

Thank you, Ricardo

YingMa0107 commented 2 years ago

Hi @rimelof,

Thank you for providing these output! All current output seems normal to me. I think the problem might come from the input scRNASeq data containing cell types with only 1 cell or very small number of cells. Since you have 70+ cell types, it might be the situation that some cell types has only one cell. Could you please check the number for each cell type by print(table(sc_meta$cellType,useNA = "ifany"))

I also updated the code to make it run when there is only one cell for some cell type. But I suggest you to filter out those cell types with < 5 cells in your initial scRNAseq data. Let me know if it does not work!

Best, Ying

rimelof commented 2 years ago

Hi @YingMa0107,

That was it! I was using a subset of my dataset to test the package before running with the whole sample and didn't realize there were groups with too little cells.

Thank you!

juliaryann commented 2 years ago

Hi @YingMa0107 , Thank you so much for your help (and your patience!!). I was using normalized data for sc_count and I was not aware raw count data was needed. Best, Julia

honghh2018 commented 11 months ago

Hi developer, i get the same error, and i look above solution, but i wasn't still find out where the error come from,

R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS: /share/apps/R/R-4.1.2-4/lib64/R/lib/libRblas.so LAPACK: /share/apps/R/R-4.1.2-4/lib64/R/lib/libRlapack.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C
[5] LC_MONETARY=C LC_MESSAGES=C LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C

attached base packages: [1] stats4 stats graphics grDevices utils datasets methods base

other attached packages: [1] wrMisc_1.12.0 MuSiC_1.0.0 TOAST_1.12.0
[4] quadprog_1.5-8 limma_3.50.3 EpiDISH_2.10.0
[7] nnls_1.4 data.table_1.14.2 DropletUtils_1.14.2
[10] SingleCellExperiment_1.16.0 SummarizedExperiment_1.24.0 GenomicRanges_1.46.1
[13] GenomeInfoDb_1.30.1 IRanges_2.28.0 S4Vectors_0.32.4
[16] MatrixGenerics_1.6.0 matrixStats_0.62.0 plyr_1.8.7
[19] dplyr_1.0.9 CARD_1.0 Biobase_2.54.0
[22] BiocGenerics_0.40.0 scRepertoire_2.0.0 ggplot2_3.4.4
[25] SeuratObject_4.1.3 Seurat_4.3.0 hdf5r_1.3.8

the check info Slot "project": [1] "Deconvolution"

Slot "info_parameters": $ct.varname [1] "cellType"

$ct.select [1] "B_cells" "CD4+_T_cells" "CD8+_T_cells" "Endothelial_cells" "Epithelial_cells" [6] "Fibroblast_cells" "Macrophage" "Mast_cells" "SMC" "cDC"

$sample.varname [1] "sampleInfo"

Slot "algorithm_matrix": list()

Slot "refined_prop": <0 x 0 matrix>

Slot "refined_expression": <0 x 0 matrix>

spatial_count = CARD_obj@spatial_countMat spatial_count 0 x 0 sparse Matrix of class "dgCMatrix" <0 x 0 matrix> spatial_count = CARD_obj@spatial_countMat spatial_count 0 x 0 sparse Matrix of class "dgCMatrix" <0 x 0 matrix> spatial_count 0 x 0 sparse Matrix of class "dgCMatrix" <0 x 0 matrix> spatial_count<-D1@assays$Spatial@counts spatial_count 18660 x 5 sparse Matrix of class "dgCMatrix" NTT-1_AGGGAGACATACTTCG-1 NTT-1_CCGGCGTGAGACTCTG-1 NTT-1_GACACGAGTTAGAGGA-1 SAMD11 . . . NOC2L . . . KLHL17 . . . PLEKHN1 . . . PERM1 . . . HES4 . . . ISG15 . . . AGRN . . . RNF223 . . . C1orf159 . 1 . TTLL10 . . . TNFRSF18 . . . TNFRSF4 . . . SDF4 1 . 1 B3GALT6 . . . C1QTNF12 . . . UBE2J2 . . . SCNN1D . . . ACAP3 . . . PUSL1 . . . INTS11 . 1 . CPTP . . . TAS1R3 . . . DVL1 . . 1 MXRA8 . . . AURKAIP1 . 2 . CCNL2 . 1 . ANKRD65 . . . TMEM88B . . . VWA1 . . . ATAD3C . . . ATAD3B . . . ATAD3A . . . TMEM240 . . . SSU72 . . . FNDC10 . . . MIB2 . 1 . MMP23B . . . CDK11B . . . CDK11A . . . NADK . . . GNB1 . 1 . CALML6 . . . TMEM52 . . . CFAP74 . . . GABRD . . . PRKCZ 1 . . FAAP20 . . . SKI . . 1 RER1 . . . PEX10 . . . PLCH2 . . . PANK4 . . . HES5 . . . TNFRSF14 . . . PRXL2B 1 . . MMEL1 . . . ACTRT2 . . . PRDM16 . . . ARHGEF16 . . 1 MEGF6 . 1 . TPRG1L . . . WRAP73 . . . TP73 . . . CCDC27 . . . SMIM1 . . . LRRC47 . . . CEP104 . . . DFFB . . . C1orf174 . . . AJAP1 . . . NPHP4 . . . KCNAB2 . . . CHD5 . . . RNF207 . . . ICMT . . . GPR153 . . . ACOT7 . . . HES2 . . . ESPN . . . TNFRSF25 . . . PLEKHG5 . . . NOL9 . . . TAS1R1 1 . . ZBTB48 . . . KLHL21 . . . PHF13 . . . THAP3 . . . DNAJC11 . . . CAMTA1 . . . VAMP3 . . . PER3 . . . UTS2 . . . TNFRSF9 . . . ERRFI1 . . . SLC45A1 . . . RERE . 1 . ENO1 . 1 . CA6 . . . SLC2A7 . . . NTT-1_GATATTTCCTACATGG-1 NTT-1_TCATCACTCGAGCTCG-1 SAMD11 . . NOC2L . . KLHL17 . . PLEKHN1 . . PERM1 . . HES4 . . ISG15 . . AGRN . . RNF223 . . C1orf159 . . TTLL10 . . TNFRSF18 . . TNFRSF4 . . SDF4 . . B3GALT6 . . C1QTNF12 . . UBE2J2 . . SCNN1D . . ACAP3 . . PUSL1 . . INTS11 . 1 CPTP . . TAS1R3 . . DVL1 . . MXRA8 . . AURKAIP1 1 1 CCNL2 . 1 ANKRD65 . . TMEM88B . . VWA1 . . ATAD3C . . ATAD3B . . ATAD3A . . TMEM240 . . SSU72 . . FNDC10 . . MIB2 . . MMP23B . . CDK11B . . CDK11A . . NADK . . GNB1 . 1 CALML6 . . TMEM52 . . CFAP74 . . GABRD . . PRKCZ . . FAAP20 . . SKI . . RER1 . . PEX10 . . PLCH2 . . PANK4 . . HES5 . . TNFRSF14 . . PRXL2B . . MMEL1 . . ACTRT2 . . PRDM16 . . ARHGEF16 . . MEGF6 . . TPRG1L . . WRAP73 . . TP73 . . CCDC27 . . SMIM1 . . LRRC47 . . CEP104 . . DFFB . . C1orf174 . . AJAP1 . . NPHP4 . . KCNAB2 . . CHD5 . . RNF207 . . ICMT . . GPR153 . . ACOT7 . . HES2 . . ESPN . . TNFRSF25 . . PLEKHG5 . . NOL9 . 1 TAS1R1 . . ZBTB48 . . KLHL21 . . PHF13 . . THAP3 . . DNAJC11 . . CAMTA1 . . VAMP3 . . PER3 . . UTS2 . . TNFRSF9 . . ERRFI1 . . SLC45A1 . . RERE . . ENO1 1 . CA6 . . SLC2A7 . .

.............................. ........suppressing 18460 rows in show(); maybe adjust 'options(max.print= , width = )' .............................. NTT-1_AGGGAGACATACTTCG-1 NTT-1_CCGGCGTGAGACTCTG-1 NTT-1_GACACGAGTTAGAGGA-1 EFCAB5 . . . ZNHIT3 . 1 . KRTAP2-1 . . . KRTAP2-2 . . . KRTAP4-7 . . . KRTAP4-8 . . . KRTAP9-4 . . . HCRT . . . ARL17B . . . ARL17A . . . RGS9 . . . AC015802.6 . . . AFMID . . . FSCN2 . . . UTS2R . . . ABHD17A . . . APBA3 . . . ZNF846 . . . EPOR . . . ZNF443 . . . CACNA1A . . . MISP3 . . . REX1BD . . . ZNF208 . . . MAG . . . GPR42 . . . PSMD8 . . . EIF3K . 1 1 CARD8 . . . NTN5 . . . FUT2 1 . . CGB7 . . . PNKP . . . CEACAM18 . . . ZNF615 . . . ZNF616 . . . ZNF528 . . . ZNF845 . . . ZNF761 . . . LILRB3 . . . ZNF865 . . . ZNF749 . . . ZNF551 . . . ZNF814 . . . A1BG . . . RNF225 . . . FKBP1A . . . PROKR2 . . . CST1 . 1 . C20orf203 . . . CNBD2 . . . MROH8 . . . SRSF6 . . . MATN4 . . . SPATA25 . . . BCAS1 . . . FAM209A . . . MTRNR2L3 . . . GNAS 1 1 . CBSL . . . KRTAP21-3 . . . C21orf62 . . . PWP2 . . . PFKL . . 1 KRTAP10-6 . . . OR11H1 . . . DGCR6 . . . DGCR6L . . . IGLV4-60 . . . IGLV6-57 . . . IGLV9-49 . . . IGLV2-33 . . . IGLV3-32 . . . IGLV3-22 . . . IGLV3-1 . . . IGLJ1 . . . IGLJ5 . . . IGLJ6 . . . DNAJB7 . . . ACR . . . MSL3 . . . TRAPPC2 . . . GK . . . GPR82 . . . ZNF81 . . . SPACA5 . . . FAM156A . . . PAGE2B . . . MTRNR2L10 . . . PAGE5 . . . P2RY4 . . . PABPC1L2B . . . SATL1 . . . ARMCX5-GPRASP2 . . . RAB40AL . . . CXorf40B . . . GPR50 . . . CSAG3 . . . PLXNB3 . . . TEX28 . . . NTT-1_GATATTTCCTACATGG-1 NTT-1_TCATCACTCGAGCTCG-1 EFCAB5 . . ZNHIT3 . . KRTAP2-1 . . KRTAP2-2 . . KRTAP4-7 . . KRTAP4-8 . . KRTAP9-4 . . HCRT . . ARL17B . . ARL17A . . RGS9 . . AC015802.6 . . AFMID . . FSCN2 . . UTS2R . . ABHD17A . . APBA3 . . ZNF846 . . EPOR . . ZNF443 . . CACNA1A . . MISP3 . . REX1BD . . ZNF208 . . MAG . . GPR42 . . PSMD8 . . EIF3K . . CARD8 . 1 NTN5 . . FUT2 . . CGB7 . . PNKP . . CEACAM18 . . ZNF615 . . ZNF616 . . ZNF528 . . ZNF845 . . ZNF761 . . LILRB3 . . ZNF865 . . ZNF749 . . ZNF551 . . ZNF814 . . A1BG . . RNF225 . . FKBP1A 1 . PROKR2 . . CST1 . . C20orf203 . . CNBD2 . . MROH8 . . SRSF6 . . MATN4 . . SPATA25 . . BCAS1 . . FAM209A . . MTRNR2L3 . . GNAS . 1 CBSL . . KRTAP21-3 . . C21orf62 . . PWP2 . . PFKL . . KRTAP10-6 . . OR11H1 . . DGCR6 . . DGCR6L . . IGLV4-60 . . IGLV6-57 . . IGLV9-49 . . IGLV2-33 . . IGLV3-32 . . IGLV3-22 . . IGLV3-1 . . IGLJ1 . . IGLJ5 . . IGLJ6 . . DNAJB7 . . ACR . . MSL3 . . TRAPPC2 . . GK . . GPR82 . . ZNF81 . . SPACA5 . . FAM156A . . PAGE2B . . MTRNR2L10 . . PAGE5 . . P2RY4 . . PABPC1L2B . . SATL1 . . ARMCX5-GPRASP2 . . RAB40AL . . CXorf40B . . GPR50 . . CSAG3 . . PLXNB3 . . TEX28 . .

CARD_obj = createCARDObject(

  • sc_count = sc_count,
  • sc_meta = sc_meta,
  • spatial_count = spatial_count,
  • spatial_location = spatial_location,
  • ct.varname = "cellType",
  • ct.select = levels(sc_meta$cellType),
  • sample.varname = "sampleInfo",
  • minCountGene = 100,
  • minCountSpot = 5)

    QC on scRNASeq dataset! ...

    QC on spatially-resolved dataset! ...

    commonGene = intersect(rownames(spatial_count),rownames(Basis)) print(head(commonGene)) [1] "SAMD11" "NOC2L" "KLHL17" "PLEKHN1" "PERM1" "HES4"
    genes = c() for(ict in ct.select){

  • print(ict)
  • rest = rowMeans(Basis[,colnames(Basis) != ict])
  • FC = log((Basis[,ict] + 1e-06)) - log((rest + 1e-06))
  • tmp = rownames(Basis)[FC > 1.25 & Basis[,ict] > 0]
  • print(length(tmp))
  • genes = c(genes,tmp)
  • } [1] "B_cells" [1] 1359 [1] "CD4+_T_cells" [1] 549 [1] "CD8+_T_cells" [1] 564 [1] "Endothelial_cells" [1] 2835 [1] "Epithelial_cells" [1] 11696 [1] "Fibroblast_cells" [1] 3945 [1] "Macrophage" [1] 1191 [1] "Mast_cells" [1] 314 [1] "SMC" [1] 2247 [1] "cDC" [1] 1591 genes = unique(genes) genes1 = intersect(genes,commonGene) print(length(commonGene)) [1] 16844 commonGene [1] "SAMD11" "NOC2L" "KLHL17" "PLEKHN1" "PERM1" "HES4" "ISG15"
    [8] "AGRN" "RNF223" "C1orf159" "TTLL10" "TNFRSF18" "TNFRSF4" "SDF4"
honghh2018 commented 11 months ago

i found the reason on this issue that the minCountGene or minCountSpot occure this error

isaamael commented 2 months ago

Hi @honghh2018

i found the reason on this issue that the minCountGene or minCountSpot occure this error

I would like to understand your problem and the logic behind your solution. I have tried some of the checks mentioned in the issue, but I still don't have a clear direction.

Thank you in advance