pegasus.net_fle

pegasus.net_fle(data, file_name=None, n_jobs=- 1, rep='diffmap', K=50, full_speed=False, target_change_per_node=2.0, target_steps=5000, is3d=False, memory=8, random_state=0, select_frac=0.1, select_K=25, select_alpha=1.0, net_alpha=0.1, polish_target_steps=1500, out_basis='net_fle')[source]

Construct Net-Force-directed (FLE) graph.

Net-FLE is an approximated FLE graph using Deep Learning model to improve the speed.

In specific, the deep model used is MLPRegressor, the scikit-learn implementation of Multi-layer Perceptron regressor.

See [Li20] for details.

Parameters
  • data (pegasusio.MultimodalData) – Annotated data matrix with rows for cells and columns for genes.

  • file_name (str, optional, default: None) – Temporary file to store the coordinates as the input to forceatlas2. If None, use tempfile.mkstemp to generate file name.

  • n_jobs (int, optional, default: -1) – Number of threads to use. If -1, use all physical CPU cores.

  • rep (str, optional, default: "diffmap") – Representation of data used for the calculation. By default, use Diffusion Map coordinates. If None, use the count matrix data.X.

  • K (int, optional, default: 50) – Number of nearest neighbors to be considered during the computation.

  • full_speed (bool, optional, default: False) –

    • If True, use multiple threads in constructing hnsw index. However, the kNN results are not reproducible.

    • Otherwise, use only one thread to make sure results are reproducible.

  • target_change_per_node (float, optional, default: 2.0) – Target change per node to stop ForceAtlas2.

  • target_steps (int, optional, default: 5000) – Maximum number of iterations before stopping the ForceAtlas2 algorithm.

  • is3d (bool, optional, default: False) – If True, calculate 3D force-directed layout.

  • memory (int, optional, default: 8) – Memory size in GB for the Java FA2 component. By default, use 8GB memory.

  • random_state (int, optional, default: 0) – Random seed set for reproducing results.

  • select_frac (float, optional, default: 0.1) – Down sampling fraction on the cells.

  • select_K (int, optional, default: 25) – Number of neighbors to be used to estimate local density for each data point for down sampling.

  • select_alpha (float, optional, default: 1.0) – Weight the down sample to be proportional to radius ** select_alpha.

  • net_alpha (float, optional, default: 0.1) – L2 penalty (regularization term) parameter of the deep regressor.

  • polish_target_steps (int, optional, default: 1500) – After running the deep regressor to predict new coordinate, Number of ForceAtlas2 iterations.

  • out_basis (str, optional, default: "net_fle") – Key name for calculated FLE coordinates to store.

Return type

None

Returns

  • None

  • Update data.obsm

    • data.obsm['X_' + out_basis]: Net FLE coordinates of the data.

  • Update data.obs

    • data.obs['ds_selected']: Boolean array to indicate which cells are selected during the down sampling phase.

Examples

>>> pg.net_fle(data)