-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRscript.txt
More file actions
121 lines (81 loc) · 4.76 KB
/
Copy pathRscript.txt
File metadata and controls
121 lines (81 loc) · 4.76 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
data=read.table("kirch.maf",fill=T,head=T)
a=unlist(strsplit(unique(as.character(data$Matched_Norm_Sample_Barcode)),"-"))
ids=unique(a[which(a=="TCGA")+2])
ref=as.character(data$Reference_Allele)
allele1=as.character(data$Tumor_Seq_Allele1)
allele2=as.character(data$Tumor_Seq_Allele2)
good_Hugo=which(ref!=allele2)
genes=as.character(unique(data$Hugo[good_Hugo]))
counts=0*c(1:length(genes))
chromosome=counts
for(i in 2:length(genes)){
ref=as.character(data$Reference_Allele[which(data$Hugo_Symbol==genes[i])])
allele1=as.character(data$Tumor_Seq_Allele1[which(data$Hugo_Symbol==genes[i])])
counts[i]=length(which(ref!=allele1))
chromosome[i]=as.character(data$Chromosome[which(data$Hugo_Symbol==genes[i])])[1]
}
for(i in 1:length(chromosome_counts)){chromosome_counts[i]=sum(counts[which(chromosome==unique(chromosome)[i])])}
patients=unique(data$Barcode)
p=c(1:length(patients))
for(i in 1:length(patients)){
ref=as.character(data$Reference_Allele[which(data$Tumor_Sample_Barcode==patients[i])])
allele1=as.character(data$Tumor_Seq_Allele1[which(data$Tumor_Sample_Barcode==patients[i])])
list=as.character(data$Hugo_Symbol[which(ref!=allele1)])
p[i]=append(p[i],list)
}
frame=data.frame(chromosome, counts, genes)
data=subset(frame, counts > 1)
p<- ggplot(frame, aes(factor(chromosome), counts)) + theme_bw()
p<- p + theme(legend.position="none") + geom_boxplot(aes(fill = factor(chromosome)))
p<- p + ylim(0,2) + ylab("Variant Counts") + xlab("Chromosome")
a=data$Hugo_Symbol[which(data$Chromosome==3)]
rev(sort(unique(a)))[1:10]
gene_frame=data.frame(counts,genes)
gene_frame=gene_frame[with(gene_frame,order(-counts)),]
top_genes=gene_frame$genes[c(1:50)]
top_genes_frame=data.frame(genes=gene_frame$genes[c(1:50)],counts=gene_frame$counts[c(1:50)])
for(i in 1:length(top_genes)){c=as.character(unique(data$Tumor_Sample_Barcode[which(data$Hugo_Symbol==as.character(top_genes_frame$genes[i]))])) ; b=append(b,c) }
a=patients_with_top_mutations[duplicated(patients_with_top_mutations, fromLast=TRUE) | duplicated(patients_with_top_mutations)]
try=data$Hugo_Symbol[which(data$Tumor_Sample_Barcode==patients_with_top_mutations[1])]
vector_common_mutations<-c(1:length(patients_with_top_mutations))*0
for(i in 1:length(patients_with_top_mutations)){
a=data$Hugo_Symbol[which(data$Tumor_Sample_Barcode==patients_with_top_mutations[i])];
vector_common_mutations[i]=Reduce(intersect, list(a,top_genes));
}
for(i in 1:length(patients_with_VHL)){a=data$Hugo_Symbol[which(data$Tumor_Sample_Barcode==patients_with_VHL[i] & data$Reference_Allele!=as.character(data$Tumor_Seq_Allele1) & data$Hugo_Symbol!="VHL" )];
list_of_associated_genes=append(list_of_associated_genes,as.character(a))
}
a=data$Hugo_Symbol[which(data$Chromosome==3 & data$Reference_Allele!=as.character(data$Tumor_Seq_Allele1) &data$Hugo_Symbol!="VHL" ) ]
patients=unique(data$Tumor_Sample_Barcode[which(data$Reference_Allele!=as.character(data$Tumor_Seq_Allele1) & (data$Hugo_Symbol=="VHL" | data$Hugo_Symbol=="PBRM1"))])
for(i in 1:length(patients)){
b=data$Hugo_Symbol[which(data$Tumor_Sample_Barcode==patients[i] & data$Reference_Allele!=as.character(data$Tumor_Seq_Allele1) & data$Hugo_Symbol!="PBRM1" & data$Hugo_Symbol!="VHL" ) ];
b=as.character(b);
a=append(a,b);
}
correlated_genes$correlated_genes=correlated_genes$correlated_genes[which(correlated_genes$correlated_genes!="Unknown")]
sort(table(correlated_genes$a),decreasing=TRUE)
variant_type=c(1:length(reference))*0
variant_type[which(reference=="A" & mutation=="C")]="AtoC"
variant_type[which(reference=="A" & mutation=="G")]="AtoG"
variant_type[which(reference=="A" & mutation=="T")]="AtoT"
variant_type[which(reference=="C" & mutation=="G")]="CtoG"
variant_type[which(reference=="C" & mutation=="T")]="CtoT"
variant_type[which(reference=="C" & mutation=="A")]="CtoA"
variant_type[which(reference=="G" & mutation=="A")]="GtoA"
variant_type[which(reference=="G" & mutation=="C")]="GtoC"
variant_type[which(reference=="G" & mutation=="T")]="GtoT"
variant_type[which(reference=="T" & mutation=="A")]="TtoA"
variant_type[which(reference=="T" & mutation=="C")]="TtoC"
variant_type[which(reference=="T" & mutation=="G")]="TtoG"
qplot(reference, ..density.., data=frame, geom="density", fill=variant_type)
a=data$Hugo_Symbol[which(data$Reference_Allele!=as.character(data$Tumor_Seq_Allele1))]
a=as.data.frame(table(a))
top_genes=as.character(a$a[which(a$Freq>15 & a$a!="Unknown")])
mutation_alleles=data$Tumor_Seq_Allele1
reference_alleles=data$Reference_Allele
genes=data$Hugo_Symbol
frame2=data.frame(genes,reference_alleles,mutation_alleles)
x.sub=frame2[frame2$genes %in% top_genes,]
variant_types=c("AtoC","AtoG","AtoT","CtoA","CtoT","CtoG","GtoA","GtoC","GtoT","TtoA","TtoC","TtoG")
genes=("A","C","T","G")
variant_type[which(reference==genes[1] & mutation==genes[2])]=variant_types[1]