# Pseudotime Inference

## Overview

This block takes precomputed PCA embeddings and clustering assignments from upstream blocks and calculates a pseudotime trajectory, a measure of each cell’s progression along a biological process like differentiation. It outputs a pseudotime value per cell and visualizes the results with UMAP and violin plots.

## Pipeline context

This block requires both PCA embeddings and cluster assignments. It follows both `Dimensionality Reduction` and `Leiden Clustering`.

```plaintext
 Blocks                                 Result pool
                                       ┌───────────
             ┌─────────────────────────┤
             │                         │
             v                         │
 ╔═══════════════════════════╗ exports │
 ║ Dimensionality Reduction /║────->─-─┤ Embeddings & Clusters
 ║     Leiden Clustering     ║         │ -----------------------
 ╚═══════════════════════════╝         │
                                       ├ [sampleId][cellId] -> pcValue, clusterId
             ┌─────────────────────────┤
             │                         │
             v                         │
 ╔═══════════════════════════╗ exports │
 ║   Pseudotime Inference    ║────->─-─┤ Pseudotime scores
 ╚═══════════════════════════╝         │ -------------------
                                       ├ [sampleId][cellId] -> pseudotime
             ┌─────────────────────────┤
             │                         │
             v                         │
 ╔═══════════════════════╗             │
 ║  Downstream Analysis  ║             │
 ╚═══════════════════════╝             │
```

## Core structure: axes and p-columns

The block consumes PCA embeddings and cluster assignments to produce a p-column containing a pseudotime value for each cell.

### Input p-columns

The block requires two main inputs: principal component embeddings and cluster assignments.

#### 1. Principal Components

- **P-column name**: `pl7.app/rna-seq/pcvalue`
- **Description**: The value for a given principal component for each cell.
- **Requirement**: **Required**.

```yaml
# --- Core Identity ---
name: pl7.app/rna-seq/pcvalue
valueType: Double


# --- Axes ---
axesSpec:
  - name: pl7.app/sampleId
    type: String
  - name: pl7.app/sc/cellId
    type: String
  - name: pl7.app/rna-seq/pc-num
    type: String


# --- Domain ---
domain:
  pl7.app/blockId: "..." # blockId from the upstream dimensionality reduction run
  pl7.app/rna-seq/batch-corrected": "false"


# --- Annotations ---
annotations:
  pl7.app/label: "Principal Component Value"
```

#### 2. Leiden Cluster

- **P-column name**: `pl7.app/rna-seq/leidencluster`
- **Description**: The cluster assignment for each cell.
- **Requirement**: **Required**.

```yaml
name: pl7.app/rna-seq/leidencluster
valueType: String
axesSpec:
  - name: pl7.app/sampleId
    type: String
  - name: pl7.app/cellId
    type: String
```

### Exported P-Columns

The block exports a p-frame containing the new `pseudotimedpt` p-column for programmatic use by downstream blocks.

#### 1. Pseudotime Score

- **P-column name**: `pl7.app/rna-seq/pseudotimedpt`
- **Description**: The calculated pseudotime value, representing a cell’s progress along a trajectory.
- **Requirement**: **Required**.
- **Specification**:

```yaml
# --- Core Identity ---
name: pl7.app/rna-seq/pseudotimedpt
valueType: Double


# --- Axes ---
axesSpec:
  - name: pl7.app/sampleId
    type: String
  - name: pl7.app/cellId
    type: String


# --- Domain ---
domain:
  pl7.app/blockId: "..." # a unique identifier for the block run


# --- Annotations ---
annotations:
  pl7.app/label: "Pseudotime Scores"
```

## Summary of Exported P-Columns

| P-Column Name                   | Description                      | Axes                 | Requirement  |
| :------------------------------ | :------------------------------- | :------------------- | :----------- |
| `pl7.app/rna-seq/pseudotimedpt` | The calculated pseudotime value. | `[sampleId][cellId]` | **Required** |

Source: https://docs.platforma.bio/sdk-pseudotime-inference/
