-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.family.r
executable file
·62 lines (56 loc) · 4.98 KB
/
plot.family.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#################################################
# File Name:plot2.r
# Author: xingpengwei
# Mail: [email protected]
# Created Time: Fri 12 Mar 2021 12:02:53 PM UTC
#################################################
library(ggplot2)
library(ggrepel)
library(ggpubr)
library(reshape2)
data = read.table("gene.cp.ecDNA.all.pheno",header = T)
CCNE1 = data[data$gene=="CCNE1",]
ERBB2 = data[data$gene=="ERBB2",]
EGFR = data[data$gene=="EGFR",]
row.names(CCNE1)=CCNE1$sample
row.names(ERBB2)=ERBB2$sample
row.names(EGFR)=EGFR$sample
table_egfr = data.frame(CNV=c(0,0),ecDNA=c(0,0))
row.names(table_egfr)=c("negative","positive")
table_egfr[1,]=c(length(which(EGFR$type=="CNV"&EGFR$Family_history=="negative")),length(which(EGFR$type=="ecDNA"&EGFR$Family_history=="negative")))
table_egfr[2,]=c(length(which(EGFR$type=="CNV"&EGFR$Family_history=="positive")),length(which(EGFR$type=="ecDNA"&EGFR$Family_history=="positive")))
chis_egfr = chisq.test(table_egfr)
corr1 <- paste("Chi-square test. = ", round(chis_egfr$p.value,2), sep="")
p1 = ggplot(data = EGFR)+geom_point(aes(x = log(copy_number),y=Family_history,size=year,color=type))+scale_color_manual(values=c("#666666","#FF0016"))+theme_bw()+theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),panel.background = element_blank())+theme(axis.text = element_text(color = "black"))+geom_text_repel(aes(log(copy_number),Family_history,label=rownames(EGFR)),max.overlaps = 30)+geom_text(aes(3,"negative",label=corr1))
table_egfr$Family_history=c("negative","positive")
table_egfr_bar = melt(table_egfr,id.vars = "Family_history")
table_egfr_bar$variable=factor(table_egfr_bar$variable,levels=c("ecDNA","CNV"))
p1_bar = ggplot(data=table_egfr_bar)+geom_bar(aes(x=Family_history,y=value,fill=variable),stat="identity")+theme_bw()+scale_y_continuous(expand = c(0,0))+scale_fill_manual(values=c("#ED2026","#676767"))
table_erbb2 = data.frame(CNV=c(0,0),ecDNA=c(0,0))
row.names(table_erbb2)=c("negative","positive")
table_erbb2[1,]=c(length(which(ERBB2$type=="CNV"&ERBB2$Family_history=="negative")),length(which(ERBB2$type=="ecDNA"&ERBB2$Family_history=="negative")))
table_erbb2[2,]=c(length(which(ERBB2$type=="CNV"&ERBB2$Family_history=="positive")),length(which(ERBB2$type=="ecDNA"&ERBB2$Family_history=="positive")))
chis_erbb2 = chisq.test(table_erbb2)
corr2 <- paste("Chi-square test. = ", round(chis_erbb2$p.value,2), sep="")
p2 = ggplot(data = ERBB2)+geom_point(aes(x = log(copy_number),y=Family_history,size=year,color=type))+scale_color_manual(values=c("#666666","#FF0016"))+theme_bw()+theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),panel.background = element_blank())+theme(axis.text = element_text(color = "black"))+geom_text_repel(aes(log(copy_number),Family_history,label=rownames(ERBB2)),max.overlaps = 30)+geom_text(aes(2,"negative",label=corr2))
table_erbb2$Family_history=c("negative","positive")
table_erbb2_bar = melt(table_erbb2,id.vars = "Family_history")
table_erbb2_bar$variable=factor(table_erbb2_bar$variable,levels=c("ecDNA","CNV"))
p2_bar = ggplot(data=table_erbb2_bar)+geom_bar(aes(x=Family_history,y=value,fill=variable),stat="identity")+theme_bw()+scale_y_continuous(expand = c(0,0))+scale_fill_manual(values=c("#ED2026","#676767"))
table_ccne1 = data.frame(CNV=c(0,0),ecDNA=c(0,0))
row.names(table_ccne1)=c("negative","positive")
table_ccne1[1,]=c(length(which(CCNE1$type=="CNV"&CCNE1$Family_history=="negative")),length(which(CCNE1$type=="ecDNA"&CCNE1$Family_history=="negative")))
table_ccne1[2,]=c(length(which(CCNE1$type=="CNV"&CCNE1$Family_history=="positive")),length(which(CCNE1$type=="ecDNA"&CCNE1$Family_history=="positive")))
chis_erbb2 = chisq.test(table_ccne1)
corr3 <- paste("Chi-square test. = ", round(chis_erbb2$p.value,2), sep="")
p3 = ggplot(data = CCNE1)+geom_point(aes(x = log(copy_number),y=Family_history,size=year,color=type))+scale_color_manual(values=c("#666666","#FF0016"))+theme_bw()+theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),panel.background = element_blank())+theme(axis.text = element_text(color = "black"))+geom_text_repel(aes(log(copy_number),Family_history,label=rownames(CCNE1)),max.overlaps = 30)+geom_text(aes(3,"negative",label=corr3))
table_ccne1$Family_history=c("negative","positive")
table_ccne1_bar = melt(table_ccne1,id.vars = "Family_history")
table_ccne1_bar$variable=factor(table_ccne1_bar$variable,levels=c("ecDNA","CNV"))
p3_bar = ggplot(data=table_ccne1_bar)+geom_bar(aes(x=Family_history,y=value,fill=variable),stat="identity")+theme_bw()+scale_y_continuous(expand = c(0,0))+scale_fill_manual(values=c("#ED2026","#676767"))
ggsave('EGFR.Family_history.copynumber.pdf',plot=p1,width=6,height=4)
ggsave('ERBB2.Family_history.copynumber.pdf',plot=p2,width=6,height=4)
ggsave('CCNE1.Family_history.copynumber.pdf',plot=p3,width=6,height=4)
ggsave('EGFR.Family_history.copynumber.bar.pdf',plot=p1_bar,width=6,height=4)
ggsave('ERBB2.Family_history.copynumber.bar.pdf',plot=p2_bar,width=6,height=4)
ggsave('CCNE1.Family_history.copynumber.bar.pdf',plot=p3_bar,width=6,height=4)