R/CalculateHUM_Ex.R

Defines functions CalculateHUM_Ex

Documented in CalculateHUM_Ex

CalculateHUM_Ex<-function(data,indexF,indexClass,allLabel,amountL)
{
  #library(Rcpp)
  #library(gtools)
    
  dataEach=NULL
    
  for(i in 1:length(allLabel))
  {
      vrem=which(data[,indexClass]==allLabel[i])
      dataEach=c(dataEach,list(data[vrem,indexF,drop = FALSE]))
  }
  
  
  indexLabel<-combn(allLabel,amountL)
  output<-matrix(ncol=(length(indexF)+amountL),nrow=ncol(indexLabel))
 
  seqAll=NULL
  
  #cycle for different label combinations
  for(j in 1:ncol(indexLabel))
  {
    
    indexL=NULL
    for(i in 1:amountL)
    {
      indexL=c(indexL,which(allLabel==indexLabel[i,j]))
      output[j,i]<-indexLabel[i,j]
    }
  
   seqMax=NULL
   seq=permutations(amountL,amountL,1:amountL)
    
  for(i in 1:length(indexF))
  {
    
    s_data=NULL
     
    prodValue=1
    for (k in 1:amountL)
    {
      vrem=sort(dataEach[[indexL[k]]][,i])
    
      s_data=c(s_data,list(vrem))
      prodValue = prodValue*length(vrem)
    }
        
    out=CalcGene(s_data,seq, prodValue)
    
    output[j,(amountL+i)]<-out$HUM
    seqMax=cbind(seqMax,out$seq)
    
  }
  colnames(seqMax)=names(data[,indexF,drop = FALSE])  
  
  seqAll=c(seqAll,list(seqMax))
  } 
  
    name<-NULL
    for(i in 1:amountL)
    {
      name<-c(name,paste("Diagnosis",i,sep=""))
    }
    colnames(output)<-c(name,indexF)
  

  return(list(HUM=output,seq=seqAll))
}

Try the HUM package in your browser

Any scripts or data that you put into this service are public.

HUM documentation built on June 21, 2022, 5:05 p.m.