''' Base <- data.frame(Nodes =c("P1", "P1", "P1", "P2"), Targets=c("P2","P3","P4","P1")) List <- c("P1", "P2", "P3") Base <- read.table("DataBase/Mybase/AB_List") List <- read.table("")[[1]] ''' ''' Result without Annotation '''
addPercent <- function(x){ percent <- round(x * 100, digits = 1) result <- paste(percent, "%", sep = "") return(result) }
library(tidyr) library(dplyr) A <- Base A <- A[which(match(A[[1]],List)!="NA"),] A <- A[which(match(A[[2]],List)!="NA"),] AVBA = paste(A[[2]],"_",A[[1]],sep='') List = c(AVBA) List = data.frame(X=List[duplicated(List)]) List = List %>% separate(X, c("A", "B"),'_') ListVBA = paste(List[[2]],"_",List[[1]],sep='') remove Lift == right List = List[-which(match(ListVBA)-c(1: nrow(List))==0),] List = List[match(ListVBA)-c(1: nrow(List))>0,] A = A[-na.omit(match(ListVAB)),] write.table(data.frame(A[1:2]),"Output",sep='\t',quote=F,col.names=F,row.names=F) ''' for delete duplicates and combind rest of colums ''' RM_du <-function(A){ AVBA = paste(A[[2]],"_",A[[1]],sep='')
Num=0 Num= Num+1
i = unique(AVAB == AVBA == AVAB)[-1]){ Num= Num+1
List1 = which(AVAB[1]) List1 = c(List1,which(AVAB[1])) TMP = A[List1,] TMP_R = data.frame(TMP[1,1:2],V3 = paste(unique(as.character(TMP[,3])), collapse='|')) Result = rbind(Result,TMP_R) A = A[-List1,] print(Num) } return(Result) }
|