aertslab / AUCell

AUCell: score single cells with gene regulatory networks
110 stars 26 forks source link

aucellRankings - merging two object #5

Closed ltosti closed 5 years ago

ltosti commented 5 years ago

Hi,

Is there a way to merge two aucellRankings objects coming from one dataset that was initially split in two?

Thank you!

s-aibar commented 5 years ago

Dear @ltosti ,

To merge two objects you can concatenate the columns (e.g. cbind on the cells_rankings@assays[["ranking"]] or getRanking(cells_rankings)).

I have also just added a cbind function that will do this. It is already available in Github, but it will take a few days to be updated in Bioc_devel.

Thanks for the feedback!

ltosti commented 5 years ago

Dear @s-aibar ,

Thank you for your help, I did manage to merge the objects using cells_rankings@assays[["ranking"]] . However, when I went ahead with the subsequent step AUCell_calcAUC I got the following error:

Error in dimnames(assay) <- `*vtmp*` : 
  length of 'dimnames' [2] not equal to array extent
Calls: AUCell_calcAUC ... endoapply -> lapply -> lapply -> lapply -> lapply -> FUN
Execution halted

Do you think this error is caused by the merging?

Thank you!

s-aibar commented 5 years ago

Dear @ltosti ,

There is probably something wrong with the way you concatenated the rankings or created the new object (probably related to the dimnames...?).

Would you mind installing the latest version of the package and try the new cbind function? I have double-checked it and that one seems to work...

You can install it from Github or Bioconductor (devel):

install.packages("https://bioconductor.org/packages/devel/bioc/src/contrib/AUCell_1.7.1.tar.gz", repos=NULL, source=TRUE)
ltosti commented 5 years ago

Hi @s-aibar ,

I tried to use the new cbind function on two objects (Formal class 'aucellResults' [package "AUCell"] with 6 slots) but I get the following error:

Error in slot(object, slot_name) : 
  cannot get a slot ("assays") from an object of type "list"

Did I do something wrong?

s-aibar commented 5 years ago

Hello @ltosti ,

Sorry, there was something wrong with the namespace of the new cbind function... I think it should now work. You can test the new version with this code:

# Install and load
devtools::install_github("aertslab/AUCell")
library(AUCell)
packageVersion("AUCell") == "1.7.2"

# Create rankings
set.seed(123)
exprMatrix <- matrix(data=sample(c(rep(0, 5000), sample(1:3, 5000, replace=TRUE))),
                     nrow=20, 
                     dimnames=list(paste("Gene", 1:20, sep=""), 
                                   paste("Cell", 1:500, sep="")))
sample1 <- exprMatrix[,1:100]
sample2 <- exprMatrix[,101:500]
cells_rankings1 <- AUCell_buildRankings(sample1)
cells_rankings2 <- AUCell_buildRankings(sample2)

# Merge
cbind(cells_rankings1, cells_rankings2)
ltosti commented 5 years ago

Hi @s-aibar ,

Yes, this works also on my objects. Thank you very much for your help!