# Script for Figure-5 # Script for "number ofTF-enhancer combinations that interact for at least one 3-AT level": # Make a new table, Y1Hdata3ATsubset, where only enhancers that were tested with 10, 20 and 40 mM 3AT are included. Y1Hdata <- read.table(file="Y1Hdata.updateduplTFs_logGitter.txt", header=TRUE, as.is=TRUE, sep="\t") list.of.enhancers <- names(table(Y1Hdata[,"enhancer"])) Y1Hdata3ATsubset <- NULL for(enhancer in list.of.enhancers) { Y1HdataPerEnhancer <- Y1Hdata[Y1Hdata[,"enhancer"]==enhancer,]; all.3AT <- names(table(Y1HdataPerEnhancer[,"X3AT"])) ; includes.10 <- sum(all.3AT=="10") == 1; includes.20 <- sum(all.3AT=="20") == 1; includes.40 <- sum(all.3AT=="40") == 1; if(includes.10 & includes.20 & includes.40) {Y1Hdata3ATsubset <- rbind(Y1Hdata3ATsubset,Y1HdataPerEnhancer[(Y1HdataPerEnhancer[,"X3AT"]==10) | (Y1HdataPerEnhancer[,"X3AT"]==20) | (Y1HdataPerEnhancer[,"X3AT"]==40),]) } } Y1Hdata3ATsubset.clean <- Y1Hdata3ATsubset[Y1Hdata3ATsubset[,"days"]==7 & !(Y1Hdata3ATsubset[,"contam"]) & !(Y1Hdata3ATsubset[,"is.twoTFs"]) & !(Y1Hdata3ATsubset[,"emptywell"]),] Y1Hdata3ATsubset.clean.10 <- Y1Hdata3ATsubset[Y1Hdata3ATsubset[,"days"]==10 & !(Y1Hdata3ATsubset[,"contam"]) & !(Y1Hdata3ATsubset[,"is.twoTFs"]) & !(Y1Hdata3ATsubset[,"emptywell"]),] #Now use the above subset, Y1Hdata3ATsubset.clean, instead of Y1Hdata, for the loop, you previously used to calculate number of TFs vs pval. pvt <- c(0.0001, seq(from=0.001, to=1, by=0.001)) TFnumber.10.7 <- c() for (p in pvt) {Y1Hpvalsubset.clean <- Y1Hdata3ATsubset.clean[Y1Hdata3ATsubset.clean[,"dupl.TFs.pval"]<=p & Y1Hdata3ATsubset.clean[,"X3AT"]==10,]; TFnumber.10.7 <- c(TFnumber.10.7,length(table(Y1Hpvalsubset.clean[,"Gene"])))} TFnumber.20.7 <- c() for (p in pvt) {Y1Hpvalsubset.clean <- Y1Hdata3ATsubset.clean[Y1Hdata3ATsubset.clean[,"dupl.TFs.pval"]<=p & Y1Hdata3ATsubset.clean[,"X3AT"]==20,]; TFnumber.20.7 <- c(TFnumber.20.7,length(table(Y1Hpvalsubset.clean[,"Gene"])))} TFnumber.40.7 <- c() for (p in pvt) {Y1Hpvalsubset.clean <- Y1Hdata3ATsubset.clean[Y1Hdata3ATsubset.clean[,"dupl.TFs.pval"]<=p & Y1Hdata3ATsubset.clean[,"X3AT"]==40,]; TFnumber.40.7 <- c(TFnumber.40.7,length(table(Y1Hpvalsubset.clean[,"Gene"])))} TFnumber.10.10 <- c() for (p in pvt) {Y1Hpvalsubset.clean.10 <- Y1Hdata3ATsubset.clean.10[Y1Hdata3ATsubset.clean.10[,"dupl.TFs.pval"]<=p & Y1Hdata3ATsubset.clean.10[,"X3AT"]==10,]; TFnumber.10.10 <- c(TFnumber.10.10,length(table(Y1Hpvalsubset.clean.10[,"Gene"])))} TFnumber.20.10 <- c() for (p in pvt) {Y1Hpvalsubset.clean.10 <- Y1Hdata3ATsubset.clean.10[Y1Hdata3ATsubset.clean.10[,"dupl.TFs.pval"]<=p & Y1Hdata3ATsubset.clean.10[,"X3AT"]==20,]; TFnumber.20.10 <- c(TFnumber.20.10,length(table(Y1Hpvalsubset.clean.10[,"Gene"])))} TFnumber.40.10 <- c() for (p in pvt) {Y1Hpvalsubset.clean.10 <- Y1Hdata3ATsubset.clean.10[Y1Hdata3ATsubset.clean.10[,"dupl.TFs.pval"]<=p & Y1Hdata3ATsubset.clean.10[,"X3AT"]==40,]; TFnumber.40.10 <- c(TFnumber.40.10,length(table(Y1Hpvalsubset.clean.10[,"Gene"])))} my.cex <- 0.5 plot(-log10(pvt), TFnumber.40.10, col="cadetblue4", pch=16, cex=my.cex, ylim=c(20,700), xlab="-log10(confidence score)", ylab="Number of TFs with p<=x", main="Number of TFs with Significant Interactions with a Confidence Score <=x") points(-log10(pvt), TFnumber.10.10, col="brown4", pch=16, cex=my.cex) points(-log10(pvt), TFnumber.20.7, col="chartreuse4", pch=16, cex=my.cex) points(-log10(pvt), TFnumber.20.10, col="darkgreen", pch=16, cex=my.cex) points(-log10(pvt), TFnumber.40.7, col="cadetblue1", pch=16, cex=my.cex) points(-log10(pvt), TFnumber.10.7, col="red", pch=16, cex=my.cex) # Script for "number ofTF-enhancer combinations that interact for two and three 3-AT levels": list.of.enhancers <- names(table(Y1Hdata[,"enhancer"])) Y1Hdata3ATsubset <- NULL for(enhancer in list.of.enhancers) { Y1HdataPerEnhancer <- Y1Hdata[Y1Hdata[,"enhancer"]==enhancer,]; all.3AT <- names(table(Y1HdataPerEnhancer[,"X3AT"])) ; includes.10 <- sum(all.3AT=="10") == 1; includes.20 <- sum(all.3AT=="20") == 1; includes.40 <- sum(all.3AT=="40") == 1; if(includes.10 & includes.20 & includes.40) {Y1Hdata3ATsubset <- rbind(Y1Hdata3ATsubset,Y1HdataPerEnhancer[(Y1HdataPerEnhancer[,"X3AT"]==10) | (Y1HdataPerEnhancer[,"X3AT"]==20) | (Y1HdataPerEnhancer[,"X3AT"]==40),]) } } Y1Hdata3ATsubset.clean <- Y1Hdata3ATsubset[Y1Hdata3ATsubset[,"days"]==7 & !(Y1Hdata3ATsubset[,"contam"]) & !(Y1Hdata3ATsubset[,"is.twoTFs"]) & !(Y1Hdata3ATsubset[,"emptywell"]),] pvt <- c(0.0001, seq(from=0.001, to=1, by=0.001)) list.of.TFs <- unique(Y1Hdata3ATsubset.clean[,"Gene"]) list.of.enhancers <- unique(Y1Hdata3ATsubset.clean[,"enhancer"]) num.of.TF.vs.pval <- matrix(rep(NA,2*length(pvt)),ncol=2) colnames(num.of.TF.vs.pval) <- c("p_value", "num.of.TF") num.of.TF.3.3AT <- rep(0,length(pvt)) date() #i <- 1 for (i in 1:length(pvt)) { p <- pvt[i] data.from.this.p <- Y1Hdata3ATsubset.clean[,"dupl.TFs.pval"]<= p for (j in 1:length(list.of.TFs)) { #j <- 20 TF <- list.of.TFs[j] data.from.this.TF <- Y1Hdata3ATsubset.clean[,"Gene"]==TF num.of.enh.3.3AT <- rep(0,length(list.of.enhancers)) for (k in 1:length(list.of.enhancers)) { #k <- 1 e <- list.of.enhancers[k] #any selection that can be done outside the loops, do it. hit.3AT.levels <- unique(Y1Hdata3ATsubset.clean[Y1Hdata3ATsubset.clean[,"enhancer"]==e & data.from.this.p & data.from.this.TF,"X3AT"]) num.3ATlevels.hit <- length(hit.3AT.levels) if(num.3ATlevels.hit >= 3) { num.of.enh.3.3AT[k] <- num.of.enh.3.3AT[k]+1 } }# end of the e loop if(sum(num.of.enh.3.3AT >= 1) > 0) { num.of.TF.3.3AT[i] <- num.of.TF.3.3AT[i]+1 } }#end of the TF loop num.of.TF.vs.pval[i, "num.of.TF"] <- num.of.TF.3.3AT[i] num.of.TF.vs.pval[i, "p_value"] <- p }#end of the p loop date() #### #do this for 10 days of growth list.of.enhancers <- names(table(Y1Hdata[,"enhancer"])) Y1Hdata3ATsubset <- NULL for(enhancer in list.of.enhancers) { Y1HdataPerEnhancer <- Y1Hdata[Y1Hdata[,"enhancer"]==enhancer,]; all.3AT <- names(table(Y1HdataPerEnhancer[,"X3AT"])) ; includes.10 <- sum(all.3AT=="10") == 1; includes.20 <- sum(all.3AT=="20") == 1; includes.40 <- sum(all.3AT=="40") == 1; if(includes.10 & includes.20 & includes.40) {Y1Hdata3ATsubset <- rbind(Y1Hdata3ATsubset,Y1HdataPerEnhancer[(Y1HdataPerEnhancer[,"X3AT"]==10) | (Y1HdataPerEnhancer[,"X3AT"]==20) | (Y1HdataPerEnhancer[,"X3AT"]==40),]) } } Y1Hdata3ATsubset.clean.10 <- Y1Hdata3ATsubset[Y1Hdata3ATsubset[,"days"]==10 & !(Y1Hdata3ATsubset[,"contam"]) & !(Y1Hdata3ATsubset[,"is.twoTFs"]) & !(Y1Hdata3ATsubset[,"emptywell"]),] pvt <- c(0.0001, seq(from=0.001, to=1, by=0.001)) list.of.TFs <- unique(Y1Hdata3ATsubset.clean.10[,"Gene"]) list.of.enhancers <- unique(Y1Hdata3ATsubset.clean.10[,"enhancer"]) num.of.TF.vs.pval.10 <- matrix(rep(NA,2*length(pvt)),ncol=2) colnames(num.of.TF.vs.pval.10) <- c("p_value", "num.of.TF") num.of.TF.3.3AT <- rep(0,length(pvt)) date() #i <- 1 for (i in 1: length(pvt)) { p <- pvt[i] data.from.this.p <- Y1Hdata3ATsubset.clean.10[,"dupl.TFs.pval"]<= p for (j in 1:length(list.of.TFs)) { #j <- 1 TF <- list.of.TFs[j] data.from.this.TF <- Y1Hdata3ATsubset.clean.10[,"Gene"]==TF num.of.enh.3.3AT <- rep(0,length(list.of.enhancers)) for (k in 1:length(list.of.enhancers)) { #k <- 1 e <- list.of.enhancers[k] #any selection that can be done outside the loops, do it. hit.3AT.levels <- unique(Y1Hdata3ATsubset.clean.10[Y1Hdata3ATsubset.clean.10[,"enhancer"]==e & data.from.this.p & data.from.this.TF,"X3AT"]) num.3ATlevels.hit <- length(hit.3AT.levels) if(num.3ATlevels.hit >= 3) { num.of.enh.3.3AT[k] <- num.of.enh.3.3AT[k]+1 } }# end of the e loop if(sum(num.of.enh.3.3AT >= 1) > 0) { num.of.TF.3.3AT[i] <- num.of.TF.3.3AT[i]+1 } }#end of the TF loop num.of.TF.vs.pval.10[i, "num.of.TF"] <- num.of.TF.3.3AT[i] num.of.TF.vs.pval.10[i, "p_value"] <- p }#end of the p loop date() #### #do this for hits at 2 3AT levels, 7 days list.of.enhancers <- names(table(Y1Hdata[,"enhancer"])) Y1Hdata3ATsubset <- NULL for(enhancer in list.of.enhancers) { Y1HdataPerEnhancer <- Y1Hdata[Y1Hdata[,"enhancer"]==enhancer,]; all.3AT <- names(table(Y1HdataPerEnhancer[,"X3AT"])) ; includes.10 <- sum(all.3AT=="10") == 1; includes.20 <- sum(all.3AT=="20") == 1; includes.40 <- sum(all.3AT=="40") == 1; if(includes.10 & includes.20 & includes.40) {Y1Hdata3ATsubset <- rbind(Y1Hdata3ATsubset,Y1HdataPerEnhancer[(Y1HdataPerEnhancer[,"X3AT"]==10) | (Y1HdataPerEnhancer[,"X3AT"]==20) | (Y1HdataPerEnhancer[,"X3AT"]==40),]) } } Y1Hdata3ATsubset.clean <- Y1Hdata3ATsubset[Y1Hdata3ATsubset[,"days"]==7 & !(Y1Hdata3ATsubset[,"contam"]) & !(Y1Hdata3ATsubset[,"is.twoTFs"]) & !(Y1Hdata3ATsubset[,"emptywell"]),] pvt <- c(0.0001, seq(from=0.001, to=1, by=0.001)) list.of.TFs <- unique(Y1Hdata3ATsubset.clean[,"Gene"]) list.of.enhancers <- unique(Y1Hdata3ATsubset.clean[,"enhancer"]) num.of.TF.vs.pval.two3AT <- matrix(rep(NA,2*length(pvt)),ncol=2) colnames(num.of.TF.vs.pval.two3AT) <- c("p_value", "num.of.TF") num.of.TF.3.3AT <- rep(0,length(pvt)) date() #i <- 2 for (i in 1: length(pvt)) { p <- pvt[i] data.from.this.p <- Y1Hdata3ATsubset.clean[,"dupl.TFs.pval"]<= p for (j in 1:length(list.of.TFs)) { #j <- 1 TF <- list.of.TFs[j] data.from.this.TF <- Y1Hdata3ATsubset.clean[,"Gene"]==TF num.of.enh.3.3AT <- rep(0,length(list.of.enhancers)) for (k in 1:length(list.of.enhancers)) { #k <- 1 e <- list.of.enhancers[k] #any selection that can be done outside the loops, do it. hit.3AT.levels <- unique(Y1Hdata3ATsubset.clean[Y1Hdata3ATsubset.clean[,"enhancer"]==e & data.from.this.p & data.from.this.TF,"X3AT"]) num.3ATlevels.hit <- length(hit.3AT.levels) if(num.3ATlevels.hit >= 2) { num.of.enh.3.3AT[k] <- num.of.enh.3.3AT[k]+1 } }# end of the e loop if(sum(num.of.enh.3.3AT >= 1) > 0) { num.of.TF.3.3AT[i] <- num.of.TF.3.3AT[i]+1 } }#end of the TF loop num.of.TF.vs.pval.two3AT[i, "num.of.TF"] <- num.of.TF.3.3AT[i] num.of.TF.vs.pval.two3AT[i, "p_value"] <- p }#end of the p loop date() #### # do it for 2 3AT levels, 10 days Y1Hdata3ATsubset.clean.10 <- Y1Hdata3ATsubset[Y1Hdata3ATsubset[,"days"]==10 & !(Y1Hdata3ATsubset[,"contam"]) & !(Y1Hdata3ATsubset[,"is.twoTFs"]) & !(Y1Hdata3ATsubset[,"emptywell"]),] pvt <- c(0.0001, seq(from=0.001, to=1, by=0.001)) list.of.TFs <- unique(Y1Hdata3ATsubset.clean.10[,"Gene"]) list.of.enhancers <- unique(Y1Hdata3ATsubset.clean.10[,"enhancer"]) num.of.TF.vs.pval.two3AT.10 <- matrix(rep(NA,2*length(pvt)),ncol=2) colnames(num.of.TF.vs.pval.two3AT.10) <- c("p_value", "num.of.TF") num.of.TF.3.3AT <- rep(0,length(pvt)) date() #i <- 1 for (i in 1: length(pvt)) { p <- pvt[i] data.from.this.p <- Y1Hdata3ATsubset.clean.10[,"dupl.TFs.pval"]<= p for (j in 1:length(list.of.TFs)) { #j <- 1 TF <- list.of.TFs[j] data.from.this.TF <- Y1Hdata3ATsubset.clean.10[,"Gene"]==TF num.of.enh.3.3AT <- rep(0,length(list.of.enhancers)) for (k in 1:length(list.of.enhancers)) { #k <- 1 e <- list.of.enhancers[k] #any selection that can be done outside the loops, do it. hit.3AT.levels <- unique(Y1Hdata3ATsubset.clean.10[Y1Hdata3ATsubset.clean.10[,"enhancer"]==e & data.from.this.p & data.from.this.TF,"X3AT"]) num.3ATlevels.hit <- length(hit.3AT.levels) if(num.3ATlevels.hit >= 2) { num.of.enh.3.3AT[k] <- num.of.enh.3.3AT[k]+1 } }# end of the e loop if(sum(num.of.enh.3.3AT >= 1) > 0) { num.of.TF.3.3AT[i] <- num.of.TF.3.3AT[i]+1 } }#end of the TF loop num.of.TF.vs.pval.two3AT.10[i, "num.of.TF"] <- num.of.TF.3.3AT[i] num.of.TF.vs.pval.two3AT.10[i, "p_value"] <- p }#end of the p loop date() #This is how to plot the data, after the first for loop #my.cex <- 0.5 #plot(-log10(num.of.TF.vs.pval[,"p_value"]), num.of.TF.vs.pval[,"num.of.TF"], col="cadetblue4", pch=16, cex=my.cex, ylim=c(0,20), xlab="-log10pvalues", ylab="Number of TFs with p<=x", main="Number of TFs vs confidence score", type="b") points(-log10(num.of.TF.vs.pval[,"p_value"]), num.of.TF.vs.pval[,"num.of.TF"], col="orange", pch=16, cex=my.cex) points(-log10(num.of.TF.vs.pval.10[,"p_value"]), num.of.TF.vs.pval.10[,"num.of.TF"], col="darkorange3", pch=16, cex=my.cex) points(-log10(num.of.TF.vs.pval.two3AT[,"p_value"]), num.of.TF.vs.pval.two3AT[,"num.of.TF"], col="lightpink2", pch=16, cex=my.cex) points(-log10(num.of.TF.vs.pval.two3AT.10[,"p_value"]), num.of.TF.vs.pval.two3AT.10[,"num.of.TF"], col="hotpink4", pch=16, cex=my.cex) ######################################################################### #Script for Table 1, showing TF-enhancer interaction above the set threshold Y1Hdata <- read.table(file="Y1Hdata.updateduplTFs_logGitter.txt", header=TRUE, as.is=TRUE, sep="\t") Y1Hdata.forsummary <- Y1Hdata[!(Y1Hdata[,"emptywell"]) & !(Y1Hdata[,"is.twoTFs"]),] list.of.TFs <- names(table(Y1Hdata.forsummary[,"Gene"])) list.of.enhancers <- names(table(Y1Hdata.forsummary[,"enhancer"])) list.of.3ATlevels <- names(table(Y1Hdata.forsummary[,"X3AT"])) mark.contamination <- matrix(rep(NA,length(list.of.TFs)*length(list.of.enhancers)),ncol=length(list.of.enhancers)) mark.contamination <- as.data.frame(mark.contamination) colnames(mark.contamination) <- list.of.enhancers rownames(mark.contamination) <- list.of.TFs number.of.3AT.levels <- matrix(rep(NA,length(list.of.TFs)*length(list.of.enhancers)),ncol=length(list.of.enhancers)) number.of.3AT.levels <- as.data.frame(number.of.3AT.levels) colnames(number.of.3AT.levels) <- list.of.enhancers rownames(number.of.3AT.levels) <- list.of.TFs interaction.table.all3AT.7.0005 <- matrix(rep(NA,length(list.of.TFs)*length(list.of.enhancers)),ncol=length(list.of.enhancers)) interaction.table.all3AT.7.0005 <- as.data.frame(interaction.table.all3AT.10.0005) colnames(interaction.table.all3AT.7.0005) <- list.of.enhancers rownames(interaction.table.all3AT.7.0005) <- list.of.TFs number.of.3ATlevels.0005 <- matrix(rep(NA,length(list.of.TFs)*length(list.of.enhancers)),ncol=length(list.of.enhancers)) number.of.3ATlevels.0005 <- as.data.frame(number.of.3ATlevels.0005) colnames(number.of.3ATlevels.0005) <- list.of.enhancers rownames(number.of.3ATlevels.0005) <- list.of.TFs wellID.and.plate <- matrix(rep(NA,2*length(list.of.TFs)),ncol=2) wellID.and.plate <- as.data.frame(wellID.and.plate) colnames(wellID.and.plate) <- c("well.ID", "plate") rownames(wellID.and.plate) <- list.of.TFs num.enhancers.bound <- rep(0,length(list.of.TFs)) #i <- 3 for (i in 1:length(list.of.TFs)) { TF <- list.of.TFs[i] wellID.and.plate[TF, "well.ID"] <- Y1Hdata.forsummary[Y1Hdata.forsummary[,"Gene"]==TF, "Pos"][1] wellID.and.plate[TF, "plate"] <- Y1Hdata.forsummary[Y1Hdata.forsummary[,"Gene"]==TF, "plate"][1] Y1Hdata.enh.per.TF.forsummary <- Y1Hdata.forsummary[Y1Hdata.forsummary[,"Gene"]==TF & (Y1Hdata.forsummary[,"X3AT"]==10| Y1Hdata.forsummary[,"X3AT"]==20|Y1Hdata.forsummary[,"X3AT"]==40|Y1Hdata.forsummary[,"X3AT"]==60|Y1Hdata.forsummary[,"X3AT"]==80|Y1Hdata.forsummary[,"X3AT"]==100) & (Y1Hdata.forsummary[,"days"]==6 | Y1Hdata.forsummary[,"days"]==7 | (Y1Hdata.forsummary[,"days"]==3 & Y1Hdata.forsummary[,"plate"]==2 & Y1Hdata.forsummary[,"enhancer"] == 909) | (Y1Hdata.forsummary[,"days"]==9 & Y1Hdata.forsummary[,"plate"]==2 & Y1Hdata.forsummary[,"enhancer"] == 902)) & Y1Hdata.forsummary[,"contam"] == 1,] #j<- 1 for (j in 1:length(list.of.enhancers)) { e <- list.of.enhancers[j] mark.contamination[i,j] <- sum(Y1Hdata.enh.per.TF.forsummary[,"enhancer"]==e) #if e is one enhancer, and Y1Hdata.enh.per.TF.forsummary is the rows of Y1Hdata that fit your criteria, including only coming from one TF, how many rows of that table have the value in the enhancer column equal to e #I guess the "how many rows" part of my answer is what the command actually means, but then what it means in terms of your data comes from how you set up that .forsummary table } Y1Hdata.enh.per.TF.forsummary <- Y1Hdata.forsummary[Y1Hdata.forsummary[,"Gene"]==TF & (Y1Hdata.forsummary[,"X3AT"]==10| Y1Hdata.forsummary[,"X3AT"]==20|Y1Hdata.forsummary[,"X3AT"]==40| Y1Hdata.forsummary[,"X3AT"]==60 |Y1Hdata.forsummary[,"X3AT"]==80|Y1Hdata.forsummary[,"X3AT"]==100) & (Y1Hdata.forsummary[,"days"]==6 | Y1Hdata.forsummary[,"days"]==7 | (Y1Hdata.forsummary[,"days"]==3 & Y1Hdata.forsummary[,"plate"]==2 & Y1Hdata.forsummary[,"enhancer"] == 909) | (Y1Hdata.forsummary[,"days"]==9 & Y1Hdata.forsummary[,"plate"]==2 & Y1Hdata.forsummary[,"enhancer"] == 902)) & !(Y1Hdata.forsummary[,"contam"] == 1),] #j<- 1 for (j in 1:length(list.of.enhancers)) { e <- list.of.enhancers[j] number.of.3AT.levels[i,j] <- sum(Y1Hdata.enh.per.TF.forsummary[,"enhancer"]==e) } Y1Hdata.enh.per.TF.forsummary <- Y1Hdata.enh.per.TF.forsummary[Y1Hdata.enh.per.TF.forsummary[,"dupl.TFs.pval"]<=0.005,] #bound.enhancers <- names(table(Y1Hdata.enh.per.TF.forsummary[,"enhancer"])) #num.enhancers.bound[i] <- length(bound.enhancers) #j<- 1 for (j in 1:length(list.of.enhancers)) { e <- list.of.enhancers[j] hit.3AT.levels <- unique(Y1Hdata.enh.per.TF.forsummary[Y1Hdata.enh.per.TF.forsummary[,"enhancer"]==e,"X3AT"]) num.3ATlevels.hit <- length(hit.3AT.levels) number.of.3ATlevels.0005[i,j] <- (sum(Y1Hdata.enh.per.TF.forsummary[,"enhancer"]==e)) if(num.3ATlevels.hit >= 2) { interaction.table.all3AT.10.0005[i,j] <- 1 num.enhancers.bound[i] <- num.enhancers.bound[i]+1 } else { interaction.table.all3AT.10.0005[i,j] <- 0 } }#this is the end of the e loop sum.per.row <- sum(interaction.table.all3AT.10.0005[i,][!is.na(interaction.table.all3AT.10.0005[i,])]) if(num.enhancers.bound[i] != sum.per.row) {cat(i," ")} }#this is the end of the TF loop sorted.mark.contamination <- mark.contamination[order(num.enhancers.bound,decreasing=TRUE),] write.table(sorted.mark.contamination,file="sorted.mark.contamination.txt",row.names=TRUE,col.names=TRUE,quote=FALSE,sep="\t",na="") sorted.number.of.3AT.levels <- number.of.3AT.levels[order(num.enhancers.bound,decreasing=TRUE),] write.table(sorted.number.of.3AT.levels,file="sorted.number.of.3AT.levels.nodoublesemptywells.txt",row.names=TRUE,col.names=TRUE,quote=FALSE,sep="\t",na="") sorted.interaction.table.all3AT.7.0005 <- interaction.table.all3AT.7.0005[order(num.enhancers.bound,decreasing=TRUE),] write.table(sorted.interaction.table.all3AT.7.0005,file="sorted.interaction.table.all3AT.7.0005.nodoublesemptywells.txt",row.names=TRUE,col.names=TRUE,quote=FALSE,sep="\t",na="") sorted.interaction.table.3ATlevels.0005 <- number.of.3ATlevels.0005[order(num.enhancers.bound,decreasing=TRUE),] write.table(sorted.interaction.table.3ATlevels.0005,file="sorted.interaction.table.0005.withhits.nodoublesemptywells.txt",row.names=TRUE,col.names=TRUE,quote=FALSE,sep="\t",na="") wellID.and.plate.sorted <- wellID.and.plate[order(num.enhancers.bound,decreasing=TRUE),] write.table(wellID.and.plate.sorted,file="wellID.and.plate.sorted.new.txt",row.names=TRUE,col.names=TRUE,quote=FALSE,sep="\t",na="")