OscarGVelasco / ClusterFoldSimilarity

Calculate cluster similarity between clusters from different single cell datasets/batches/samples.
MIT License
14 stars 1 forks source link

check cell types match #15

Closed jennieli421 closed 1 week ago

jennieli421 commented 2 months ago

I have followed the tutorial regarding "cell types match" and successfully got the matching result for dataset2:

type.count <- singlecell.object.list[[2]][[]] %>% 
  group_by(seurat_clusters) %>% 
  count(condition) %>% 
  arrange(desc(n), .by_group = TRUE) 

type.count.top1 <- type.count %>%
  filter(row_number()==1) 

cbind.data.frame(type.count, 
                 matched.type = rep(table(type.count$seurat_clusters), 
                                   x = similarity.table[similarity.table$datasetL == dataset2,]$clusterR) 
                 )

the resulting table is what I expected:

   seurat_clusters condition   n    matched.type
1                0       L 546    Hippo_CDD
2                0       P  42    Hippo_CDD
3                1       L 394    Hippo_CDD

However, when I try to find matches for dataset1, I encountered an error:

type.count1 <- singlecell.object.list[[1]][[]] %>% 
  group_by(seurat_clusters) %>% 
  count(condition) %>% 
  arrange(desc(n), .by_group = TRUE) 

cbind.data.frame(type.count1, 
                 matched.type = rep(table(type.count1$seurat_clusters), 
                                   x = similarity.table[similarity.table$datasetL == dataset1,]$clusterR) 
                 )  
Error in rep(table(type.count1$seurat_clusters), x = similarity.table[similarity.table$datasetL ==  : 
  invalid 'times' argument

How should I revise my code to obtain the result I want?

OscarGVelasco commented 2 months ago

Hi @jennieli421 , It seems that the problem comes from the "times" argument (the number of reps of each element of x) in the rep function, probably because some NA´s or other invalid value. Can you please check the output of "table(type.count1$seurat_clusters)" ?

OscarGVelasco commented 1 week ago

Closed due to inactivity for more than a month.