@@ -573,22 +573,24 @@ testStop <- function(x, epsilon=0.1){
573573# ' Function to select references for ALR
574574# ' @param dat input data in relative abundances
575575# ' @param meta metadata following MDSINE's metadata format
576- suggestRefs <- function (dat , meta ){
576+ # ' @param scaling library size to scale the data to proportions
577+ suggestRefs <- function (dat , meta , scaling = 1 ){
578+ # #dat <- apply(dat,2,function(x)x/sum(x))
577579 sps <- rownames(dat )
578580 # #1. remove ref with 0 values
579581 message(" The following species are not recommended due to 0 values:" )
580582 fil1 <- rowSums(dat == 0 )/ ncol(dat ) > 0.05
581583 message(paste0(sps [fil1 ], collapse = ' , ' ))
582584 # #2. filtering two tails
583- tmp <- rowMeans(prop.table (dat ,2 ))
584- fil2 <- tmp < 0.005
585- fil3 <- tmp > 0.5
585+ tmp <- rowMeans(apply (dat ,2 , function ( x ) x / sum( x ) ))
586+ fil2 <- tmp < 0.05
587+ fil3 <- tmp == max( tmp )
586588 message(" The following species are not recommended due to their low/high abudances:" )
587589 message(paste0(sps [fil2 | fil3 ], collapse = ' , ' ))
588590 cv <- foreach(s = unique(meta $ subjectID ), .combine = rbind ) %do % {
589591 apply(dat [, meta $ subjectID == s ], 1 , function (x ) sd(x )/ mean(x ))
590592 }
591- if (! is.null(cv )){
593+ if (! is.null(dim( cv ) )){
592594 cv <- apply(cv ,2 ,mean )
593595 }
594596 message(" The following species is recommended as the reference:" )
0 commit comments