得到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")
# 转成长数据格式;
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)
#蓝
mycol3=colorRampPalette(c("#00abef","#64b036","#ffe743","#64b036","#00abef"))(36)
我发现最近总忘记写简书