Harmony icon indicating copy to clipboard operation
Harmony copied to clipboard

Meaning and function of the `n_components` parameter

Open Marius1311 opened this issue 5 years ago • 1 comments

Harmony has a n_components parameter, which, according to the docstring:

:param pc_components: Minimum number of principal components to use. Specify `None` to use pre-computed components

That value is used for utils.run_pca, but it's not passed over to scanpy's neighboor computation, see https://github.com/dpeerlab/Harmony/blob/eca0771348e7f1b901f95d1a8fc68d95530e830c/src/harmony/core.py#L67

So I wonder what the significance of that parameter actually is?

Also, I find the default value of 1000 a bit high, as scanpy's default here is much smaller, 50 I believe

Marius1311 avatar May 25 '20 13:05 Marius1311

The n_components parameter is used below https://github.com/dpeerlab/Harmony/blob/eca0771348e7f1b901f95d1a8fc68d95530e830c/src/harmony/core.py#L48 to compute the principal components.

In line 67, temp is already pre-computed principal components and thus the parameter is not passed for nearest neighbor computation.

ManuSetty avatar May 25 '20 18:05 ManuSetty