R/row.stats.by.group.R

Defines functions row.stats.by.group

# row.stats.by.group: Function uses stat.by.group function to compute stats for each row of the
# expression and lesion data matrices and return a data.frame of expression level by lesion groups for
# each specified test.

row.stats.by.group=function(X,   # expression data
                            G,   # lesion data
                            stat, # stats to be computed
                            ...)

{
  if (any(dim(X)!=dim(G)))
    stop("X and G are of incompatible dimensions.  X and G must have the same dimensions.")

  if (any(colnames(X)!=colnames(G)))
    stop("X and G must have column names matched.")

  all.grps=sort(unique(G))
  all.grps=sort(unique(all.grps))

  k=length(all.grps)

  m=nrow(X)

  res=matrix(NA,m,k)
  colnames(res)=all.grps
  rownames(res)=rownames(X)

  for (i in 1:m)
  {
    res[i,]=stat.by.group(X[i,],G[i,],stat,all.grps,...)
  }

  return(res)
}

Try the GRIN2 package in your browser

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

GRIN2 documentation built on June 17, 2025, 9:11 a.m.