aertslab / SCENIC

SCENIC is an R package to infer Gene Regulatory Networks and cell types from single-cell RNA-seq data.
http://scenic.aertslab.org
GNU General Public License v3.0
421 stars 95 forks source link

could not find function "calcRSS" #374

Open chenx9 opened 1 year ago

chenx9 commented 1 year ago

rss <- calcRSS(AUC=getAUC(sub_regulonAUC),

saeedfc commented 1 year ago

Hi,

Not a contributor of the package. Have you loaded SCENIC r package? library(SCENIC)

chenx9 commented 1 year ago

Yes, I have loaded without displaying an error

1674133151432
saeedfc commented 1 year ago

Can you try loading all the 3 functions below and see if it works?

.H <- function(pVect){
  pVect <- pVect[pVect>0] # /sum(pVect) ??
  - sum(pVect * log2(pVect))
}

# Jensen-Shannon Divergence (JSD)
calcJSD <- function(pRegulon, pCellType)
{
  (.H((pRegulon+pCellType)/2)) - ((.H(pRegulon)+.H(pCellType))/2)
}

# Regulon specificity score (RSS)
.calcRSS.oneRegulon <- function(pRegulon, pCellType)
{
  jsd <- calcJSD(pRegulon, pCellType)
  1 - sqrt(jsd)
}

calcRSS <- function(AUC, cellAnnotation, cellTypes=NULL)
{
  if(any(is.na(cellAnnotation))) stop("NAs in annotation")
  if(any(class(AUC)=="aucellResults")) AUC <- getAUC(AUC)
  normAUC <- AUC/rowSums(AUC)
  if(is.null(cellTypes)) cellTypes <- unique(cellAnnotation)
  # 
  ctapply <- lapply
  if(require('BiocParallel')) ctapply <- bplapply

  rss <- ctapply(cellTypes, function(thisType)
    sapply(rownames(normAUC), function(thisRegulon)
    {
      pRegulon <- normAUC[thisRegulon,]
      pCellType <- as.numeric(cellAnnotation==thisType)
      pCellType <- pCellType/sum(pCellType)
      .calcRSS.oneRegulon(pRegulon, pCellType)
    })
  )
  rss <- do.call(cbind, rss)
  colnames(rss) <- cellTypes
  return(rss)
}

Kind regards, Saeed

chenx9 commented 1 year ago
1674791600383

When I load the function you mentioned, the following problem occurs

Bathroomboss commented 1 year ago

I had the same problem, but i solved it by updating scenic version to 1.3.1

amateur-boy commented 1 year ago

I had the same problem, but i solved it by updating scenic version to 1.3.1

where to download SCENIC of 1.3.1?thanks!

Bathroomboss commented 1 year ago

sorry, I can't remember exactly. Mabey you can try this commond. devtools::install_github("aertslab/SCENIC")