In [ ]:
import os
import numpy as np
import anndata as ad
import pandas as pd
import scanpy as sc
import copy
import warnings
from datetime import datetime

sc.settings.n_jobs = 32
warnings.filterwarnings("ignore")

pwd = os.getcwd()

Update 1 - 2023-05-05: Add CPS and rename Microglia-PVM/VLMC supertypes¶

In [ ]:
region = "MTG"
date = "2022-08-18"
adata = sc.read_h5ad(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_all-nuclei." + date + ".h5ad"))
In [ ]:
adata.obs["Supertype"].cat.rename_categories(
    {
        "VLMC_2": "Pericyte_1",
        "VLMC_2_1-SEAAD": "SMC-SEAAD",
        "VLMC_2_2-SEAAD": "Pericyte_2-SEAAD",
        "Micro-PVM_2_2-SEAAD": "Lymphocyte",
        "Micro-PVM_1_1-SEAAD": "Monocyte"
    },
    inplace=True
)
In [ ]:
CPS = pd.read_csv(os.path.join(pwd, "input", region, "donor_name_CPS.csv"), index_col=0)
adata.obs = adata.obs.merge(CPS, left_on="Donor ID", right_index=True, how="left")
adata.write(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_all-nuclei." + str(datetime.date(datetime.now())) + ".h5ad"), compression="gzip")
In [ ]:
region = "MTG"
date = "2022-08-18"
adata = sc.read_h5ad(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_final-nuclei." + date + ".h5ad"))
In [ ]:
adata.obs["Supertype"].cat.rename_categories(
    {
        "VLMC_2": "Pericyte_1",
        "VLMC_2_1-SEAAD": "SMC-SEAAD",
        "VLMC_2_2-SEAAD": "Pericyte_2-SEAAD",
        "Micro-PVM_2_2-SEAAD": "Lymphocyte",
        "Micro-PVM_1_1-SEAAD": "Monocyte"
    },
    inplace=True
)
In [ ]:
CPS = pd.read_csv(os.path.join(pwd, "input", region, "donor_name_CPS.csv"), index_col=0)
adata.obs = adata.obs.merge(CPS, left_on="Donor ID", right_index=True, how="left")
adata.write(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_final-nuclei." + str(datetime.date(datetime.now())) + ".h5ad"), compression="gzip")

Update 2 - 2024-02-13: Add real ages for donors over 90 years old, full APOE4 genotypes, and whether a donor was severely affected. Also releasing donor-specific h5ad objects.¶

In [ ]:
region = "MTG"
date = "2023-05-05"
adata = sc.read_h5ad(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_all-nuclei." + date + ".h5ad"))
In [ ]:
metadata = pd.read_excel(
    os.path.join(pwd, "input", region, "Supplementary Table 1.xlsx"),
    sheet_name="SEA-AD_Cohort_Metadata",
    index_col=0
)
updated_metadata = adata.obs.loc[:, ["Donor ID"]].merge(
    metadata.loc[:, ["Age at Death", "APOE Genotype", "Severely Affected Donor"]].fillna("N"),
    left_on="Donor ID",
    right_index=True,
    how="left"
)

adata.obs["Age at Death"] = updated_metadata["Age at Death"].copy()
adata.obs["APOE4 Status"] = updated_metadata["APOE Genotype"].copy()
adata.obs = adata.obs.rename(
    {"APOE4 Status": "APOE Genotype"},
    axis=1,
)
adata.obs["Severely Affected Donor"] = updated_metadata["Severely Affected Donor"].copy()
In [ ]:
adata.write(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_all-nuclei." + str(datetime.date(datetime.now())) + ".h5ad"), compression="gzip")
In [ ]:
region = "MTG"
date = "2023-05-05"
adata = sc.read_h5ad(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_final-nuclei." + date + ".h5ad"))
In [ ]:
metadata = pd.read_excel(
    os.path.join(pwd, "input", region, "Supplementary Table 1.xlsx"),
    sheet_name="SEA-AD_Cohort_Metadata",
    index_col=0
)
updated_metadata = adata.obs.loc[:, ["Donor ID"]].merge(
    metadata.loc[:, ["Age at Death", "APOE Genotype", "Severely Affected Donor"]].fillna("N"),
    left_on="Donor ID",
    right_index=True,
    how="left"
)

adata.obs["Age at Death"] = updated_metadata["Age at Death"].copy()
adata.obs["APOE4 Status"] = updated_metadata["APOE Genotype"].copy()
adata.obs = adata.obs.rename(
    {"APOE4 Status": "APOE Genotype"},
    axis=1,
)
adata.obs["Severely Affected Donor"] = updated_metadata["Severely Affected Donor"].copy()
In [ ]:
adata.write(os.path.join(pwd, "output", region, "SEAAD_MTG_RNAseq_final-nuclei." + str(datetime.date(datetime.now())) + ".h5ad"), compression="gzip")
In [ ]:
for i in adata.obs["Donor ID"].cat.categories:
    print(i)
    adata[adata.obs["Donor ID"] == i].write(os.path.join(pwd, "output", region, "donor_objects", i + "_SEAAD_MTG_RNAseq_final-nuclei." + str(datetime.date(datetime.now())) + ".h5ad"), compression="gzip")

BREAKING UPDATE - 2026-06-22: Re-release of MTG as part of Multiregion dataset¶

Our multiregional data release encompasses 10 neo- and allo-cortical brain regions that span the cortical arc of AD neuropathological staging. Briefly, the data include include previously released nuclei from the middle temporal gyrus (MTG) and prefrontal cortex (PFC/A9) (see https://www.nature.com/articles/s41593-024-01774-5), and 8 additional regions:

  • Hippocampus (HIP)
  • Medial entorhinal cortex (MEC)
  • Lateral entorhinal cortex (LEC)
  • Inferior temporal gyrus (ITG)
  • Superior temporal gyrus (STG)
  • Frontal insula (FI)
  • Angular gyrus (AnG)
  • Primary visual cortex (V1C)

All 84 donors from the previous MTG release had their MTG, DFC, and MEC profiled, while the remaining regions were profiled in a subset of 43 donors without severe co-morbidities (our "AD Spectrum" donors).

The new AnnData files follow the same format as prior releases, but have a few breaking changes:

Taxonomy changes: Nuclei from every region were mapped to the SEA-AD MTG/PFC taxonomy to hierarchically assign a major cell "Class", a "Subclass" underneath it, and a mappable, fine-grained cell "Supertype" below that. The previous taxonomy has been expanded to include new types that were not present in the previous MTG/PFC taxonomy (e.g. region-specific excitatory types in HIP, MEC, and V1C), cell labels that are common across regions are retained (e.g. Sst_25 still refers to the same kind of cell type in the updated taxonomy). A very small number of MTG nuclei were assigned a new cell type annotation as part of this process. The cell type colors have been updated to account for new types in AnnData.uns["Supertype_colors"].

Quality control changes: A small number of nuclei that were not flagged by quality control cutoffs in the initial release have been flagged and removed in the final-nuclei objects in this new release.

Embedding changes: AnnData.obsm["X_scVI"] & AnnData.obsm["X_umap"] Now contains to the latent space and umap projection computed from the entire Multiregional dataset.

Gene information changes: We now include the ensembl_id and gene_name for every feature in AnnData.var

If you notice any other issues with this update, please report them to https://community.brain-map.org/

In [ ]: