Talk:RankProduct.R

From Organic Design wiki
Error in RankProd package, specifically related to the RP and topGene function.
The help(RP) documentation provides the following information
about NA handling;

   na.rm: if 'FALSE' (default), the NA value will not be used in
          computing rank. If 'TRUE', the missing  values will be
          replaced by the gene-wise mean of the non-missing values.
          Gene with all values missing  will be assigned "NA"

So, in the case where an entire row of observations for a gene are NAs the rank
product should be assigned NAs. Generating a 10 by 4 matrix from a normal
distribution with two rows of missing values;

library(RankProd)
set.seed(1)

nrows <- 10
ncols <- 4
X <- round(matrix(rnorm(nrows * ncols), nc=ncols),2)

X[2:3,] <- NA
X

RP.out <- RP(X, cl=rep(1,ncols), na.rm=TRUE)

RP.out$RPrank

RP.out$RPrank[2:3,] # Small bug here
subset(RP.out$Orirank, 2:3)

RP.out$Orirank[["class1 > class 2"]] # (additional space in list name)
RankProd1(X, logged=TRUE, num.class=1, rev.sorting=TRUE)$rank.all

RP.out$Orirank[["class1 < class2"]]
RankProd1(X, logged=TRUE, num.class=1, rev.sorting=FALSE)$rank.all


RP.out$pval


tG <- topGene(RP.out, cutoff = 0.1, method="pval", logged=FALSE,
        logbase=2, gene.names=rownames(X)) 

# List is wrong

tG[[1]]
# List ok
tG[[2]]


sessionInfo()