Revision | a9e12042e2618e56ed24ce2f60c801058807a2b0 (tree) |
---|---|
Zeit | 2010-03-06 03:00:49 |
Autor | lorenzo |
Commiter | lorenzo |
Some modifications to the code to analyze data and make the plots and also to the code which divides the interactions
into roles (the category ALL was also including categories which were anyway left out).
@@ -75,7 +75,9 @@ | ||
75 | 75 | sel_P=s.where((tag_ids>=1400) & (tag_ids<1500))[0] |
76 | 76 | sel_V=s.where((tag_ids>=1500) & (tag_ids<1600))[0] |
77 | 77 | sel_A=s.where((tag_ids>=1600))[0] |
78 | -sel_ALL=s.where((tag_ids>=0))[0] | |
78 | +#sel_ALL=s.where((tag_ids>=0))[0] | |
79 | +sel_ALL=s.where((tag_ids<1100) | ((tag_ids>=1200) & (tag_ids<1300)) | ((tag_ids>=1300) & (tag_ids<1400)) \ | |
80 | + | ((tag_ids>=1400) & (tag_ids<1500)) | ((tag_ids>=1600)) )[0] | |
79 | 81 | |
80 | 82 | sel_list=[sel_E,sel_F,sel_N,sel_D,sel_P,sel_V,sel_A,sel_ALL] |
81 | 83 |
@@ -254,6 +254,30 @@ | ||
254 | 254 | |
255 | 255 | if (plot_before_network==1){ |
256 | 256 | |
257 | + | |
258 | +file_loc <- c("../A-A/interactions_a_a_.dat", | |
259 | + "../D-D/interactions_d_d_.dat", | |
260 | + "../N-N/interactions_n_n_.dat", | |
261 | + "../P-P/interactions_p_p_.dat", | |
262 | + "../E-E/interactions_e_e_.dat") | |
263 | + | |
264 | +number_tags <- seq(length(file_loc)) | |
265 | + | |
266 | +tag_categories <- c("A","D","N","P","E") | |
267 | + | |
268 | + | |
269 | +for (i in seq(length(file_loc))){ | |
270 | + | |
271 | +#fn <- paste(prefix_vec[i],"Contact Number", sep=" ") | |
272 | + | |
273 | +tags_by_category <- read.table(file_loc[i]) | |
274 | + | |
275 | +tags_by_category <- as.matrix(tags_by_category) | |
276 | + | |
277 | +number_tags[i] <- length(unique(c(tags_by_category[ ,2],tags_by_category[ ,3]))) | |
278 | + | |
279 | +} | |
280 | + | |
257 | 281 | #This is useful and should get executed |
258 | 282 | |
259 | 283 | if (hist_plot==1){ |
@@ -287,16 +311,24 @@ | ||
287 | 311 | |
288 | 312 | fn <- paste(prefix_vec[i],"Contact Number", sep=" ") |
289 | 313 | |
290 | -my_dframe <- read.table(file_loc[i]) | |
314 | +my_dframe <- read.table(file_loc[i], header=FALSE) | |
291 | 315 | |
292 | 316 | my_dframe <- as.matrix(my_dframe) |
293 | 317 | |
318 | +if (i<=5){ | |
319 | + | |
320 | + print("dim(my_dframe)") | |
321 | + print(dim(my_dframe)) | |
322 | + | |
323 | +} | |
324 | + | |
294 | 325 | |
295 | 326 | #i.e. I am using 1 hours as a max duration of each (uncumulated!!!) link. |
296 | 327 | sel <- which(my_dframe<=filter_unc) |
297 | 328 | |
298 | 329 | my_dframe <- my_dframe[sel] |
299 | 330 | |
331 | + | |
300 | 332 | ## print(max("my_dframe is ")) |
301 | 333 | |
302 | 334 | ## print(max(my_dframe)) |
@@ -308,9 +340,12 @@ | ||
308 | 340 | names(my_dframe) <- c("time") |
309 | 341 | #my_dframe$time <- factor(my_dframe$time) |
310 | 342 | |
311 | -list_ggplot[[i]] <- ggplot(my_dframe,aes(x=time,y=..count..) )+ | |
312 | - geom_histogram(binwidth=.2, colour="black", fill="blue",origin=log10(20))+ | |
313 | - # geom_vline(xintercept = 3600)+ | |
343 | +list_ggplot[[i]] <- ggplot(my_dframe,aes(x=time) )+ | |
344 | + geom_histogram(aes(y=..count..), binwidth=.2, colour="black", fill="blue",origin=log10(20))+ | |
345 | + geom_vline(xintercept = log10(60), col="red", size=1)+ | |
346 | +# geom_vline(xintercept = log10(600), col="black",size=1)+ | |
347 | + geom_vline(xintercept = log10(600), col="darkgreen",size=1)+ | |
348 | + | |
314 | 349 | #xlab(theme_blank())+ |
315 | 350 | ylab(fn)+ |
316 | 351 | ## scale_x_continuous(trans="log10", limits=c(19,3600))+ |
@@ -498,6 +533,22 @@ | ||
498 | 533 | |
499 | 534 | |
500 | 535 | |
536 | +prefix_vec_double <- c("A","A","A","D","A","N","A","P","A","E", | |
537 | + "D","D","D","N","D","P","D","E","N","N", | |
538 | + "N","P","E","N","P","P","E","P","E","E") | |
539 | + | |
540 | + | |
541 | + | |
542 | +norm_vec <- seq(length(prefix_vec)) | |
543 | + | |
544 | + | |
545 | +for (i in seq(length(prefix_vec))){ | |
546 | + | |
547 | +norm_vec[i] <- number_tags[which(tag_categories==prefix_vec_double[2*i-1])]*number_tags[which(tag_categories==prefix_vec_double[2*i])] | |
548 | + | |
549 | +} | |
550 | + | |
551 | + | |
501 | 552 | sum_of_contact_durations <- seq(length(prefix_vec)) |
502 | 553 | |
503 | 554 | count_contacts <- seq(length(prefix_vec)) |
@@ -506,8 +557,8 @@ | ||
506 | 557 | |
507 | 558 | for (i in seq(15)){ |
508 | 559 | |
509 | -print("i is, ") | |
510 | -print(i) | |
560 | +## print("i is, ") | |
561 | +## print(i) | |
511 | 562 | |
512 | 563 | fn <- paste(prefix_vec[i],"Contact Number", sep=" ") |
513 | 564 |
@@ -552,9 +603,9 @@ | ||
552 | 603 | sum_of_contact_durations[i] <- sum(link_cumulative_durations) |
553 | 604 | count_contacts[i] <- sum(number_contacts_in_link) |
554 | 605 | |
555 | -if (prefix_vec[i]=="P-P"){ | |
556 | -pp_durations <- link_cumulative_durations | |
557 | -} | |
606 | +## if (prefix_vec[i]=="P-P"){ | |
607 | +## pp_durations <- link_cumulative_durations | |
608 | +## } | |
558 | 609 | |
559 | 610 | |
560 | 611 | #Now I get rid of links whose cumulated duration is excessive |
@@ -564,11 +615,11 @@ | ||
564 | 615 | |
565 | 616 | my_dframe_tot <- cbind(link_cumulative_durations,number_contacts_in_link) |
566 | 617 | |
567 | -print("max(my_dframe_tot[ ,1])") | |
568 | -print(max(my_dframe_tot[ ,1])) | |
618 | +## print("max(my_dframe_tot[ ,1])") | |
619 | +## print(max(my_dframe_tot[ ,1])) | |
569 | 620 | |
570 | -print("max(my_dframe_tot[ ,2])") | |
571 | -print(max(my_dframe_tot[ ,2])) | |
621 | +## print("max(my_dframe_tot[ ,2])") | |
622 | +## print(max(my_dframe_tot[ ,2])) | |
572 | 623 | |
573 | 624 | |
574 | 625 | my_dframe_tot <- as.data.frame(my_dframe_tot) |
@@ -671,7 +722,8 @@ | ||
671 | 722 | x_mid <- (x_max+x_min)/2 |
672 | 723 | |
673 | 724 | y_min <- rep(0,length(prefix_vec)) |
674 | -y_max <- sum_of_contact_durations/sum(sum_of_contact_durations) | |
725 | +#y_max <- sum_of_contact_durations/sum(sum_of_contact_durations) | |
726 | +y_max <- sum_of_contact_durations | |
675 | 727 | |
676 | 728 | data_small <- cbind(y_max,y_min,x_min,x_max,x_mid) |
677 | 729 |
@@ -684,14 +736,14 @@ | ||
684 | 736 | my_ybreaks <- (seq(8)-1)/10 |
685 | 737 | |
686 | 738 | count_duration_plot<- ggplot(data_new)+ |
687 | - geom_rect(aes(ymin = y_min, ymax = y_max,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
739 | + geom_rect(aes(ymin = y_min, ymax= y_max/3600.,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
688 | 740 | xlab("Role Pair")+ |
689 | - ylab("Fraction of Overall Contact Duration")+ | |
741 | + ylab("Total Contact Duration [hours]")+ | |
690 | 742 | ## scale_x_continuous(trans="log10", limits=c(19,660))+ |
691 | 743 | ## scale_y_continuous(trans="log10", limits=c(1,700))+ |
692 | 744 | ## scale_x_continuous(trans="log10",limits=c(20,18000))+ |
693 | 745 | scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ |
694 | -scale_y_continuous( limits=c(0.,0.7), breaks=my_ybreaks)+ | |
746 | +#scale_y_continuous( limits=c(0.,0.7), breaks=my_ybreaks)+ | |
695 | 747 | opts(axis.title.x = theme_text(size = 35))+ |
696 | 748 | opts(axis.title.y = theme_text(size = 35, angle=90))+ |
697 | 749 | opts(axis.text.x = theme_text(size=30, colour="black",vjust=1))+ |
@@ -700,27 +752,27 @@ | ||
700 | 752 | opts(axis.text.y = theme_text(size=30, colour="black", hjust=1)) |
701 | 753 | |
702 | 754 | |
703 | -CairoPDF("Contact_duration_fraction_per_coupled_roles_rectangles.pdf", width=20, height=10) | |
755 | +CairoPDF("Contact_duration_per_coupled_roles.pdf", width=20, height=10) | |
704 | 756 | |
705 | 757 | print(count_duration_plot) |
706 | 758 | dev.off() |
707 | 759 | |
708 | 760 | |
709 | -#Now | |
710 | - | |
711 | -data_new$y_max <- count_contacts/sum(count_contacts) | |
712 | 761 | |
713 | -my_ybreaks <- (seq(5)-1)/10 | |
714 | 762 | |
715 | -count_contact_plot<- ggplot(data_new)+ | |
716 | - geom_rect(aes(ymin = y_min, ymax = y_max,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
763 | +#and its normalized version | |
764 | + | |
765 | +my_ybreaks <- seq(0,20,by=5) | |
766 | + | |
767 | +count_duration_plot<- ggplot(data_new)+ | |
768 | + geom_rect(aes(ymin = y_min, ymax = y_max/norm_vec/60.,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
717 | 769 | xlab("Role Pair")+ |
718 | - ylab("Fraction of Overall Contact Number")+ | |
770 | + ylab("Normalized Total Contact Duration [min]")+ | |
719 | 771 | ## scale_x_continuous(trans="log10", limits=c(19,660))+ |
720 | 772 | ## scale_y_continuous(trans="log10", limits=c(1,700))+ |
721 | 773 | ## scale_x_continuous(trans="log10",limits=c(20,18000))+ |
722 | 774 | scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ |
723 | -scale_y_continuous( limits=c(0.0,0.4), breaks=my_ybreaks)+ | |
775 | +scale_y_continuous( limits=c(0.,20.), breaks=my_ybreaks)+ | |
724 | 776 | opts(axis.title.x = theme_text(size = 35))+ |
725 | 777 | opts(axis.title.y = theme_text(size = 35, angle=90))+ |
726 | 778 | opts(axis.text.x = theme_text(size=30, colour="black",vjust=1))+ |
@@ -729,11 +781,78 @@ | ||
729 | 781 | opts(axis.text.y = theme_text(size=30, colour="black", hjust=1)) |
730 | 782 | |
731 | 783 | |
732 | -CairoPDF("Contact_number_fraction_per_coupled_roles_rectangles.pdf", width=20, height=10) | |
784 | +CairoPDF("Normalized_contact_duration_per_coupled_roles.pdf", width=20, height=10) | |
785 | + | |
786 | +print(count_duration_plot) | |
787 | +dev.off() | |
788 | + | |
789 | + | |
790 | + | |
791 | + | |
792 | + | |
793 | +#Now the fraction of contacts | |
794 | + | |
795 | +#data_new$y_max <- count_contacts/sum(count_contacts) | |
796 | + | |
797 | +data_new$y_max <- count_contacts | |
798 | + | |
799 | + | |
800 | +my_ybreaks <- (seq(5)-1)/10 | |
801 | + | |
802 | +count_contact_plot<- ggplot(data_new)+ | |
803 | + geom_rect(aes(ymin = y_min, ymax = y_max,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
804 | + xlab("Role Pair")+ | |
805 | + ylab("Total Contact Number")+ | |
806 | +## scale_x_continuous(trans="log10", limits=c(19,660))+ | |
807 | +## scale_y_continuous(trans="log10", limits=c(1,700))+ | |
808 | + ## scale_x_continuous(trans="log10",limits=c(20,18000))+ | |
809 | + scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ | |
810 | +#scale_y_continuous( limits=c(0.0,0.4), breaks=my_ybreaks)+ | |
811 | + opts(axis.title.x = theme_text(size = 35))+ | |
812 | + opts(axis.title.y = theme_text(size = 35, angle=90))+ | |
813 | + opts(axis.text.x = theme_text(size=30, colour="black",vjust=1))+ | |
814 | + # opts(axis.text.x = theme_blank())+ | |
815 | +# geom_text(aes(label = labels, fill = NULL), data = data_new)+ | |
816 | + opts(axis.text.y = theme_text(size=30, colour="black", hjust=1)) | |
817 | + | |
818 | + | |
819 | +CairoPDF("Contact_number_per_coupled_roles.pdf", width=20, height=10) | |
733 | 820 | |
734 | 821 | print(count_contact_plot) |
735 | 822 | dev.off() |
736 | 823 | |
824 | + | |
825 | +#and its normalized version | |
826 | + | |
827 | +my_ybreaks <- c(0,0.5e-3,1e-3,1.5e-3,2e-3) | |
828 | + | |
829 | +count_contact_plot<- ggplot(data_new)+ | |
830 | + geom_rect(aes(ymin = y_min, ymax = y_max/norm_vec,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
831 | + xlab("Role Pair")+ | |
832 | + ylab("Normalized Total Contact Number")+ | |
833 | +## scale_x_continuous(trans="log10", limits=c(19,660))+ | |
834 | +## scale_y_continuous(trans="log10", limits=c(1,700))+ | |
835 | + ## scale_x_continuous(trans="log10",limits=c(20,18000))+ | |
836 | + scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ | |
837 | +#scale_y_continuous( limits=c(0.0,2e-3), breaks=my_ybreaks)+ | |
838 | + opts(axis.title.x = theme_text(size = 35))+ | |
839 | + opts(axis.title.y = theme_text(size = 35, angle=90))+ | |
840 | + opts(axis.text.x = theme_text(size=30, colour="black",vjust=1))+ | |
841 | + # opts(axis.text.x = theme_blank())+ | |
842 | +# geom_text(aes(label = labels, fill = NULL), data = data_new)+ | |
843 | + opts(axis.text.y = theme_text(size=30, colour="black", hjust=1)) | |
844 | + | |
845 | + | |
846 | +CairoPDF("Normalized_contact_number_per_coupled_roles.pdf", width=20, height=10) | |
847 | + | |
848 | +print(count_contact_plot) | |
849 | +dev.off() | |
850 | + | |
851 | + | |
852 | + | |
853 | + | |
854 | + | |
855 | + | |
737 | 856 | ##########################################################################################################à |
738 | 857 | ##########################################################################################################à |
739 | 858 | ##########################################################################################################à |
@@ -777,8 +896,8 @@ | ||
777 | 896 | |
778 | 897 | for (i in seq(length(prefix_vec))){ |
779 | 898 | |
780 | -print("i is, ") | |
781 | -print(i) | |
899 | +## print("i is, ") | |
900 | +## print(i) | |
782 | 901 | |
783 | 902 | #fn <- paste(prefix_vec[i]," Number of Contacts", sep=" ") |
784 | 903 |
@@ -867,7 +986,8 @@ | ||
867 | 986 | x_mid <- (x_max+x_min)/2 |
868 | 987 | |
869 | 988 | y_min <- rep(0,length(prefix_vec)) |
870 | -y_max <- sum_of_contact_durations/sum(sum_of_contact_durations) | |
989 | +#y_max <- sum_of_contact_durations/sum(sum_of_contact_durations) | |
990 | +y_max <- sum_of_contact_durations | |
871 | 991 | |
872 | 992 | data_small <- cbind(y_max,y_min,x_min,x_max,x_mid) |
873 | 993 |
@@ -877,17 +997,17 @@ | ||
877 | 997 | |
878 | 998 | names(data_new) <- c("y_max","y_min","x_min","x_max","x_mid","my_labels") |
879 | 999 | |
880 | -my_ybreaks <- (seq(5)-1)/10 | |
1000 | +my_ybreaks <- seq(0,200,by=50) | |
881 | 1001 | |
882 | 1002 | count_duration_plot<- ggplot(data_new)+ |
883 | - geom_rect(aes(ymin = y_min, ymax = y_max,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
1003 | + geom_rect(aes(ymin = y_min, ymax = y_max/3600.,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
884 | 1004 | xlab("Role")+ |
885 | - ylab("Fraction of Overall Contact Duration")+ | |
1005 | + ylab("Total Contact Duration [hours]")+ | |
886 | 1006 | ## scale_x_continuous(trans="log10", limits=c(19,660))+ |
887 | 1007 | ## scale_y_continuous(trans="log10", limits=c(1,700))+ |
888 | 1008 | ## scale_x_continuous(trans="log10",limits=c(20,18000))+ |
889 | 1009 | scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ |
890 | -scale_y_continuous( limits=c(0.0,0.4), breaks=my_ybreaks)+ | |
1010 | +scale_y_continuous( limits=c(0.0,200), breaks=my_ybreaks)+ | |
891 | 1011 | opts(axis.title.x = theme_text(size = 20))+ |
892 | 1012 | opts(axis.title.y = theme_text(size = 20, angle=90))+ |
893 | 1013 | opts(axis.text.x = theme_text(size=15, colour="black",vjust=1))+ |
@@ -896,27 +1016,25 @@ | ||
896 | 1016 | opts(axis.text.y = theme_text(size=15, colour="black", hjust=1)) |
897 | 1017 | |
898 | 1018 | |
899 | -CairoPDF("Contact_duration_fraction_per_role_rectangles.pdf") | |
1019 | +CairoPDF("Contact_duration_per_role.pdf") | |
900 | 1020 | |
901 | 1021 | print(count_duration_plot) |
902 | 1022 | dev.off() |
903 | 1023 | |
904 | 1024 | |
905 | -#Now | |
906 | - | |
907 | -data_new$y_max <- count_contacts/sum(count_contacts) | |
1025 | +#Now its normalized version | |
908 | 1026 | |
909 | -my_ybreaks <- (seq(4)-1)/10 | |
1027 | +#my_ybreaks <- seq(0,200,by=50) | |
910 | 1028 | |
911 | -count_contact_plot<- ggplot(data_new)+ | |
912 | - geom_rect(aes(ymin = y_min, ymax = y_max,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
1029 | +count_duration_plot<- ggplot(data_new)+ | |
1030 | + geom_rect(aes(ymin = y_min, ymax = y_max/number_tags/60.,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
913 | 1031 | xlab("Role")+ |
914 | - ylab("Fraction of Overall Contact Number")+ | |
1032 | + ylab("Normalized Total Contact Duration [min]")+ | |
915 | 1033 | ## scale_x_continuous(trans="log10", limits=c(19,660))+ |
916 | 1034 | ## scale_y_continuous(trans="log10", limits=c(1,700))+ |
917 | 1035 | ## scale_x_continuous(trans="log10",limits=c(20,18000))+ |
918 | 1036 | scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ |
919 | -scale_y_continuous( limits=c(0.0,0.3), breaks=my_ybreaks)+ | |
1037 | +#scale_y_continuous( limits=c(0.0,20), breaks=my_ybreaks)+ | |
920 | 1038 | opts(axis.title.x = theme_text(size = 20))+ |
921 | 1039 | opts(axis.title.y = theme_text(size = 20, angle=90))+ |
922 | 1040 | opts(axis.text.x = theme_text(size=15, colour="black",vjust=1))+ |
@@ -925,11 +1043,71 @@ | ||
925 | 1043 | opts(axis.text.y = theme_text(size=15, colour="black", hjust=1)) |
926 | 1044 | |
927 | 1045 | |
928 | -CairoPDF("Contact_number_fraction_per_role_rectangles.pdf") | |
1046 | +CairoPDF("Normalized_contact_duration_per_role.pdf") | |
1047 | + | |
1048 | +print(count_duration_plot) | |
1049 | +dev.off() | |
1050 | + | |
1051 | + | |
1052 | + | |
1053 | +##################################################################### | |
1054 | + | |
1055 | +#Now the same quantity with contact numbers | |
1056 | + | |
1057 | +#data_new$y_max <- count_contacts/sum(count_contacts) | |
1058 | +data_new$y_max <- count_contacts | |
1059 | + | |
1060 | +my_ybreaks <- (seq(4)-1)/10 | |
1061 | + | |
1062 | +count_contact_plot<- ggplot(data_new)+ | |
1063 | + geom_rect(aes(ymin = y_min, ymax = y_max,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
1064 | + xlab("Role")+ | |
1065 | + ylab("Total Contact Number")+ | |
1066 | +## scale_x_continuous(trans="log10", limits=c(19,660))+ | |
1067 | +## scale_y_continuous(trans="log10", limits=c(1,700))+ | |
1068 | + ## scale_x_continuous(trans="log10",limits=c(20,18000))+ | |
1069 | + scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ | |
1070 | +#scale_y_continuous( limits=c(0.0,0.3), breaks=my_ybreaks)+ | |
1071 | + opts(axis.title.x = theme_text(size = 20))+ | |
1072 | + opts(axis.title.y = theme_text(size = 20, angle=90))+ | |
1073 | + opts(axis.text.x = theme_text(size=15, colour="black",vjust=1))+ | |
1074 | + # opts(axis.text.x = theme_blank())+ | |
1075 | +# geom_text(aes(label = labels, fill = NULL), data = data_new)+ | |
1076 | + opts(axis.text.y = theme_text(size=15, colour="black", hjust=1)) | |
1077 | + | |
1078 | + | |
1079 | +CairoPDF("Contact_number_per_role.pdf") | |
929 | 1080 | |
930 | 1081 | print(count_contact_plot) |
931 | 1082 | dev.off() |
932 | 1083 | |
1084 | + | |
1085 | +my_ybreaks <- c(0,0.5e-2,1e-2,1.5e-2,2e-2) | |
1086 | + | |
1087 | +count_contact_plot<- ggplot(data_new)+ | |
1088 | + geom_rect(aes(ymin = y_min, ymax = y_max/number_tags,xmin=x_min,xmax=x_max), colour="black", fill="blue")+ | |
1089 | + xlab("Role")+ | |
1090 | + ylab("Normalized Total Contact Number")+ | |
1091 | +## scale_x_continuous(trans="log10", limits=c(19,660))+ | |
1092 | +## scale_y_continuous(trans="log10", limits=c(1,700))+ | |
1093 | + ## scale_x_continuous(trans="log10",limits=c(20,18000))+ | |
1094 | + scale_x_continuous(labels=prefix_vec, breaks=x_mid)+ | |
1095 | +#scale_y_continuous( limits=c(0.0,0.02), breaks=my_ybreaks)+ | |
1096 | + opts(axis.title.x = theme_text(size = 20))+ | |
1097 | + opts(axis.title.y = theme_text(size = 20, angle=90))+ | |
1098 | + opts(axis.text.x = theme_text(size=15, colour="black",vjust=1))+ | |
1099 | + # opts(axis.text.x = theme_blank())+ | |
1100 | +# geom_text(aes(label = labels, fill = NULL), data = data_new)+ | |
1101 | + opts(axis.text.y = theme_text(size=15, colour="black", hjust=1)) | |
1102 | + | |
1103 | + | |
1104 | +CairoPDF("Normalized_contact_number_per_role.pdf") | |
1105 | + | |
1106 | +print(count_contact_plot) | |
1107 | +dev.off() | |
1108 | + | |
1109 | + | |
1110 | + | |
933 | 1111 | print("OK down here") |
934 | 1112 | |
935 | 1113 | #Now I go on with a boxplot |
@@ -942,11 +1120,24 @@ | ||
942 | 1120 | data_bp$role_label <- factor(data_bp$role_label) |
943 | 1121 | |
944 | 1122 | |
1123 | +line_seq <- c(log10(300),log10(600),log10(1800)) | |
1124 | +line_col <- c("5 minutes", "10 minutes", "30 minutes") | |
1125 | + | |
1126 | +data_line <- cbind(as.data.frame(line_seq),as.data.frame(line_col)) | |
1127 | + | |
1128 | +names(data_line) <- c("line_seq","line_col") | |
945 | 1129 | |
946 | 1130 | my_ybreaks <- c(1e1,1e2,1e3,1e4) |
947 | 1131 | gpl <- ggplot(data_bp,aes(x=role_label,y=contact_data) )+ |
948 | 1132 | # geom_boxplot( quantiles = c(0,1))+ |
949 | 1133 | geom_boxplot( )+ |
1134 | + geom_hline(yintercept = log10(300), col="red", size=1)+ | |
1135 | + geom_hline(yintercept = log10(600), col="black",size=1)+ | |
1136 | + geom_hline(yintercept = log10(1800), col="darkgreen",size=1)+ | |
1137 | + | |
1138 | +#geom_hline(yintercept = line_seq, col="red", size=1)+ | |
1139 | +#geom_hline(data=dataline, yintercept = line_seq, color=line_col, size=1)+ | |
1140 | + | |
950 | 1141 | ## scale_x_log10() + |
951 | 1142 | ## scale_y_log10()+ #better NOT to use short-hand notation if you want to set the axis |
952 | 1143 | #scale_x_continuous(trans = "log10", limits=c(10,1e4))+ |
@@ -1016,8 +1207,8 @@ | ||
1016 | 1207 | |
1017 | 1208 | gt95 <- c(gt95,as.matrix(data_bp$contact_data[sel][sel2])) |
1018 | 1209 | |
1019 | -print ("length(gt95 is, )") | |
1020 | -print(length(gt95)) | |
1210 | +## print ("length(gt95 is, )") | |
1211 | +## print(length(gt95)) | |
1021 | 1212 | |
1022 | 1213 | gt95_lab <- c(gt95_lab,as.vector(data_bp$role_label[sel][sel2])) |
1023 | 1214 |
@@ -1045,6 +1236,10 @@ | ||
1045 | 1236 | geom_crossbar(aes(y = q50, ymin = q25, ymax = q75),fill="white") + |
1046 | 1237 | geom_crossbar(aes(y = q95, ymin = q95, ymax = q95)) + |
1047 | 1238 | geom_crossbar(aes(y = q5, ymin = q5, ymax = q5)) + |
1239 | + geom_hline(yintercept = log10(300), col="red", size=1)+ | |
1240 | + geom_hline(yintercept = log10(600), col="black",size=1)+ | |
1241 | + geom_hline(yintercept = log10(1800), col="darkgreen",size=1)+ | |
1242 | + | |
1048 | 1243 | scale_y_continuous( trans="log10", limits=c(1e1,1e4), breaks=my_ybreaks)+ |
1049 | 1244 | |
1050 | 1245 | geom_errorbar(limits) + |
@@ -1091,8 +1286,9 @@ | ||
1091 | 1286 | |
1092 | 1287 | if (plot_network==1){ |
1093 | 1288 | |
1289 | + | |
1094 | 1290 | list_ggplot <- list() #I re-initialize this list |
1095 | - | |
1291 | +#list_g_con <- list() #this list will contain the connected nodes in the network | |
1096 | 1292 | |
1097 | 1293 | ## file_loc <- c("../A-A/interactions_a_a_.dat", |
1098 | 1294 | ## "../A-D/interactions_a_d_.dat", |
@@ -1185,6 +1381,24 @@ | ||
1185 | 1381 | |
1186 | 1382 | |
1187 | 1383 | |
1384 | +file_loc4 <- c("../A-A/hashed_couples_in_contact_durations_1_.dat", | |
1385 | + "../A-D/hashed_couples_in_contact_durations_1_.dat", | |
1386 | + "../A-N/hashed_couples_in_contact_durations_1_.dat", | |
1387 | + "../A-P/hashed_couples_in_contact_durations_1_.dat", | |
1388 | + "../A-E/hashed_couples_in_contact_durations_1_.dat", | |
1389 | + "../D-D/hashed_couples_in_contact_durations_1_.dat", | |
1390 | + "../D-N/hashed_couples_in_contact_durations_1_.dat", | |
1391 | + "../D-P/hashed_couples_in_contact_durations_1_.dat", | |
1392 | + "../D-E/hashed_couples_in_contact_durations_1_.dat", | |
1393 | + "../N-N/hashed_couples_in_contact_durations_1_.dat", | |
1394 | + "../N-P/hashed_couples_in_contact_durations_1_.dat", | |
1395 | + "../E-N/hashed_couples_in_contact_durations_1_.dat", | |
1396 | + "../P-P/hashed_couples_in_contact_durations_1_.dat", | |
1397 | + "../E-P/hashed_couples_in_contact_durations_1_.dat", | |
1398 | + "../E-E/hashed_couples_in_contact_durations_1_.dat") | |
1399 | + | |
1400 | + | |
1401 | + | |
1188 | 1402 | |
1189 | 1403 | prefix_vec <- c("A-A","A-D","A-N","A-P","A-E", |
1190 | 1404 | "D-D","D-N","D-P","D-E","N-N", |
@@ -1206,8 +1420,8 @@ | ||
1206 | 1420 | #for (i in sel_num){ |
1207 | 1421 | |
1208 | 1422 | |
1209 | -print("i is, ") | |
1210 | -print(i) | |
1423 | +## print("i is, ") | |
1424 | +## print(i) | |
1211 | 1425 | |
1212 | 1426 | |
1213 | 1427 | duration_list <- read.table(file_loc2[i],header=FALSE) |
@@ -1227,13 +1441,19 @@ | ||
1227 | 1441 | tab_ini <- read.table(file_loc[i],header=FALSE) |
1228 | 1442 | tab_ini <- as.matrix(tab_ini) |
1229 | 1443 | |
1444 | +hashed_ids <- read.table(file_loc4[i],header=FALSE) | |
1445 | +hashed_ids <- as.matrix(hashed_ids) | |
1446 | + | |
1230 | 1447 | |
1231 | 1448 | #Now get rid of all the contacts below a certain threhshold |
1232 | 1449 | |
1233 | 1450 | tab_ini <- tab_ini[sel,] |
1234 | 1451 | duration_list <- duration_list[sel] |
1235 | 1452 | |
1453 | +# and also update the duration list! | |
1454 | +duration_list <- duration_list[sel] | |
1236 | 1455 | |
1456 | +hashed_ids <- hashed_ids[sel] | |
1237 | 1457 | |
1238 | 1458 | ## graph_raw_no_time <- tab_ini[ , 2:dim(tab_ini)[2]] |
1239 | 1459 |
@@ -1258,11 +1478,18 @@ | ||
1258 | 1478 | # 99878976 1234558 |
1259 | 1479 | #which are obviously the same edge repeated twice. |
1260 | 1480 | |
1481 | +#E(g)$weight <- duration_list | |
1482 | + | |
1483 | +#wb <- duration_list | |
1261 | 1484 | |
1262 | 1485 | g <- simplify(g) |
1263 | 1486 | |
1487 | +#wa <- E(g)$weight | |
1488 | + | |
1264 | 1489 | names_g <- V(g)$name |
1265 | 1490 | |
1491 | +hashed_unique <- unique(hashed_ids) | |
1492 | + | |
1266 | 1493 | |
1267 | 1494 | #E(g)$weight <- duration_list |
1268 | 1495 |
@@ -1272,12 +1499,12 @@ | ||
1272 | 1499 | ids_isolated_nodes <- setdiff(tag_list,ids_connected_nodes) |
1273 | 1500 | |
1274 | 1501 | |
1275 | -print("ids_isolated_nodes") | |
1502 | +## print("ids_isolated_nodes") | |
1276 | 1503 | |
1277 | -print(ids_isolated_nodes) | |
1504 | +## print(ids_isolated_nodes) | |
1278 | 1505 | |
1279 | -print("number isol nodes") | |
1280 | -print(length(ids_isolated_nodes)) | |
1506 | +## print("number isol nodes") | |
1507 | +## print(length(ids_isolated_nodes)) | |
1281 | 1508 | |
1282 | 1509 | #Now add the isolated nodes to the graph |
1283 | 1510 |
@@ -1380,4 +1607,8 @@ | ||
1380 | 1607 | dev.off() |
1381 | 1608 | |
1382 | 1609 | } |
1610 | + | |
1611 | + | |
1612 | + | |
1613 | + | |
1383 | 1614 | print("So far so good") |