R/ternary_convert.R

Defines functions ternary_convert

Documented in ternary_convert

ternary_convert <-
function(matrix,threshold){
    ternary<-matrix(,nrow(matrix),ncol(matrix)) #This creates an empty matrix (Precisely, matrix with all NAs)
    rownames(ternary)<-rownames(matrix)
    colnames(ternary)<-colnames(matrix)
    ternary[matrix>-1*threshold&matrix<threshold]=0
    ternary[matrix<=-1*threshold]=-1
    ternary[matrix>=threshold]=1
    return(as.data.frame(ternary)) 
}
peterwu19881230/microbialPhenotypes documentation built on March 19, 2021, 6:36 a.m.