Deck 8 and Deck 9: Adding Columns and Chaining + What AnnData Is

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/8

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:26 PM on 8/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

9 Terms

1
New cards

What does df['log_n_genes'] = np.log1p(df['n_genes']) do if log_n_genes doesn't exist yet?

Creates a new column with that name; if it already existed, it would be overwritten.

2
New cards

What does each step in this chain return, and why does that let you call the next method directly?

top_cells = (

df[df['pct_mito'] < 10]

.sort_values('n_genes', ascending=False)

.head(10)

)

Each step (df[...], .sort_values(), .head()) returns a new DataFrame, so the next method can be called immediately without an intermediate variable.

3
New cards

How does this pandas chaining pattern relate to SpatialData plotting calls like sdata.pl.render_shapes(...).pl.render_points(...).pl.show()?

Same underlying principle → each call returns something you can keep calling methods on but just applied to a different set of methods.

4
New cards

What is AnnData designed to bundle together, beyond just a count matrix?

The count matrix (cells × genes) plus metadata about cells, metadata about genes, and derived results (PCA, UMAP, clustering) → all kept aligned with each other.

5
New cards

Why not just use separate DataFrames for the count matrix and cell metadata?

  • Filtering out low-quality cells would require manually keeping every separate DataFrame in sync

  • AnnData bundles them so filtering keeps everything aligned automatically.


6
New cards

In X = np.random.poisson(1, size=(100, 2000)), what do the two dimensions represent?

100 rows = cells/observations; 2000 columns = genes/variables.

7
New cards

What does adata.obs_names = [...] set?

Names/labels for each cell (observation).

8
New cards

What does adata.var_names = [...] set?

Names/labels for each gene (variable).

9
New cards

What is AnnData's axis order convention?

(n_obs, n_vars) → observations (cells) first, variables (genes) second.