R code: tdcclass

tdcclass=function(X1,X2,FF,num.permutations=Inf){

  ## Input:

 

        # X1 - network 1

        # X2 - network 2

        # FF - index of the subset of genes to be considered for testing

 

        # num.permutations - the number of random permutations

 

  ## Output:

 

        # p - p value

        # delta - observed test statistic

 

 

s1=plsnet(X1)

s2=plsnet(X2)

n1=ncol(X1)

n2=ncol(X2)

X=cbind(X1,X2)

n=n1+n2

nG=nrow(X)

f=length(FF)

ACD=abs(s1[FF,FF]-s2[FF,FF])

delta=(sum(ACD)-sum(diag(ACD)))/(f*(f-1))

 

count.overall=0

for (i in 1:num.permutations){

  i1=as.vector(sample(1:n,n1))

  perm.X1=X[,i1]

  perm.X2=X[,-i1]

  perm.s1=plsnet(perm.X1)

  perm.s2=plsnet(perm.X2)

  ACD=abs(perm.s1[FF,FF]-perm.s2[FF,FF])

  perm.delta=(sum(ACD)-sum(diag(ACD)))/(f*(f-1))

  if (perm.delta>=delta)

  count.overall=count.overall+1

}

p.value.overall=count.overall/num.permutations

 

list(p=p.value.overall,delta=delta)

}

 

Made with Namu6