aertslab / SCopeLoomR

R package (compatible with SCope) to create generic .loom files and extend them with other data e.g.: SCENIC regulons, Seurat clusters and markers, ...
MIT License
38 stars 15 forks source link

Adding SCENIC AUC matrix is not working #39

Open saeedfc opened 1 year ago

saeedfc commented 1 year ago

Hi, Thanks you for Scope and ScopeLoomR. I tried the following code to add the AUC_Matrix. The loom file works, but I cannot visualize any regulon activity in scope.

library(Seurat)
library(SCopeLoomR)
exp_mtx <- GetAssayData(obj, assay = "RNA", slot = "data")
exp_mtx <- as.matrix(exp_mtx)
## Read in the auc matrix obtained ferom pySCENIC pipeline
scenic_mtx <- read.csv(paste0("../REGA_Lungs/output/", auc_files[1]), row.names = 1)
## Remove the appended '...' character at the end of regulon names
colnames(scenic_mtx) <- gsub(pattern = "\\.\\.\\.$", replacement = "", colnames(scenic_mtx))
## Prepend "TF_" to regulon names
colnames(scenic_mtx)  <- paste0("TF_", colnames(scenic_mtx) )

build_loom(
  file.name=file.name,
  dgem=exp_mtx,
  title=obj_name[i], # A namr for your data
  genome="Mouse", # Just for user information, not used internally
  default.embedding=umap_mtx,
  default.embedding.name="Seurat_UMAP"
)

loom <- open_loom(file.name, mode = 'r+')

add_regulons_AUC(
    loom,
    t(scenic_mtx),
    column.attr.name="MotifRegulonsAUC") 

close_loom(loom= loom)

instead add_regulon_AUC, I also tried the function add_scenic_regulons_auc_matrix(loom=loom, regulons.AUC = t(scenic_mtx))

t(scenic_mtx) is a matrix with same cells as columns and regulons(TFs) as rows. Code runs without any error. I can open the file in Scope. I can see the gene expression. But when I type transcription factor names, I cannot see anything other than genes ( I mean cannot see regulons). As you might notice, the regulons all start with "TF_", so in theory when i try to type "TF.." in the field in scope, it should pop down with regulon names. Also, I cannot see anything if I go to the 'regulon' tab on scope.

I also tried without adding "TF_" in auc matrix regulon names. In such cases, If I type a transcription factor name, I should in theory see the gene in 'gene' category and 'regulon' category.

I cannot figure out, what could be going wrong.

Is there an alternative to add AUC matrix as an additional assay (I tried with add_matrix function. But didn't work)?