navinlabcode / CellTrek

95 stars 18 forks source link

Error in CellTrek::celltrek step #2

Closed RENXI-NUS closed 2 years ago

RENXI-NUS commented 2 years ago

Hi,

I encountered the following error at the CellTrek::celltrek step following your tutorial.

> ## Chart single cells to their spatial locations
> visium_scRNAseq_celltrek <- CellTrek::celltrek(st_sc_int=visium_traint, int_assay='traint', sc_data=s_df, sc_assay = 'RNA', reduction='pca', intp=T, intp_pnt=5000, intp_lin=F, nPCs=30, ntree=1000,  dist_thresh=0.55, top_spot=5, spot_n=5, repel_r=20, repel_iter=20, keep_model=F)
Distance between spots is: 216 
Interpolating...
Random Forest training... 
Random Forest prediction...  
Making distance matrix... 
Making graph... 
Pruning graph...
Joining, by = c("Var1", "Var2", "value", "val_rsc", "Var1_type", "Var2_type")
Spatial Charting SC data...
Repelling points...
Creating Seurat Object... 
sc data...Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : 
  invalid character indexing

Any ideas how to solve it? Thank you.

smorabit commented 2 years ago

Just chiming in to say that I am getting the exact same error on using celltrek on my own data.

WandeRum commented 2 years ago

Hi, could you please try 1. check if any cell and ST ids are duplicated; 2. not to feed with sc_data? I have met similar issues which were caused by the cell id issues. I am happy to check if you can provide the data.

smorabit commented 2 years ago

None of the ids were duplicated in my single-cell or ST datasets. As you suggested I tried to run CellTrek::celltrek without using sc_data, and it did finish running. However, the resulting object does not seem to contain all of the original input cells. The single-cell dataset that I used for CellTrek::traint had 16,728 cells while the resulting seurat object from CellTrek::celltrek has 13,604 cells. Do you have any explanation as to why there are missing cells? I am guessing celltrek could not confidently predict them or something.

WandeRum commented 2 years ago

As I checked some of our previous test data, we did find some syntactically invalid names which will lead to this problem. Renaming the object before the analysis is helpful (we added it to the tutorial). For the question, yes, not all cells can be mapped. It depends on the spatial resolution and MNN graph at the last step. U can probably change the parameters to get more or fewer cells. One thing is that a small amount of redundant cell charting is also allowable with the default parameters (depending on the MNN parameters) since we considered that in many ST slides, different regions could also have similar cells.

RENXI-NUS commented 2 years ago

Problem has solved. Thank you!!