############################################################################################################ ############################################################################################################ ######################################### BioXM application ################################################ ############################################################################################################ ############################################################################################################ # # # Functional modules integrating essential cellular functions are predictive of the response of leukaemia # # cells to DNA damage # # # # Supplementary Material # # R-Code written by Nil Turan and Philipp Antczak # # # # Dr. Francesco Falciani Group, University of Birmingham # # # # 2008 # # # ############################################################################################################ ############################################################################################################ ############################################################################################################ # CALL FUNCTIONS ########################################################################################### ############################################################################################################ ############################################################################################################ ############################################################################################################ # (Others_BioXM-I) CALL FUNCTION: get adjacency list from a BioXM output ############################################################################################################ get.adj.list <- function( file.name, gene.source, gene.target, annotation, dataset.symbol ){ tmp <- list() for( i in seq( file.name[,1] ) ) { source <- strsplit( as.character( file.name[i,gene.source] )," \\[" )[[1]][1] target <- strsplit( as.character( file.name[i,gene.target] )," \\[" )[[1]][1] currenti <- as.character( file.name[i,annotation] ) subtmp <- c( unlist( tmp[source] ),which( as.character(dataset.symbol) == target ) ) subtmp2 <- c( unlist( tmp[target] ),which( as.character(dataset.symbol) == source ) ) tmp[source] <- list( unique( subtmp ) ) tmp[target] <- list( unique( subtmp2 ) ) attributes( tmp[source] ) <- list( pathways=c( attributes( tmp[source] )$pathways,currenti ) ) } return( tmp ) } ############################################################################################################ # (Others_BioXM-II) CALL FUNCTION: get a network from a BioXM output ############################################################################################################ get.network <- function( data, bioxm.output.KEGG, bioxm.output.pp, f.out.adj.list, pp.col.target = "Gene.target", pp.col.source = "Gene.source", KEGG.col.target = "Target.Gene", KEGG.col.source = "Source.Gene", pp.annotation = "Annotation.Interaction.Source", KEGG.annotation = "Pathway.source") { pp.col.target <- gsub( " ","\\.", pp.col.target ) pp.col.source <- gsub( " ","\\.", pp.col.source ) KEGG.col.target <- gsub( " ","\\.", KEGG.col.target ) KEGG.col.target <- gsub( " ","\\.", KEGG.col.source ) pp.annotation <- gsub( " ","\\.", pp.annotation ) KEGG.annotation <- gsub( " ","\\.", KEGG.annotation ) # read the output created by BioXM kegg <- read.delim( bioxm.output.KEGG,header=T,row.names=NULL ) pp <- read.delim( bioxm.output.pp,header=T,row.names=NULL ) kegg.sub <- unique( kegg[, c( KEGG.col.source, KEGG.col.target, KEGG.annotation ) ] ) if( class( data ) == "matrix" ) { dataset.symbol <- rownames( data ) }else if( class( data ) == "vector" ) { dataset.symbol <- data } pp.sub <- unique( pp[, c( pp.col.source,pp.col.target,pp.annotation )] ) # create KEGG interaction list stock.list <- c() for( i in kegg.sub[,KEGG.col.target] ){ target.tmp <- unlist( strsplit( as.character( kegg.sub[i,KEGG.col.target] ),";" ) ) source.tmp <- unlist( strsplit( as.character( kegg.sub[i,KEGG.col.source] ),";" ) ) for( j in seq( target.tmp ) ) { for( l in seq( source.tmp ) ) { stock.list <- rbind( stock.list, c( source.tmp[l],target.tmp[j] ) ) } } } kegg.sub <- cbind( stock.list, rep( unique( as.character( kegg.sub[,KEGG.annotation])), length( stock.list[,1] ) ) ) colnames( kegg.sub ) <- c(KEGG.col.source, KEGG.col.target, KEGG.annotation) kegg.adj.list<-get.adj.list( kegg.sub, KEGG.col.source, KEGG.col.target, KEGG.annotation, dataset.symbol ) list.order <- match( names( kegg.adj.list ), as.character( dataset.symbol ) ) kegg.adj.list.2 <- list() length( kegg.adj.list.2 ) <- length( dataset.symbol ) names( kegg.adj.list.2 ) <- as.character( dataset.symbol ) for( i in seq( list.order ) ) kegg.adj.list.2[list.order[i]] <- list( kegg.adj.list[[i]] ) kegg.adj.list <- kegg.adj.list.2 rm( kegg.adj.list.2 ) # create protein-protein interaction list pp.adj.list <- get.adj.list( pp.sub, pp.col.source, pp.col.target, pp.annotation, dataset.symbol ) list.order <- match( names( pp.adj.list ), as.character( dataset.symbol ) ) pp.adj.list.2 <- list() length( pp.adj.list.2 ) <- length( dataset.symbol ) names( pp.adj.list.2 ) <- as.character( dataset.symbol ) for( i in seq( list.order ) ) pp.adj.list.2[ list.order[i] ] <- list( pp.adj.list[[i]] ) pp.adj.list <- pp.adj.list.2 rm( pp.adj.list.2 ) # merge the KEGG list and protein-protein interaction list super.adj.list <- list() super.adj.list[[1]] <- kegg.adj.list super.adj.list[[2]] <- pp.adj.list adj.list.merge <- list() length( adj.list.merge ) <- length( dataset.symbol ) for( i in 1:length( dataset.symbol ) ) { for( j in seq( super.adj.list ) ) { adj.list.merge[i] <- list( unique( c( unlist( adj.list.merge[[i]] ), unlist( super.adj.list[[j]][[i]] ) ) ) ) } } names( adj.list.merge ) <- dataset.symbol null.values <- which( sapply ( adj.list.merge, is.null ) ) for( i in null.values ) adj.list.merge[[i]] <- integer(0) # write down adjacent list write.adj.list( adj.list.merge, f.out.adj.list ) return( list( adj.list = adj.list.merge ) ) }