cluster
Short Description
sm.tl.cluster
: This function allows users to cluster the dataset.
The function supports four clustering algorithm (kmeans, phenograph, leiden and parc).
Function
cluster(adata, method='kmeans', subset_genes=None, sub_cluster=False, sub_cluster_column='phenotype', sub_cluster_group=None, parc_small_pop=50, parc_too_big_factor=0.4, k=10, n_pcs=None, resolution=1, phenograph_clustering_metric='euclidean', nearest_neighbors=30, use_raw=True, log=True, random_state=0, collapse_labels=False, label=None, output_dir=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata |
AnnData Object |
required | |
method |
string
|
Clustering method to be used- Implemented methods- kmeans, phenograph, leiden and parc. |
'kmeans'
|
subset_genes |
list
|
Pass a list of genes ['CD3D', 'CD20', 'KI67'] that should be included for the purpose of clustering. By default the algorithm uses all genes in the dataset. |
None
|
sub_cluster |
bool
|
If the user has already performed clustering or phenotyping previously and would like to sub-cluster within a particular cluster/phenotype, this option can be used. |
False
|
sub_cluster_column |
string
|
The column name that contains the cluster/phenotype information to be sub-clustered. This is only required when sub_cluster is set to True. |
'phenotype'
|
sub_cluster_group |
list
|
By default the program will sub-cluster all groups within column passed through the argument sub_cluster_column. If user wants to sub cluster only a subset of phenotypes/clusters this option can be used. Pass them as list e.g. ["tumor", "b cells"]. |
None
|
parc_small_pop |
int
|
Smallest cluster population to be considered a community in PARC clustering. |
50
|
parc_too_big_factor |
float
|
If a cluster exceeds this share of the entire cell population, then the PARC will be run on the large cluster. at 0.4 it does not come into play. |
0.4
|
k |
int
|
Number of clusters to return when using K-Means clustering. |
10
|
n_pcs |
int)
|
Number of PC's to be used in leiden clustering. By default it uses all PC's. |
None
|
resolution |
float
|
A parameter value controlling the coarseness of the clustering. Higher values lead to more clusters. |
1
|
phenograph_clustering_metric |
string
|
Distance metric to define nearest neighbors. Note that performance will be slower for correlation and cosine. Available methods- cityblock’, ‘cosine’, ‘euclidean’, ‘manhattan’, braycurtis’, ‘canberra’, ‘chebyshev’, ‘correlation’, ‘dice’, ‘hamming’, ‘jaccard’, ‘kulsinski’, ‘mahalanobis’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘yule’ |
'euclidean'
|
nearest_neighbors |
int
|
Number of nearest neighbors to use in first step of graph construction. This parameter is used both in leiden and phenograph clustering. |
30
|
use_raw |
bool
|
If True, raw data will be used for clustering.
If False, normalized/scaled data within |
True
|
log |
bool
|
If |
True
|
random_state |
int
|
Change the initialization of the optimization. |
0
|
collapse_labels |
bool
|
While sub clustering only a few phenotypes/clusters, this argument helps to group all the other phenotypes/clusters into a single category- Helps in visualisation. |
False
|
label |
string
|
Key or optional column name for the returned data, stored in |
None
|
output_dir |
string
|
Path to output directory. |
None
|
Returns:
Name | Type | Description |
---|---|---|
adata |
AnnData Object
Returns an updated |
1 2 |
|
Source code in scimap/tools/_cluster.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|