2022-10-09 ?;鶊D

得到VJ的table后,用前兩列和count或者freq(最好freq),分別作為"TCR1", "TCR2","value"

library(networkD3)#載入包
setwd("C:\\Users\\Administrator\\Desktop\\table\\VDJ")
network<-read.csv("VJ2.freq.csv",header=TRUE,stringsAsFactors = TRUE)
colnames(network) <- c("TCR1", "TCR2","value")
#------------------------
library(ggalluvial)
setwd("C:\\Users\\Administrator\\Desktop\\table\\VDJ")
df<-read.csv("VJ2.freq.csv",header=TRUE)
is_alluvia_form(df,weight ="freq")
# 轉(zhuǎn)成長數(shù)據(jù)格式;
df_lodes <- to_lodes_form(df,key ="x", value = "stratum", id = "alluvium",axes =1:2)
head(df_lodes,12)
is_lodes_form(df_lodes,key = "x",value = "stratum",id = "alluvium",weight ="freq")
mycol3=colorRampPalette(c("#D8BFD8","#FFE4E1","#FFF68F","#EEE8AA","#FFC1C1","#F5DEB3","#DB7093"))(36)

ggplot(df_lodes,aes(x = x, stratum =stratum, alluvium = alluvium,
                    fill = stratum, label = stratum)) +
  scale_x_discrete(expand = c(0, 0)) +
  geom_flow(width = 1/5, knot.pos = 0.1) +
  geom_stratum(alpha = .9,color="grey80",width = 2/10) +  #width:只能1/2
  geom_text(stat = "stratum", size =2.5,color="black") +
  scale_fill_manual(values = mycol3) +
  xlab("") + ylab("") +
  theme_bw() +
  theme(panel.grid =element_blank()) +
  theme(panel.border = element_blank()) +
  theme(axis.line = element_blank(),axis.ticks =element_blank(),axis.text.y =element_blank())+
  guides(fill = FALSE)

#藍(lán)
mycol3=colorRampPalette(c("#00abef","#64b036","#ffe743","#64b036","#00abef"))(36)

我發(fā)現(xiàn)最近總忘記寫簡書

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容