UBod / apcluster

R package implementing affinity propagation clustering along with various utilities
https://github.com/UBod/apcluster
9 stars 8 forks source link

a question about `apcluster` #3

Closed QianhuiWan closed 5 years ago

QianhuiWan commented 5 years ago

Hi, I am using apcluster and found this error, it's probably because the matrix is too large, is there a way to deal with big matrix when using apcluster? Thank you so much.

s2 <- corSimMat(Placenta_betaNorm_sig, sel=NA, r=1, signed=TRUE, method="pearson")

apres1a <- apcluster(s2)

Error in which(s > -Inf) : 
  long vectors not supported yet: ../../src/include/Rinlinedfuns.h:519
UBod commented 5 years ago

As the error message suggests, the apcluster() function cannot handle long vectors (i.e. indexed R data objects with f 2^31 or more elements). My answer is simple: this is currently not implemented, and we do not have any resources to implement that feature. I suggest to use leveraged AP instead (function apclusterL() that is also included in the package). This is an iterative method that clusters all samples, but only considers a sub-sample of possible exemplars which are refined iteratively. A little example: if you use 'frac=0.05', this means that you use 5% of samples as potential exemplars. The similarity matrix that is computed internally then is only 5% as large as it would be otherwise, which is quite easy to handle. The 'sweeps' parameter controls how many iterative refinement runs you make. For more information, see the package documentation. I hope that helps.

QianhuiWan commented 5 years ago

Very helpful, thank you so much!