1
|
1 #!/usr/bin/env Rscript
|
|
2 .libPaths('~/R_libs_36')
|
|
3 args = commandArgs(trailingOnly=TRUE)
|
|
4
|
|
5 library("dplyr", warn.conflicts = FALSE)
|
|
6 library(ggplot2)
|
|
7
|
|
8
|
|
9 perts_lab<-read.delim(args[1],sep=" ",row.names = 1)
|
|
10
|
|
11 perts_lab<-replace(perts_lab,perts_lab==-1,"down")
|
|
12 perts_lab<-replace(perts_lab,perts_lab==1,"up")
|
|
13 perts_lab<-replace(perts_lab,perts_lab==0,"nochange")
|
|
14
|
|
15 df1<-data.frame(perts_lab)
|
|
16 df1$up <- apply(df1, 1, function(x) length(which(x=="up")))
|
|
17 df1$down<-apply(df1, 1, function(x) length(which(x=="down")))
|
|
18 df1$total<-df1$up+df1$down
|
|
19 df1<-df1[order(df1$total),]
|
|
20 write.table(df1,"successful_controlnode_perturbations.txt",quote=F)
|
|
21
|
|
22 # oh<-t(perts_lab) %>% reshape2::melt()
|
|
23 # pdf(file="pertrubation_trends.pdf")
|
|
24 # ggplot(oh, aes(x=value)) + facet_wrap(~Var1,scales = "free_x",shrink=FALSE) + geom_bar(aes(y = (..count..)/nrow(perts_lab))) + scale_y_continuous(labels=scales::percent) |