R/dist.lsn.R

Defines functions dist.lsn

# dist.lsn: Computes pairwise distances between subjects based on lesion profiles.

dist.lsn=function(lsn.mtx) # lesion matrix with subjects in columns and genes in rows
{
  n=ncol(lsn.mtx)
  res=matrix(NA,n,n)
  colnames(res)=rownames(res)=colnames(lsn.mtx)
  diag(res)=0

  if (n<2)
    return(res)

  for (i in 1:(n-1))
    for (j in (i+1):n)
    {
      res[i,j]=res[j,i]=sum(lsn.mtx[,i]!=lsn.mtx[,j])
    }
  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 Aug. 22, 2026, 5:09 p.m.