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
412 stars 94 forks source link

Error when plotting regulon activity by cell type #139

Open KatjaRM opened 4 years ago

KatjaRM commented 4 years ago

Hi everyone,

I am trying to plot regulon activity using the code provided in the vignette. When I try to run

regulonActivity_byCellType <- sapply(split(rownames(cellInfo), cellInfo$seuratCluster), function(cells) rowMeans(getAUC(regulonAUC)[,cells]))

I get the error

Error in base::rowMeans(x, na.rm = na.rm, dims = dims, ...) : 'x' must be an array of at least two dimensions

I checked that my cells are named similarly and they are all present in the cellInfo. No cells are missing in cellInfo.

Here is head(cellInfo)

                                          seuratCluster     nGene nUMI

dataset2_AAAGTAGGTACGACCC 25 1790 5693 dataset2_AACTGGTCAACACCCG 24 1909 6369 dataset2_AAGGAGCAGATATACG 24 2046 8431 dataset2_ACATCAGTCTACCAGA 25 2043 7201 dataset2_ACCAGTAGTGGTCTCG 24 2061 6361 dataset2_ACGATGTCATGTAGTC 24 2586 9339

I think the error is potentially about regulonAUC, but cannot quite figure out where exactly.

getAUC(regulonAUC) returns the cell names matching to cellInfo, as it should and rowMeans(getAUC(regulonAUC) returns the averages for the regulons

Does anyone have any idea what could be wrong? Help would be greatly appreciated!

Best,

Katja

luca8651 commented 4 years ago

I have the same issue! Did you manage to solve it?

KatjaRM commented 4 years ago

I did not. Weirdly it happened with only one specific dataset but not with other ones. In the end I used a very annoying and time consuming workaround involving excel sheets that worked out, where I averaged everything myself and then reloaded the data back into R.

luca8651 commented 4 years ago

Hi Katja. Thanks for your reply! I have actually found out what was causing the error. I was trying to do exactly the same, that is looking at regulon activity between Seurat clusters. However, my set of cells did not match the clusters perfectly, and one cluster was represented by just one cell. This caused the error because, when selecting a single cell, I was getting an object "NULL" dimensions and passing it to "rowMeans". The fix (at least for me) is actually easy:

regulonActivity_byCellType <- sapply(split(rownames(cellInfo), cellInfo$seuratCluster),

I am sorry that you had to use a complex workaround, but I hope this answer is helpful anyway :)

KatjaRM commented 4 years ago

Thank you! That helps!!! :)

apal6 commented 3 weeks ago

Hi,

I am not able to run this for some reason, here's my code and error, can someone help? Thanks

regulonActivity_byCellType <- sapply(cellInfo$seuratCluster,
+                                      function(Cell) rowMeans(getAUC(auc_mtx)[,Cell]))
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'rowMeans': could not find function "getAUC"