#inserisci in inp1/2/3/4 il numero di rotture per ciascun soggetto delle 4
#classi per le bande dei cluster A e B.




#CLUSTER A

inp1A<-scan("ROTTURE_PER_SOGGETTO_CONTROLLO_CLUSTER_A.dat")

inp2A<-scan("ROTTURE_PER_SOGGETTO_RAD_MALATI_CLUSTER_A.dat")

inp3A<-scan("ROTTURE_PER_SOGGETTO_RAD_NO_MALATI_CLUSTER_A.dat")

inp4A<-scan("ROTTURE_PER_SOGGETTO_PEST_CLUSTER_A.dat")

TOT_ROTTURE_CLUSTER_A<-2153

seqA<-rep(0, times = 60)

k<-0

for( i in 1:length(inp1A) ) {

	k<-k+1

	seqA[k]<-(inp1A[i]/(2*TOT_ROTTURE_CLUSTER_A))

}
perc_1A<-100*sum(inp1A)/TOT_ROTTURE_CLUSTER_A




for( i in 1:length(inp2A) ) {

	k<-k+1

	seqA[k]<-inp2A[i]/TOT_ROTTURE_CLUSTER_A

}
perc_2A<-100*sum(inp2A)/TOT_ROTTURE_CLUSTER_A





for( i in 1:length(inp3A) ) {

	k<-k+1

	seqA[k]<-inp3A[i]/TOT_ROTTURE_CLUSTER_A

}
perc_3A<-100*sum(inp3A)/TOT_ROTTURE_CLUSTER_A





for( i in 1:length(inp4A) ) {

	k<-k+1

	seqA[k]<-(inp4A[i]/(2*TOT_ROTTURE_CLUSTER_A))

}
perc_4A<-100*sum(inp4A)/TOT_ROTTURE_CLUSTER_A


#oltre a disegnare quantifichiamo un po'
media_inp1A<-mean(inp1A)
media_inp2A<-mean(inp2A)
media_inp3A<-mean(inp3A)
media_inp4A<-mean(inp4A)

media_fra_inp1A<-mean(inp1A/TOT_ROTTURE_CLUSTER_A)
media_fra_inp2A<-mean(inp2A/TOT_ROTTURE_CLUSTER_A)
media_fra_inp3A<-mean(inp3A/TOT_ROTTURE_CLUSTER_A)
media_fra_inp4A<-mean(inp4A/TOT_ROTTURE_CLUSTER_A)








#CLUSTER B	

inp1B<-scan("ROTTURE_PER_SOGGETTO_CONTROLLO_CLUSTER_B.dat")

inp2B<-scan("ROTTURE_PER_SOGGETTO_RAD_MALATI_CLUSTER_B.dat")

inp3B<-scan("ROTTURE_PER_SOGGETTO_RAD_NO_MALATI_CLUSTER_B.dat")

inp4B<-scan("ROTTURE_PER_SOGGETTO_PEST_CLUSTER_B.dat")

TOT_ROTTURE_CLUSTER_B<-3553

seqB<-rep(0, times = 60)

z<-0

for( i in 1:length(inp1B) ) {

	z<-z+1

	seqB[z]<-(inp1B[i]/(2*TOT_ROTTURE_CLUSTER_B))

}
perc_1B<-100*sum(inp1B)/TOT_ROTTURE_CLUSTER_B





for( i in 1:length(inp2B) ) {

	z<-z+1

	seqB[z]<-inp2B[i]/TOT_ROTTURE_CLUSTER_B

}
perc_2B<-100*sum(inp2B)/TOT_ROTTURE_CLUSTER_B





for( i in 1:length(inp3B) ) {

	z<-z+1

	seqB[z]<-inp3B[i]/TOT_ROTTURE_CLUSTER_B

}
perc_3B<-100*sum(inp3B)/TOT_ROTTURE_CLUSTER_B





for( i in 1:length(inp4B) ) {

	z<-z+1

	seqB[z]<-(inp4B[i]/(2*TOT_ROTTURE_CLUSTER_B))

}
perc_4B<-100*sum(inp4B)/TOT_ROTTURE_CLUSTER_B


#oltre a disegnare quantifichiamo un po'
media_inp1B<-mean(inp1B)
media_inp2B<-mean(inp2B)
media_inp3B<-mean(inp3B)
media_inp4B<-mean(inp4B)

media_fra_inp1B<-mean(inp1B/TOT_ROTTURE_CLUSTER_B)
media_fra_inp2B<-mean(inp2B/TOT_ROTTURE_CLUSTER_B)
media_fra_inp3B<-mean(inp3B/TOT_ROTTURE_CLUSTER_B)
media_fra_inp4B<-mean(inp4B/TOT_ROTTURE_CLUSTER_B)















#costruisco col
colors<-NULL

q<-0

for( i in 1:length(inp1B) ) {

	q<-q+1

	colors[q]<-"lightblue"

}






for( i in 1:length(inp2B) ) {

	q<-q+1

	colors[q]<-"gray"

}






for( i in 1:length(inp3B) ) {

	q<-q+1

	colors[q]<-"lightcyan"

}






for( i in 1:length(inp4B) ) {

	q<-q+1

	colors[q]<-"lavender"

}


#costruisco legenda


leg.txt<-c("control people", "radiated ill people", "radiated healthy people",
"pesticide exposed people")
leg.col<-c("lightblue", "gray", "lightcyan","lavender") 



#grafico del numero di rotture dei soggetti del campione ( preventivamente ordinati per classi )in riferimento alle bande del cluster A o B
#grA<-barplot(seqA, type = "h", col = c(colors),legend.text = c(leg.txt),main = " Number of breaks occured on cluster A bands on patients' sample", xlab = "patient ID", ylab = "breaks number")
#grB<-barplot(seqB, type = "h",col = c(colors),legend.text =c(leg.txt),main = " Number of breaks occured on cluster B bands on patients' sample", xlab = "patient ID", ylab = "breaks number")

#grafico la frazione del numero di rotture totale del cluster per soggetto
grA<-barplot(seqA, type = "h", col = c(colors),legend.text = c(leg.txt),main = "Number of breaks occured on cluster A bands on patients'sample", xlab ="patient ID", ylab = "breaks number/cluster breaks number")
#grB<-barplot(seqB, type = "h",col = c(colors),legend.text =c(leg.txt),main = " Number of breaks occured on cluster B bands onpatients'sample", xlab = "patient ID", ylab = "breaks number/cluster breaks number")

