AlineTalhouk / diceR

Diverse Cluster Ensemble in R
https://alinetalhouk.github.io/diceR/
Other
34 stars 10 forks source link

extracting gene list from a specific cluster #158

Closed aniketbroad2604 closed 2 years ago

aniketbroad2604 commented 2 years ago

I am having trouble in extracting the gene list which belong to a specific cluster. Is there a code or function which is already present to extract the genes?

dchiu911 commented 2 years ago

Hi @aniketbroad2604 please try the following reprex. If your input matrix data has rownames, then the resulting final assignment matrix will also show the mapping in the clusters element of obj. If you are interested in clustering genes instead of samples the input can be transposed.

library(diceR)
data(hgsc)
hgsc <- hgsc[1:100, 1:50]
obj <- dice(
  hgsc,
  nk = 4,
  reps = 5,
  algorithms = c("ap", "sc", "block", "som", "cmeans", "hdbscan"),
  cons.funs = c("kmodes", "majority")
)
#> Selecting k and imputing non-clustered cases
#> Computing consensus functions
#> Evaluating output with consensus function results
#> Diverse Cluster Ensemble Completed
head(obj$clusters)
#>                     kmodes majority
#> TCGA.04.1331_PRO.C5      2        2
#> TCGA.04.1332_MES.C1      1        2
#> TCGA.04.1336_DIF.C4      4        1
#> TCGA.04.1337_MES.C1      1        1
#> TCGA.04.1338_MES.C1      4        4
#> TCGA.04.1341_PRO.C5      2        2

obj_t <- dice(
  t(hgsc),
  nk = 4,
  reps = 5,
  algorithms = c("ap", "sc", "block", "som", "cmeans", "hdbscan"),
  cons.funs = c("kmodes", "majority")
)
#> Selecting k and imputing non-clustered cases
#> Computing consensus functions
#> Evaluating output with consensus function results
#> Diverse Cluster Ensemble Completed
head(obj_t$clusters)
#>        kmodes majority
#> ABAT        3        1
#> ABHD2       1        1
#> ACTB        1        1
#> ACTR2       3        1
#> ACTR5       1        1
#> ACVR2A      3        1

Created on 2022-08-16 by the reprex package (v2.0.1)