Skip to content

load_data

load_data(path, nsamples, genes, time_key, cell_type_key=None, exclude_times=None, seed=0, normalize=False, plot_total_counts=False, min_tot_counts=0.0, max_tot_counts=100.0)

Load AnnData snapshots and sample a fixed number of cells per time.

Cells are globally filtered by total counts across selected genes before per-time subsampling: keep cells with total counts in [min_tot_counts, max_tot_counts].

Parameters:

  • path (str) –

    Either a local path to the .h5ad/.h5ad.gz dataset, or one of {"natcomm", "kaggle"} to fetch from DATA_URLS.

  • nsamples (int) –

    Number of cells sampled at each time point.

  • genes (list of str) –

    Selected genes used to build expression snapshots.

  • time_key (str) –

    Name of the observation column storing time labels.

  • cell_type_key (str, default: None ) –

    Name of the observation column storing cell-type labels.

  • exclude_times (scalar or sequence, default: None ) –

    Time value(s) to exclude before filtering and subsampling. If None, all time points are kept.

  • seed (int, default: 0 ) –

    Random seed for snapshot subsampling.

  • normalize (bool, default: False ) –

    If True, normalize each cell by its total counts and rescale by 1e4 before gene selection and subsampling.

  • plot_total_counts (bool, default: False ) –

    If True, plot per-time-point histograms of per-cell total counts (over selected genes) before filtering and subsampling.

  • min_tot_counts (float, default: 0.0 ) –

    Minimum total-count threshold (strict).

  • max_tot_counts (float, default: 100.0 ) –

    Maximum total-count threshold (strict).

Returns:

  • samples ( ndarray of shape (n_times, nsamples, n_genes) ) –

    Subsampled expression snapshots.

  • unique_times ( ndarray of shape (n_times,) ) –

    Unique times present in the dataset.

  • ind_array ( ndarray of shape (n_times, nsamples), optional ) –

    Encoded cell-type labels for sampled cells. Returned only when cell_type_key is not None.

  • cell_types ( (Series, optional) ) –

    Full cell-type annotation column. Returned only when cell_type_key is not None.