今天在跑CellChat的時(shí)候,出現(xiàn)了一個(gè)問(wèn)題"Error in
levels<-
(*tmp*
, value = as.character(levels)) : factor level [2] is duplicated", 寫(xiě)個(gè)教程記錄下解決辦法坝疼。
1. 問(wèn)題
我看了下在跑到LT通路的時(shí)候搜贤,發(fā)現(xiàn)報(bào)錯(cuò)了,看了下跑出來(lái)的結(jié)果钝凶,發(fā)現(xiàn)LT通路中顯著的配體受體對(duì)是重復(fù)的仪芒。這個(gè)重復(fù)的話只能是zebrafish的配體受體對(duì)庫(kù)中有重復(fù)了
2.解決
(1) check zebrafish 配體受體對(duì)庫(kù)
CellChatDB <- CellChatDB.zebrafish # use CellChatDB.mouse if running on mouse data
showDatabaseCategory(CellChatDB)
dplyr::glimpse(CellChatDB$interaction)
# use a subset of CellChatDB for cell-cell communication analysis
CellChatDB.use <- subsetDB(CellChatDB, search = "Secreted Signaling") # use Secreted Signaling
(2) 刪除配體受體庫(kù)中其他重復(fù)的配體受體對(duì)
new_interaction <- NULL
all_pathway_name <- unique(CellChatDB.use$interaction$pathway_name)
lrnum <- matrix(0, length(all_pathway_name), 4)
for (i in seq_along(all_pathway_name)){
print(all_pathway_name[i])
temp <- dplyr::filter(CellChatDB.use$interaction, pathway_name == all_pathway_name[i])
lrnum[i, c(1, 2)] <- dim(temp)
temp <- temp %>% distinct(interaction_name_2, .keep_all = TRUE)
lrnum[i, c(3, 4)] <- dim(temp)
new_interaction <- rbind(new_interaction, temp)
}
rownames(lrnum) <- all_pathway_name
開(kāi)心!8荨5嗝!哟沫!