Scanpy, UMAP and t-SNE with an AI agent

Scanpy is a widely used Python toolkit for single-cell analysis. UMAP and t-SNE are the two plots most people use to look at the result. An AI agent can run this workflow from a plain request. This post shows what the steps are and how to read the plots with care.

What is Scanpy?

Scanpy is an open-source Python library for single-cell RNA-seq data. It reads a table of gene counts per cell, filters out poor cells, normalizes the counts, groups similar cells, and finds marker genes. Many papers and tutorials use it, so an AI agent already knows its common patterns.

The Scanpy workflow, step by step

  1. Load the data. Read the counts and the cell and gene names.
  2. Quality control. Remove cells with very few genes or a high share of mitochondrial reads.
  3. Normalize. Scale counts so cells with different depth are comparable.
  4. Pick variable genes. Keep the genes that differ most between cells.
  5. Reduce dimensions. Run PCA, then build a neighbor graph.
  6. Cluster. Group cells that look alike.
  7. Embed. Make the UMAP or t-SNE plot.
  8. Find markers. Test which genes define each cluster.

An AI agent can do all eight from one request, such as "load this dataset, filter low-quality cells, cluster, and show me a UMAP colored by cluster." Ask it to show its code, so you can see each choice.

UMAP and t-SNE: what they show

Each cell has thousands of gene measurements. UMAP and t-SNE squeeze them into two numbers per cell, so you can draw a point on a page. Cells with similar expression land close together.

  • UMAP keeps more of the larger layout. It is fast and is the common default.
  • t-SNE focuses on local neighbors. It is good at separating small groups.

Both are pictures, not measurements. The same data can look different with other settings or a different random seed.

How to read these plots

  • Do not trust the distance between two far-apart groups.
  • Do not read the size of a cluster on the plot as its true size. Count the cells.
  • Color the plot by sample or batch. If clusters follow the batch, the signal may be technical.
  • Color by marker genes to check that a cluster label makes sense.

An agent can make these checks in seconds. Ask for them every time.

Use public data as a reference

A plot of your own sample is easier to judge next to a reference. Glass Bio hosts public single-cell data, and Astral shows public human single-cell clusters on one map. Our post on public and clinical single-cell datasets explains how to find samples to compare against.

Do it with a colleague

A UMAP is easier to judge when more than one person looks at it. In a shared workspace, the agent posts the plot and the code where your teammates can see them and reply. See collaborative AI agents in a team workspace. For the broader picture of what an agent can take on, read about the AI bioinformatician.

Marble is the Glass Bio agent for this kind of work.

Frequently asked questions

Can an AI agent run Scanpy for me?

Yes. An AI agent can write and run Scanpy code for quality control, clustering, UMAP, t-SNE, and differential expression. You should read the code and check the plots.

Should I use UMAP or t-SNE?

Both give a 2D picture of cell similarity. Use either to explore your data. Do not read distances between far-apart groups as exact, and do not use either picture alone as proof.

Do I need to know Python to use an AI agent for single-cell analysis?

No, but it helps. The agent writes the Python for you. Knowing a little makes it easier to review what it did.

Keep reading