Deck 15: Adding Metadata, Coordinates, and Saving

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/5

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:09 PM on 9/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

6 Terms

1
New cards

What does adata.obs['log_n_genes'] = np.log1p(adata.obs['n_genes']) do?

  • Adds a new column to the .obs DataFrame

    • Same mechanism as adding a column to any pandas DataFrame.


2
New cards

What's the difference between what .obs and .obsm store per cell?

  • .obs holds a single value per cell (a category, count, percentage)

  • .obsm holds a small array per cell (e.g. an x,y pair, or PCA/UMAP coordinates).


3
New cards

What shape is adata.obsm['spatial']?

(n_cells, 2) → x,y coordinates per cell

4
New cards

What shape is adata.obsm['X_pca']?

(n_cells, 50) → PCA coordinates.

5
New cards

What does adata.write_h5ad('my_data.h5ad') save?

Everything in the object in one file (X, .obs, .var, .obsm, .uns, .layers) in one round trip.

6
New cards

Why is saving everything in one .h5ad file better than saving separate files for each piece?

It avoids having to separately save and reload multiple files and hope they stay aligned with each other.