# How do I download specific cell type gene expression data from WHB?

**URL:** https://community.brain-map.org/t/how-do-i-download-specific-cell-type-gene-expression-data-from-whb/3648
**Category:** Technical
**Tags:** software, atlas-cell-types, celltype, transcriptomics, analysis, human, how-to, atlas-human-brain-adult
**Created:** [September 6, 2024, 12:00am UTC](https://community.brain-map.org/t/how-do-i-download-specific-cell-type-gene-expression-data-from-whb/3648 "2024-09-06T00:00:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![atown](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@atown](https://community.brain-map.org/u/atown)
#### Post date: [September 6, 2024, 12:00am UTC](https://community.brain-map.org/t/how-do-i-download-specific-cell-type-gene-expression-data-from-whb/3648/1 "2024-09-06T00:00:18Z")

</div>

Thank you for the Allen Brain cell atlas data access tool! Is there a way to download a subset of the gene expression raw data? For example, looking at a specific cell type of interest such as Astrocytes. I saw that you have the capability to download a subset of genes, but I’d like to download the whole gene expression raw data for a given cell type. Thanks for your time/help.

---

<div class="post-metadata">

### Author: ![morriscb](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/morriscb/32/736_2.png) [@morriscb](https://community.brain-map.org/u/morriscb)
#### Post date: [September 9, 2024, 5:11pm UTC](https://community.brain-map.org/t/how-do-i-download-specific-cell-type-gene-expression-data-from-whb/3648/2 "2024-09-09T17:11:09Z")

</div>

Hi,

Good question. Unfortunately the files of the data aren’t structured in such a way that you can only download a given cell type. The human brain data are stored as two files (neurons vs non-neurons) while the mouse brain data are stored by assay and dissection. You’ll have to download the full dataset access what you are looking for.

That said, you should be able access the cells once you have the files downloaded. The genes are a bit more difficult to access hence examples, however for cell data things are more straight forward. If you follow the [WHB part 2 tutorial](https://github.com/AllenInstitute/abc_atlas_access/blob/main/notebooks/WHB-10x_snRNASeq_tutorial_part_2.ipynb) to create the cell\_extended table, you will be able to create a table of cells that are in the supercluster supercluster Astrocyte by selecting only rows with the value Astrocyte. You can then use the cell\_id/indexes of the cell table you’ve just created to index into the anndata file. There’s example of loading the anndata and slicing the file in the first few cells of [this notebook](https://alleninstitute.github.io/abc_atlas_access/notebooks/merfish_imputed_genes_example.html). You’ll just need to change the files you are loading and change the slicing in the 10th cell of that notebook (the one that creates `gene_subset`) from column major `[:, gene_index]` to row major `[cell_index, :]`.

The operations I described above are pretty standard in [Pandas](https://pandas.pydata.org/), [Numpy](https://numpy.org/), and [anndata](https://anndata.readthedocs.io/en/latest/). Check out tutorials and documentation on those libraries if you are not already familiar.

Good luck!

---

<div class="post-metadata">

### Author: ![atown](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@atown](https://community.brain-map.org/u/atown)
#### Post date: [September 9, 2024, 6:34pm UTC](https://community.brain-map.org/t/how-do-i-download-specific-cell-type-gene-expression-data-from-whb/3648/3 "2024-09-09T18:34:58Z")

</div>

Yep, that is exactly what I am doing now to get a cell-type specific gene expression matrix. Just wanted to double check there wasn’t functionality to do this already. Thanks so much for your help/time!
