Lee, Dalley et al. (2023) on dandiset 000636¶
Paper: Lee BR, Dalley R, et al. "Signature morphoelectric properties of diverse GABAergic interneurons in the human neocortex." Science 382, eadf6484 (2023), doi:10.1126/science.adf6484.
Dataset: DANDI:000636, "Human interneuron patch-seq electrophysiology", version 0.241120.0510 (doi:10.48324/dandi.000636/0.241120.0510): 706 NWB files, one neuron each, 109 donors, 24.5 GB. This is the only published version; the paper cites no version (its Data and materials availability says only that data "will be made available through BIL, DANDI, and NeMO"), so the most recent published version is pinned. Its content equals the draft's (same asset count and size).
Claims: claims/lee-2023.yaml, written from the author manuscript of the version of record (PMC12229143) and the bioRxiv preprint (doi:10.1101/2022.11.08.515739). This run had the version-of-record text only (paper/10.1126-science.adf6484.txt); its supplementary legends are missing.
Labels and other outside data come from the paper's code repository, AllenInstitute/human_patchseq_gaba at commit 5eb357a1cea246c7c847b5608a8fc7e87ea95b58: the per-cell metadata (labels, matched to files by nwb_id), the paper's feature table (used only to check the features computed here), the morphology feature table, the DBC calls, the channel gene list and the transcriptomes. The electrophysiology features are computed from the NWB files with IPFX.
| Claim | Data | Tested here |
|---|---|---|
| cell-metadata-link | labels | tested |
| dataset-composition | labels | tested |
| fig1b-more-genes-in-culture, figs1a-genes-across-days, fig1d-nms-no-difference, fig1c-marker-expression-correlated | code repository | tested |
| figs2d-seven-channel-genes | code repository | run; blocked (gene filter needs data not in the repository) |
| figs1-microglial-signature | code repository | run with a Python substitute for Seurat; blocked (readings disagree) |
| fig1e-wfdc2-transcriptome-overlap, figs1de-mapping-unaffected, fig2a-patchseq-overlaps-snrnaseq, fig3-frzb-transcriptome-intermediate | code repository, snRNA-seq | blocked (Seurat integration; snRNA-seq reference) |
| fig5a-dbc-two-ttypes, figs7a-dbc-regions, figs7a-dbc-markers, fig4d-calb1-genes-by-morphology | labels, code repository | tested |
| figs2b-wfdc2-ephys-43-of-84, fig1l-width-sag-differ, figs2c-no-change-with-days | dataset | run; blocked (unreleased features; readings disagree) |
| fig1i, fig2b, fig2f, fig2g, fig2h, fig3c, fig3e, figs6, fig4c, fig5c, fig5d-dbc-ephys-intermingled, figs5 | dataset with labels | tested |
| fig1g, fig2c, fig2e, fig3g, fig1h, fig5d-dbc-morph-umap | morphology feature table | tested |
| fig4a-calb1-morphology-types | morphology feature table | two of four traits tested |
| fig5b-merfish-layers | MERFISH | blocked; Patch-seq layers reported |
| fig5e-bouton-density, fig6b-species-morphology | images, mouse reconstructions | blocked |
| mouse-label-link, fig6c, fig6e, figs8b, figs9 | mouse data (Gouwens et al. 2020, dandiset 000020) | tested in species_lee_2023.ipynb |
The full extraction streams all 706 files and takes about 35 minutes.
Revised after the first verification: feature failures (non-positive input resistance or width) are set missing; the DBC neighbour claims read SST as Revised_subclass_label; figs1a uses the Genes_Detected column; the neighbour claims show the paper's 84-feature table as a variant; figs1, the Patch-seq layers of fig5b and two traits of fig4a are now run; the mouse claims are in a second notebook. Revised after the second verification: numbers in the conclusions corrected, the outputs behind three findings printed (the IPFX version, how Genes_Detected compares with thresholds, the microglial calls of the two tables), and changes of outcome proposed for fig2b-ephys-umap-subclasses and fig5d-dbc-morph-umap. Revised after the third verification: the proposed outcomes applied (fig2b blocked, fig5d-dbc-morph-umap not reproduced) and the numbers of their conclusions corrected to the printed outputs, with those of the copy the third round reviewed.
import time, zlib, resource, warnings, logging
import numpy as np, pandas as pd, requests
from scipy import stats
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import lee2023 as L
warnings.filterwarnings("ignore")
logging.disable(logging.WARNING)
pd.set_option("display.width", 200); pd.set_option("display.max_columns", 40)
KEY = "lee-2023"
def seed(claim, k=0):
"""Seed of a claim's generator (protocol, author step 3); k-th generator adds k."""
return zlib.crc32(f"{KEY}/{claim}".encode()) + k
SEED_OFFSETS = [0, 1000, 2000, 3000, 4000]
T0 = time.time()
Data¶
The asset list of the pinned version, the dandiset metadata, and the paper's tables from its code repository at commit 5eb357a (labels only; claim cell-metadata-link).
A = L.assets()
V = L.version_metadata()
meta = L.metadata_table()
fx_paper = L.code_table("LeeDalley_ephys_fx.csv")
morph = L.code_table("LeeDalley_morpho_features.csv")
dbc_tab = L.code_table("dbc_calb1_ADGRG6.csv")
FEATS84 = [c for c in fx_paper.columns if c != "specimen_id" and c not in L.CHIRP]
print("version", L.VERSION, "assets", len(A), "subjects", A.subject.nunique(), "sessions", A.session.nunique(),
"total GB", round(A["size"].sum() / 1e9, 2))
print("archive summary:", {k: V["assetsSummary"].get(k) for k in ["numberOfFiles", "numberOfSubjects", "numberOfCells"]})
print("metadata rows", len(meta), "unique specimens", meta.specimen_id_x.nunique(), "| feature table rows", len(fx_paper),
"| feature columns", fx_paper.shape[1] - 1, "of which chirp", len(L.CHIRP), "-> 84 =", len(FEATS84))
version 0.241120.0510 assets 706 subjects 109 sessions 706 total GB 24.47
archive summary: {'numberOfFiles': 706, 'numberOfSubjects': 109, 'numberOfCells': 616}
metadata rows 779 unique specimens 778 | feature table rows 704 | feature columns 93 of which chirp 9 -> 84 = 84
Feature extraction¶
Every NWB file is streamed and its long square, short square and ramp sweeps read; sweeps failing the Methods' QC are dropped, and IPFX computes the features (helper cell_features). This takes about 25 minutes.
t = time.time()
R = L.all_cell_features(A.asset_id.tolist(), workers=3)
R = A.merge(R, on="asset_id")
print(f"extraction {time.time() - t:.0f} s; peak memory of a worker {resource.getrusage(resource.RUSAGE_CHILDREN).ru_maxrss / 1e6:.2f} GB")
extraction 1094 s; peak memory of a worker 4.29 GB
FEATS = [c for c in FEATS84 if c in R.columns]
print("of the 84 features,", len(FEATS), "computed;", len(set(FEATS84) - set(FEATS)), "not computed by public IPFX:",
sorted(set(FEATS84) - set(FEATS)))
import importlib.metadata, pathlib, re, ipfx
ipfx_src = "\n".join(p.read_text(errors="ignore") for p in pathlib.Path(ipfx.__file__).parent.rglob("*.py"))
stems = sorted({re.sub(r"_(ramp|short_square|hero|rheo)$", "", f) for f in set(FEATS84) - set(FEATS)})
print("IPFX version", importlib.metadata.version("ipfx"), "| stems of the missing features named anywhere in its source:",
[s_ for s_ in stems if s_ in ipfx_src], "of", stems)
err = R.filter(regex="^error").notna()
print("files with a read error:", int(err.get("error", pd.Series(False)).sum()))
for c in err.columns:
if c != "error":
print(c, int(err[c].sum()), R[c].dropna().str.split(":").str[0].str[:60].value_counts().to_dict())
m1 = meta.drop_duplicates()
D = R.merge(m1, left_on="session", right_on="nwb_session", how="left")
D["has_row"] = D.specimen_id_x.notna()
D["subclass"] = D.Revised_subclass_label
D["ttype"] = D.Transcriptomic_type
D["ls_ok"] = D.n_long_square_qc > 0
E = D[D.has_row & D.ls_ok].copy() # labelled cells with at least one QC-passing long square sweep
print("labelled files", int(D.has_row.sum()), "| with a QC-passing long square sweep", len(E),
"| with rheobase", int(E.rheobase_i.notna().sum()), "| with sag", int(E.sag.notna().sum()))
# Feature failures (verifier, round 1): IPFX returns a non-positive input resistance or AP width for a few
# cells. These are not physical values, so they are set missing; the count is printed.
NONPOS = ["input_resistance"] + [c for c in FEATS if c.startswith("width_")]
dropped = {c: int((E[c] <= 0).sum()) for c in NONPOS if (E[c] <= 0).any()}
for c in NONPOS:
E.loc[E[c] <= 0, c] = np.nan
print("non-positive values set missing (cells per feature):", dropped)
print("fi_fit_slope at or below 0 (kept, a flat f-I curve is possible):", int((E.fi_fit_slope <= 0).sum()))
of the 84 features, 65 computed; 19 not computed by public IPFX: ['adp_v_last_rheo', 'ahp_delay_ratio_5spike', 'ahp_delay_ratio_hero', 'postap_slope_hero', 'postap_slope_ramp', 'postap_slope_rheo', 'postap_slope_short_square', 'sag_area', 'sag_area_depol', 'sag_depol', 'sag_peak_t', 'sag_peak_t_depol', 'sag_tau', 'trough_slowdeltav_hero', 'trough_slowdeltav_rheo', 'width_suprathresh_hero', 'width_suprathresh_ramp', 'width_suprathresh_rheo', 'width_suprathresh_short_square']
IPFX version 2.1.2 | stems of the missing features named anywhere in its source: [] of ['adp_v_last', 'ahp_delay_ratio', 'ahp_delay_ratio_5spike', 'postap_slope', 'sag_area', 'sag_area_depol', 'sag_depol', 'sag_peak_t', 'sag_peak_t_depol', 'sag_tau', 'trough_slowdeltav', 'width_suprathresh']
files with a read error: 0
error_long_square 16 {'FeatureError': 11, 'ValueError': 5}
error_short_square 4 {'FeatureError': 4}
labelled files 690 | with a QC-passing long square sweep 686 | with rheobase 675 | with sag 675
non-positive values set missing (cells per feature): {'input_resistance': 2, 'width_short_square': 1, 'width_rheo': 1}
fi_fit_slope at or below 0 (kept, a flat f-I curve is possible): 1
Data check¶
print("Files and subjects")
print(" files", len(R), "subjects (sub- folders)", R.subject.nunique(), "| subject_id in file equals folder:", bool((R.subject_id == R.subject).all()),
"| session_id equals file name:", bool((R.session_id == R.session).all()))
print(" species strings:", R.species.value_counts().to_dict(), "| institution:", R.institution.value_counts().to_dict())
print(" fields under /general:", R.general_fields.value_counts().to_dict())
print(" electrode location:", R.electrode_location.value_counts().to_dict())
print(" archive summary says numberOfCells", V["assetsSummary"].get("numberOfCells"), "for", len(R), "files, one cell per file")
print("Sampling rates of the analysed sweeps (Hz):", R.rates.astype(str).value_counts().to_dict())
print(" the Methods state 'digitized at 50 kHz'; files at 200 kHz by session date:")
R["year"] = R.session_start_time.str[:4]
print(pd.crosstab(R.year, R.rates.astype(str)))
print("Units (response|stimulus):", R.units.astype(str).value_counts().to_dict())
print("Sweeps per file: long square", R.n_long_square.describe()[["min", "50%", "max"]].to_dict(),
"| after QC", R.n_long_square_qc.describe()[["min", "50%", "max"]].to_dict())
print(" sweeps dropped by QC: long square %d of %d, short square %d of %d, ramp %d of %d" % (
(R.n_long_square - R.n_long_square_qc).sum(), R.n_long_square.sum(), (R.n_short_square - R.n_short_square_qc).sum(),
R.n_short_square.sum(), (R.n_ramp - R.n_ramp_qc).sum(), R.n_ramp.sum()))
print(" sweeps dropped for bridge balance >= 15% of Rin (cells):", int((R.n_bridge15_dropped > 0).sum()))
print("Labelled cells by condition and subclass (labelled files with a QC-passing long square sweep)")
print(pd.crosstab(E.subclass, E.condition, margins=True))
print("Donors", E.Donor.nunique(), "| cells per donor median", E.groupby("Donor").size().median())
print("Ranges of the variables used")
for c in ["rheobase_i", "input_resistance", "sag", "vm_for_sag", "width_rheo", "width_short_square", "upstroke_downstroke_ratio_rheo",
"peak_deltav_rheo", "latency_rheo", "avg_rate_hero", "fi_fit_slope", "v_baseline", "tau"]:
x = E[c].dropna()
print(f" {c:32s} n={len(x):3d} min={x.min():.4g} median={x.median():.4g} max={x.max():.4g}")
print("Clock check: the first spike of the rheobase sweep follows stimulus onset; latency (s) over cells:",
E.latency_rheo.describe()[["min", "50%", "max"]].round(4).to_dict(), "| negative:", int((E.latency_rheo < 0).sum()),
"| beyond the 1 s step:", int((E.latency_rheo > 1.0).sum()))
print(" contrast: rate in the hero sweep (rheobase + 40 pA) against rheobase sweep, median",
E.avg_rate_hero.median(), "against", E.avg_rate_rheo.median(), "spikes/s; higher in",
int((E.avg_rate_hero > E.avg_rate_rheo).sum()), "of", int(E[["avg_rate_hero", "avg_rate_rheo"]].notna().all(1).sum()), "cells")
print(" hyperpolarizing sweep used for sag reaches", E.vm_for_sag.describe()[["min", "50%", "max"]].round(1).to_dict(), "mV (target -100 mV)")
key = ["v_baseline", "rheobase_i", "input_resistance", "tau", "sag", "width_short_square", "threshold_i_ramp"]
kk = R[key].astype(float).round(6).fillna(-1e9).map(repr).agg("|".join, axis=1)
dup = R[R[key].notna().sum(1) >= 4][kk[R[key].notna().sum(1) >= 4].duplicated(keep=False)]
print("Deposited twice? files sharing identical values of", key, ":", len(dup), dup.session.tolist())
print(" files with the same file size:", int(R["size"].duplicated(keep=False).sum()))
print("Days in culture of culture cells:", E[E.condition == "culture"].Days_In_culture.value_counts().sort_index().to_dict())
Files and subjects
files 706 subjects (sub- folders) 109 | subject_id in file equals folder: True | session_id equals file name: True
species strings: {'Homo Sapiens': 581, 'Homo sapiens': 125} | institution: {'Allen Institute for Brain Science': 706}
fields under /general: {'data_collection,devices,generated_by,institution,intracellular_ephys,labnotebook,session_id,source_script,stimsets,subject,testpulse,user_comment': 706}
electrode location: {'none;none': 705, 'none;none;none': 1}
archive summary says numberOfCells 616 for 706 files, one cell per file
Sampling rates of the analysed sweeps (Hz): {'[50000.0]': 625, '[200000.0]': 78, '[]': 1, '[25000.0, 50000.0]': 1, '[50000.0, 200000.0]': 1}
the Methods state 'digitized at 50 kHz'; files at 200 kHz by session date:
rates [200000.0] [25000.0, 50000.0] [50000.0, 200000.0] [50000.0] []
year
2017 0 0 0 35 0
2018 0 1 0 165 1
2019 0 0 1 304 0
2020 60 0 0 121 0
2021 18 0 0 0 0
Units (response|stimulus): {"['volts|amperes']": 705, '[]': 1}
Sweeps per file: long square {'min': 0.0, '50%': 17.0, 'max': 117.0} | after QC {'min': 0.0, '50%': 15.0, 'max': 99.0}
sweeps dropped by QC: long square 3487 of 16021, short square 686 of 4102, ramp 499 of 2892
sweeps dropped for bridge balance >= 15% of Rin (cells): 30
Labelled cells by condition and subclass (labelled files with a QC-passing long square sweep)
condition acute culture All
subclass
LAMP5/PAX6/Other 40 24 64
PVALB 115 248 363
SST 19 139 158
VIP 59 42 101
All 233 453 686
Donors 102 | cells per donor median 4.0
Ranges of the variables used
rheobase_i n=675 min=2 median=60 max=380
input_resistance n=673 min=21.72 median=208.9 max=3497
sag n=675 min=0.001955 median=0.2253 max=0.6081
vm_for_sag n=675 min=-116.3 median=-87.13 max=-60.36
width_rheo n=605 min=0.0003 median=0.00062 max=0.00165
width_short_square n=667 min=4e-05 median=0.00057 max=0.00312
upstroke_downstroke_ratio_rheo n=606 min=0.8219 median=1.842 max=5.132
peak_deltav_rheo n=675 min=9.775 median=62 max=95.76
latency_rheo n=675 min=0.01016 median=0.09934 max=0.9887
avg_rate_hero n=675 min=1 median=16 max=81
fi_fit_slope n=672 min=-3.32e-19 median=0.1709 max=1.176
v_baseline n=675 min=-78.04 median=-63.07 max=-45.01
tau n=675 min=0.005334 median=0.01525 max=0.06672
Clock check: the first spike of the rheobase sweep follows stimulus onset; latency (s) over cells: {'min': 0.0102, '50%': 0.0993, 'max': 0.9887} | negative: 0 | beyond the 1 s step: 0
contrast: rate in the hero sweep (rheobase + 40 pA) against rheobase sweep, median 16.0 against 1.0000000000000002 spikes/s; higher in 621 of 675 cells
hyperpolarizing sweep used for sag reaches {'min': -116.3, '50%': -87.1, 'max': -60.4} mV (target -100 mV)
Deposited twice? files sharing identical values of ['v_baseline', 'rheobase_i', 'input_resistance', 'tau', 'sag', 'width_short_square', 'threshold_i_ramp'] : 0 []
files with the same file size: 0
Days in culture of culture cells: {2.0: 2, 3.0: 54, 4.0: 43, 5.0: 21, 6.0: 124, 7.0: 109, 8.0: 19, 9.0: 24, 10.0: 9, 11.0: 11, 12.0: 1, 13.0: 15, 14.0: 13, 15.0: 7, 16.0: 1}
cell-metadata-link¶
The dandiset's NWB files can be matched to the paper's per-cell metadata and feature tables in its code repository, and features recomputed from the files agree with those tables.
Matched by nwb_id (the NWB session id). Reproduced when at least 90% of the Has_ephys rows are found and rheobase_i, input_resistance, sag and width_rheo are within 10% of the paper's table for at least 90% of cells with both values.
Result: reproduced. 684 of the 704 rows with electrophysiology (97.2%) have an NWB file, and rheobase, input resistance, sag and width at rheobase computed here are within 10% of the paper's table for 92.2%, 94.5%, 97.8% and 98.8% of cells. All four agree together for 90.6% of cells. 16 files have no metadata row, and the metadata table repeats one row. Some features computed here differ from the table more often (isi_adapt_ratio within 10% for 27% of cells, fi_fit_slope 41%), so those definitions are not the paper's.
dataset-composition¶
The study characterized 778 human GABAergic neurons in layers 2 to 6, covering 44 of the 45 GABAergic t-types, with electrophysiology from 75 LAMP5/PAX6, 99 VIP, 149 SST and 352 PVALB neurons.
Counted over the dandiset's files with a QC-passing long square sweep, labelled through the link, by (a) Revised_subclass_label and (b) subclass_label; 778 and 44 over all labelled cells. Cell-level QC (seal, access resistance) is not recomputed here.
exp = {"LAMP5/PAX6/Other": 75, "VIP": 99, "SST": 149, "PVALB": 352}
print("neurons in the metadata table (unique specimens):", m1.specimen_id_x.nunique(), "| t-types:", m1.Transcriptomic_type.nunique())
print("layers of the labelled cells:", m1.Cortical_layer.value_counts(dropna=False).to_dict())
comp = pd.DataFrame({"expected": exp,
"a_revised": E.Revised_subclass_label.value_counts(),
"b_subclass_label": E.subclass_label.value_counts(),
"all_Has_ephys_rows_revised": m1[m1.Has_ephys == True].Revised_subclass_label.value_counts()})
comp["a_within"] = (comp.a_revised - comp.expected).abs() <= 0.1 * comp.expected
comp["b_within"] = (comp.b_subclass_label - comp.expected).abs() <= 0.1 * comp.expected
print(comp)
print("files counted", len(E), "| sum of expected", sum(exp.values()))
print("variant, cells with a rheobase computed here:", int(E.rheobase_i.notna().sum()), E[E.rheobase_i.notna()].Revised_subclass_label.value_counts().to_dict(),
"| subclass_label:", E[E.rheobase_i.notna()].subclass_label.value_counts().to_dict())
print("labelled files without a QC-passing long square sweep:", int((D.has_row & ~D.ls_ok).sum()))
print("RESULT composition: reading a all within:", bool(comp.a_within.all()), "| reading b all within:", bool(comp.b_within.all()))
neurons in the metadata table (unique specimens): 778 | t-types: 44
layers of the labelled cells: {'3': 377, '2': 166, '5': 76, '4': 65, nan: 53, '6': 23, '5_6': 13, '1': 3, '2_3': 2}
expected a_revised b_subclass_label all_Has_ephys_rows_revised a_within b_within
LAMP5/PAX6/Other 75 64 69 67 False True
PVALB 352 363 290 370 True False
SST 149 158 231 156 True False
VIP 99 101 96 111 True True
files counted 686 | sum of expected 675
variant, cells with a rheobase computed here: 675 {'PVALB': 358, 'SST': 155, 'VIP': 99, 'LAMP5/PAX6/Other': 63} | subclass_label: {'PVALB': 286, 'SST': 227, 'VIP': 94, 'LAMP5/PAX6/Other': 68}
labelled files without a QC-passing long square sweep: 4
RESULT composition: reading a all within: False | reading b all within: False
Result: partially reproduced. The metadata table holds 778 neurons in 44 t-types, as the paper says. Counted over the files here, reading (a) gives VIP 101, SST 158 and PVALB 363, within tolerance, but LAMP5/PAX6 64 against 75. Reading (b) gives LAMP5/PAX6 69 and VIP 96 within tolerance, and SST 231 and PVALB 290 outside it. Cells with a rheobase number 675, the paper's total, but by subclass they are 63, 99, 155 and 358.
Transcriptomes from the paper's code repository¶
The claims on gene expression are data: elsewhere: the expression matrices are in the code repository at commit 5eb357a (complete_patchseq_data_sets1/2.RData, log2(CPM + 1), 778 cells), read here with the rdata package.
X, metaP = L.transcriptomes()
print("expression matrix genes x cells", X.shape, "| value range", float(X.values.min()), float(X.values.max()))
cells_meta = m1.set_index("patched_cell_container")
print("expression columns found in the metadata table:", int(X.columns.isin(cells_meta.index).sum()), "of", X.shape[1])
T = cells_meta.loc[X.columns]
genes_detected_here = (X > 0).sum(axis=0)
print("genes detected (>0) agrees with the Genes_Detected column for", int((genes_detected_here.values == T.Genes_Detected.values).sum()), "of", len(T),
"cells; median absolute difference", float(np.median(np.abs(genes_detected_here.values - T.Genes_Detected.values))))
# How Genes_Detected was counted (the attempt's finding): genes above a threshold of the stored log2(CPM + 1)
for thr in [0, 0.5, 1, 2, 3, 4, 5]:
n_thr = (X.values > thr).sum(axis=0)
print(f"genes above {thr}: equal to Genes_Detected for {int((n_thr == T.Genes_Detected.values).sum())} of {len(T)} cells, "
f"median absolute difference {float(np.median(np.abs(n_thr - T.Genes_Detected.values)))}")
print("condition2 of the metadata table (duplicate row removed, rows) against condition2 of metaPatch (columns):")
print(pd.crosstab(T.condition2, metaP.set_index("patched_cell_container").reindex(T.index).condition2.astype(str)))
print("condition2 over all 779 rows of the metadata table, duplicate kept:", meta.condition2.value_counts().to_dict())
expression matrix genes x cells (50281, 778) | value range 0.0 17.77850863531457 expression columns found in the metadata table: 778 of 778 genes detected (>0) agrees with the Genes_Detected column for 0 of 778 cells; median absolute difference 4393.5 genes above 0: equal to Genes_Detected for 0 of 778 cells, median absolute difference 4393.5 genes above 0.5: equal to Genes_Detected for 0 of 778 cells, median absolute difference 4393.5
genes above 1: equal to Genes_Detected for 0 of 778 cells, median absolute difference 4004.0 genes above 2: equal to Genes_Detected for 0 of 778 cells, median absolute difference 2285.5 genes above 3: equal to Genes_Detected for 0 of 778 cells, median absolute difference 1167.5 genes above 4: equal to Genes_Detected for 0 of 778 cells, median absolute difference 796.0
genes above 5: equal to Genes_Detected for 0 of 778 cells, median absolute difference 1594.5
condition2 of the metadata table (duplicate row removed, rows) against condition2 of metaPatch (columns):
condition2 acute acute_immune culture culture_immune
condition2
acute 181 0 0 0
acute_microglial 0 130 0 0
culture 0 0 287 0
culture_microglial 0 0 0 180
condition2 over all 779 rows of the metadata table, duplicate kept: {'culture': 287, 'acute': 181, 'culture_microglial': 181, 'acute_microglial': 130}
fig1b-more-genes-in-culture¶
Patch-seq neurons from slices in culture (2 to 16 days) had more genes detected than neurons from acute slices.
Two-sided Mann-Whitney, culture against acute (condition); reproduced when the culture median is higher at p < 0.0001. Genes detected is the Genes_Detected column, the measure the code's notebook plots (Genes.Detected of metaPatch, equal to it for every cell, printed in figs1a); the count of genes above 0 in the matrix is a variant.
g = pd.DataFrame({"genes": genes_detected_here.values, "condition": T.condition.values, "dic": T.Days_In_culture.values})
a2, c2 = T[T.condition == "acute"].Genes_Detected, T[T.condition == "culture"].Genes_Detected
u2, p2 = stats.mannwhitneyu(c2, a2, alternative="two-sided")
print(f"Genes_Detected column (the code's Genes.Detected): acute n={len(a2)} median={a2.median():.0f}, culture n={len(c2)} median={c2.median():.0f}, U={u2:.0f}, p={p2:.3g}")
a, c = g[g.condition == "acute"].genes, g[g.condition == "culture"].genes
u, p = stats.mannwhitneyu(c, a, alternative="two-sided")
print(f"variant, genes > 0 in the matrix: acute median={a.median():.0f}, culture median={c.median():.0f}, U={u:.0f}, p={p:.3g}")
print("RESULT fig1b: Genes_Detected", bool(c2.median() > a2.median() and p2 < 1e-4), "| matrix variant", bool(c.median() > a.median() and p < 1e-4))
Genes_Detected column (the code's Genes.Detected): acute n=311 median=6802, culture n=467 median=7318, U=85858, p=1.62e-05 variant, genes > 0 in the matrix: acute median=11259, culture median=12203, U=91792, p=4.27e-10 RESULT fig1b: Genes_Detected True | matrix variant True
Result: reproduced. Culture cells have more genes detected: on the Genes_Detected column, which the code's notebook plots, the median is 7318 against 6802 (p = 1.6e-05); on genes above 0 in the expression matrix, 12203 against 11259 (p = 4.3e-10). Both are below p = 0.0001.
figs1a-genes-across-days¶
The higher number of genes detected in culture is present at every day in culture sampled and stays consistent across days in culture.
Pearson's correlation of genes detected with days in culture over culture cells (holds when p >= 0.05), and the median at every day above the acute median. Genes detected is the Genes_Detected column the claim names; genes above 0 in the matrix are a variant.
mpG = metaP.set_index("patched_cell_container").reindex(T.index)["Genes.Detected"] if "Genes.Detected" in metaP.columns else None
if mpG is not None:
print("Genes.Detected of metaPatch (the column the code's notebook plots) equals the metadata table's Genes_Detected for",
int((mpG.values == T.Genes_Detected.values).sum()), "of", len(T), "cells")
gd = pd.DataFrame({"genes": T.Genes_Detected.values, "condition": T.condition.values, "dic": T.Days_In_culture.values})
RES_S1A = {}
for name, src_ in [("Genes_Detected column (the source the claim names)", gd), ("genes > 0 in the matrix (variant)", g)]:
acute_med = src_[src_.condition == "acute"].genes.median()
cs = src_[src_.condition == "culture"]
r, p = stats.pearsonr(cs.dic, cs.genes)
rs, ps = stats.spearmanr(cs.dic, cs.genes)
per_day = cs.groupby("dic").genes.agg(["median", "count"])
per_day["minus_acute_median"] = per_day["median"] - acute_med
per_day["above_acute_median"] = per_day["median"] > acute_med
print(f"--- {name}: acute median {acute_med:.0f}; Pearson r={r:.3f}, p={p:.3g}, n={len(cs)}; Spearman rho={rs:.3f}, p={ps:.3g}")
print(per_day.T.to_string())
RES_S1A[name] = (bool(p >= 0.05), bool(per_day.above_acute_median.all()))
print("RESULT figs1a,", name, ": consistency (p>=0.05):", RES_S1A[name][0], "| elevation at every day:", RES_S1A[name][1])
Genes.Detected of metaPatch (the column the code's notebook plots) equals the metadata table's Genes_Detected for 778 of 778 cells --- Genes_Detected column (the source the claim names): acute median 6802; Pearson r=0.000, p=0.999, n=467; Spearman rho=-0.031, p=0.506 dic 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 median 6732.5 6588.0 7815.0 7170.0 8104.5 6971.5 6181.5 7036.5 8552.0 5185.0 9581.0 7381.0 8344.0 6932.0 9059.0 count 2 58 43 25 126 112 20 24 9 11 1 15 13 7 1 minus_acute_median -69.5 -214.0 1013.0 368.0 1302.5 169.5 -620.5 234.5 1750.0 -1617.0 2779.0 579.0 1542.0 130.0 2257.0 above_acute_median False False True True True True False True True False True True True True True RESULT figs1a, Genes_Detected column (the source the claim names) : consistency (p>=0.05): True | elevation at every day: False --- genes > 0 in the matrix (variant): acute median 11259; Pearson r=0.029, p=0.537, n=467; Spearman rho=-0.017, p=0.707 dic 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 median 15551.0 11488.5 13267.0 12554.0 12905.5 11836.5 11299.5 11991.5 13870.0 11303.0 12816.0 11495.0 12670.0 12367.0 13653.0 count 2 58 43 25 126 112 20 24 9 11 1 15 13 7 1 minus_acute_median 4292.0 229.5 2008.0 1295.0 1646.5 577.5 40.5 732.5 2611.0 44.0 1557.0 236.0 1411.0 1108.0 2394.0 above_acute_median True True True True True True True True True True True True True True True RESULT figs1a, genes > 0 in the matrix (variant) : consistency (p>=0.05): True | elevation at every day: True
Result: partially reproduced. On the Genes_Detected column the claim names, genes detected do not correlate with days in culture (Pearson r = 0.000, p = 0.999, n = 467), but the median is above the acute median (6802) at only 11 of the 15 days sampled: days 2, 3, 8 and 11 are below it (by 70, 214, 621 and 1617 genes). On genes above 0 in the matrix (a variant) every day is above the acute median (11259) and r = 0.029, p = 0.54.
fig1d-nms-no-difference¶
The normalized marker sum score does not differ between acute and culture neurons.
A claim of absence, judged on the two-sided Mann-Whitney test of marker_sum_norm_label, acute against culture.
nms_a = m1[m1.condition == "acute"].marker_sum_norm_label.dropna()
nms_c = m1[m1.condition == "culture"].marker_sum_norm_label.dropna()
u, p = stats.mannwhitneyu(nms_a, nms_c, alternative="two-sided")
print(f"acute n={len(nms_a)} median={nms_a.median():.3f}; culture n={len(nms_c)} median={nms_c.median():.3f}; U={u:.0f} p={p:.3g}; "
f"rank-biserial={1 - 2 * u / (len(nms_a) * len(nms_c)):.3f}")
print("NMS range", round(m1.marker_sum_norm_label.min(), 3), round(m1.marker_sum_norm_label.max(), 3))
print("RESULT fig1d: no difference (p>=0.05):", bool(p >= 0.05))
acute n=311 median=0.962; culture n=467 median=0.962; U=75314 p=0.38; rank-biserial=-0.037 NMS range 0.403 1.519 RESULT fig1d: no difference (p>=0.05): True
Result: reproduced. NMS does not differ (medians 0.962 and 0.962, Mann-Whitney p = 0.38, rank-biserial -0.037).
fig1c-marker-expression-correlated¶
For the top differentially expressed genes of each GABAergic subclass, average expression in acute and culture neurons is strongly correlated.
Readings named by the criterion: Pearson or Spearman, log2(CPM + 1) or CPM, per subclass or pooled, genes ranked by differential expression in the Patch-seq cells (the snRNA-seq ranking needs the dissociated-nuclei reference, which the code repository does not hold: its notebook loads complete_facs_data_sets.RData, absent at 5eb357a). Patch-seq ranking: the 25 genes with the largest difference in mean log2(CPM + 1) between a subclass's cells and all other cells (a standard choice).
Result: reproduced, under an assumption. Every reading run gives r > 0 and p < 1e-4, per subclass (r 0.75 to 0.97) and pooled (r 0.87 to 0.92). The genes are ranked here in the Patch-seq cells; the snRNA-seq ranking could not be run, as the reference data are not in the repository.
figs1-microglial-signature¶
Culture neurons fall into two clusters, with and without a microglial gene signature, and the signature is also present, less strongly, in a subset of acute neurons.
The criterion is the Seurat clustering of the code's chunks "cluster cultured cells" and "identify immune signature cells in culture and acute" (read at 5eb357a, printed below). Seurat is an R package and is not in the entry's environment, so its steps are run here in Python with Seurat's default parameters, a substitute: variable features by the vst method (2000 genes, loess span 0.3, here a lowess), ScaleData (z-score per gene, clipped at 10), 20 PCs, a UMAP with Seurat's defaults (30 neighbours, min_dist 0.3, cosine), FindNeighbors on the two UMAP dimensions (20 neighbours, shared-neighbour Jaccard weights pruned below 1/15) and Louvain clustering (networkx) at the code's resolutions, 0.001 on all culture cells and then 0.1 on culture and on acute cells with the microglial genes as the variable features. The microglial genes are the 269 of Data S2 (used_for_defining_microglial_signature), the genes the code's culture_DEX step chose. A cluster is microglial when its mean expression of these genes is the highest. The calls are compared with the paper's (condition2). Readings of "less pronounced": (a) a lower fraction of acute than culture cells called microglial, (b) lower mean expression of the 269 genes in acute than in culture microglial cells. Run under the claim's seed and four more.
rmd_lines = requests.get(f"https://raw.githubusercontent.com/{L.CODE_REPO}/{L.CODE_COMMIT}/scripts_gene_expression/acute_vs_culture_comparisons_update.Rmd", timeout=120).text.splitlines()
for key in ["pcs_patch <- 20", "res_patch <- 0.1"]:
j0 = next(j for j, l in enumerate(rmd_lines) if l.startswith(key))
print("\n".join(rmd_lines[j0:j0 + 7])); print("...")
S2 = L.code_table("DataS2_microglial_signature_genes_generalized.csv")
MG = [g_ for g_ in S2[S2.used_for_defining_microglial_signature.astype(str).str.upper() == "TRUE"].gene if g_ in X.index]
print("Data S2 genes", len(S2), "| used to define the signature and in the matrix:", len(MG))
from statsmodels.nonparametric.smoothers_lowess import lowess
from sklearn.decomposition import PCA
from sklearn.neighbors import NearestNeighbors
import scipy.sparse as sps, networkx as nx, umap
def vst_genes(Xc, n=2000):
"""Seurat's vst selection: standardized variance after a mean-variance fit (lowess for loess), values clipped at sqrt(cells)."""
mu, var = Xc.mean(1), Xc.var(1, ddof=1)
ok = var > 0
fit = lowess(np.log10(var[ok]), np.log10(mu[ok]), frac=0.3, return_sorted=False)
sd = pd.Series(np.sqrt(10 ** fit), index=Xc.index[ok])
Z = ((Xc[ok].sub(mu[ok], axis=0)).div(sd, axis=0)).clip(upper=np.sqrt(Xc.shape[1]))
return Z.var(1, ddof=1).sort_values(ascending=False).index[:n]
def seurat_like_clusters(Xc, genes, res, sd):
Z = Xc.loc[genes].T
Z = ((Z - Z.mean()) / Z.std(ddof=1).replace(0, np.nan)).fillna(0).clip(upper=10)
pcs = PCA(n_components=20, random_state=sd).fit_transform(Z.values)
emb = umap.UMAP(n_neighbors=30, min_dist=0.3, metric="cosine", random_state=sd).fit_transform(pcs)
_, ind = NearestNeighbors(n_neighbors=20).fit(emb).kneighbors(emb)
n = len(emb)
A = sps.csr_matrix((np.ones(ind.size), (np.repeat(np.arange(n), 20), ind.ravel())), shape=(n, n))
S = (A @ A.T).tocoo()
w = S.data / (40 - S.data)
keep = (w >= 1 / 15) & (S.row < S.col)
Gs = nx.Graph(); Gs.add_nodes_from(range(n))
Gs.add_weighted_edges_from(zip(S.row[keep], S.col[keep], w[keep]))
comms = nx.community.louvain_communities(Gs, weight="weight", resolution=res, seed=sd)
lab = np.zeros(n, int)
for ci, cm in enumerate(sorted(comms, key=len, reverse=True)):
lab[list(cm)] = ci
return lab
cond_T = T.condition.values
paper_call = T.condition2.astype(str).str.contains("microglial").values
score = X.loc[MG].mean(0).values
RES_S1 = {}
for off in SEED_OFFSETS:
sd = seed("figs1-microglial-signature") + off
cu = cond_T == "culture"; Xcu = X.loc[:, cu]
lab0 = seurat_like_clusters(Xcu, vst_genes(Xcu), 0.001, sd)
sc0 = pd.Series(score[cu]).groupby(lab0).mean()
p0 = stats.mannwhitneyu(score[cu][lab0 == sc0.idxmax()], score[cu][lab0 != sc0.idxmax()]).pvalue if len(sc0) > 1 else np.nan
calls = np.zeros(len(T), bool); nclu = {}
for cnd in ["culture", "acute"]:
m_ = cond_T == cnd
lab1 = seurat_like_clusters(X.loc[:, m_], MG, 0.1, sd)
sc1 = pd.Series(score[m_]).groupby(lab1).mean()
calls[np.where(m_)[0][lab1 == sc1.idxmax()]] = True
nclu[cnd] = len(sc1)
fa, fc = calls[cond_T == "acute"].mean(), calls[cond_T == "culture"].mean()
ea, ec = score[calls & (cond_T == "acute")].mean(), score[calls & (cond_T == "culture")].mean()
agree = (calls == paper_call).mean()
RES_S1[off] = dict(two_clusters=len(sc0) == 2, sig_p=p0, frac_acute=fa, frac_culture=fc, expr_acute=ea, expr_culture=ec)
print(f"seed+{off}: culture clusters at resolution 0.001: {len(sc0)} (sizes {np.bincount(lab0).tolist()}, mean signature {sc0.round(2).tolist()}, "
f"Mann-Whitney p between the highest and the rest {p0:.2g}); clusters at 0.1, culture {nclu['culture']}, acute {nclu['acute']}; "
f"called microglial: culture {fc:.2f}, acute {fa:.2f}; mean signature of called cells, culture {ec:.2f}, acute {ea:.2f}; "
f"agreement with condition2 {agree:.3f}")
print("paper's calls (condition2): culture", round(paper_call[cond_T == "culture"].mean(), 3), "acute", round(paper_call[cond_T == "acute"].mean(), 3),
"| mean signature of called cells, culture", round(score[paper_call & (cond_T == "culture")].mean(), 2), "acute", round(score[paper_call & (cond_T == "acute")].mean(), 2),
"| uncalled, culture", round(score[~paper_call & (cond_T == "culture")].mean(), 2), "acute", round(score[~paper_call & (cond_T == "acute")].mean(), 2))
r0 = RES_S1[0]
print("RESULT figs1, claim's seed: two culture clusters:", r0["two_clusters"], "| (a) acute fraction lower:", bool(r0["frac_acute"] < r0["frac_culture"]),
"| (b) acute signature lower:", bool(r0["expr_acute"] < r0["expr_culture"]))
pcs_patch <- 20 res_patch <- 0.001 culture <- ScaleData(culture, verbose = FALSE) culture <- RunPCA(culture, npcs = pcs_patch, verbose = FALSE) culture <- RunUMAP(culture, reduction = "pca", dims = 1:pcs_patch, verbose = FALSE) culture <- FindNeighbors(culture, dims = 1:2, verbose = FALSE,reduction="umap") culture <- FindClusters(culture, resolution = res_patch, verbose=FALSE) ... res_patch <- 0.1 VariableFeatures(culture) <- rownames(culture_DEX) culture <- ScaleData(culture, verbose = FALSE) culture <- RunPCA(culture, npcs = pcs_patch, verbose = FALSE) culture <- RunUMAP(culture, reduction = "pca", dims = 1:pcs_patch, verbose = FALSE) culture <- FindNeighbors(culture, dims = 1:2, verbose = FALSE,reduction="umap") culture <- FindClusters(culture, resolution = res_patch, verbose=FALSE) ... Data S2 genes 601 | used to define the signature and in the matrix: 269
seed+0: culture clusters at resolution 0.001: 3 (sizes [208, 172, 87], mean signature [1.14, 6.03, 1.09], Mann-Whitney p between the highest and the rest 1.8e-72); clusters at 0.1, culture 2, acute 2; called microglial: culture 0.38, acute 0.40; mean signature of called cells, culture 5.92, acute 3.82; agreement with condition2 0.982
seed+1000: culture clusters at resolution 0.001: 2 (sizes [296, 171], mean signature [1.13, 6.05], Mann-Whitney p between the highest and the rest 2.3e-72); clusters at 0.1, culture 2, acute 2; called microglial: culture 0.38, acute 0.39; mean signature of called cells, culture 5.92, acute 3.83; agreement with condition2 0.981
seed+2000: culture clusters at resolution 0.001: 2 (sizes [296, 171], mean signature [1.13, 6.04], Mann-Whitney p between the highest and the rest 2.8e-72); clusters at 0.1, culture 2, acute 2; called microglial: culture 0.38, acute 0.46; mean signature of called cells, culture 5.92, acute 3.57; agreement with condition2 0.968
seed+3000: culture clusters at resolution 0.001: 2 (sizes [296, 171], mean signature [1.13, 6.04], Mann-Whitney p between the highest and the rest 2.8e-72); clusters at 0.1, culture 2, acute 2; called microglial: culture 0.38, acute 0.40; mean signature of called cells, culture 5.92, acute 3.81; agreement with condition2 0.983
seed+4000: culture clusters at resolution 0.001: 2 (sizes [296, 171], mean signature [1.13, 6.04], Mann-Whitney p between the highest and the rest 2.8e-72); clusters at 0.1, culture 2, acute 2; called microglial: culture 0.38, acute 0.47; mean signature of called cells, culture 5.92, acute 3.56; agreement with condition2 0.967 paper's calls (condition2): culture 0.385 acute 0.418 | mean signature of called cells, culture 5.9 acute 3.76 | uncalled, culture 1.06 acute 1.4 RESULT figs1, claim's seed: two culture clusters: False | (a) acute fraction lower: False | (b) acute signature lower: True
Result: blocked, methods underspecified. The readings of "less pronounced" disagree, as the criterion foresees. The culture cells split into a cluster with a high microglial signature (171 to 173 cells, mean 6.0 against 1.1, Mann-Whitney p 1.1e-72 to 2.8e-72) and the rest, into two clusters under four of the five seeds, the claim's among them, and three under seed +3000 (the third is a split of the cells without the signature). Reading (b) holds: the acute cells called microglial express the 269 genes less than the culture ones (mean 3.6 to 3.8 against 5.9). Reading (a) fails: a larger fraction of acute than of culture cells is called microglial (0.40 to 0.47 against 0.38), and the paper's own calls give the same (0.418 against 0.385). The calls here agree with condition2 for 96.7% to 98.2% of cells.
figs2d-seven-channel-genes¶
Of 114 voltage-gated ion-channel genes, only seven differ in expression between culture and acute neurons.
As the code's chunks "linear model gene expression WFDC2" and "fold change and ion channels WFDC2": PVALB WFDC2 cells, genes with mean > 0.01, lm(expression ~ condition + isImmune + condition*isImmune) per gene, apply(lm_pval, 2, p.adjust) (Holm over each gene's three term p-values, as the code applies it per gene), channel genes from vgic_genes.csv, counted at adjusted p <= 0.01. isImmune is the paper's call (condition2 ending in "microglial"). The code's keepGenes filter needs the dissociated-nuclei data, not in the repository, so it is not applied.
vgic = L.code_table("vgic_genes.csv")
channels = set(vgic["HGNC symbol"].dropna())
wf = (T.Transcriptomic_type == "Inh L2-4 PVALB WFDC2").values
Xw = X.loc[:, wf]
keep = Xw.mean(axis=1) > 0.01
Xw = Xw[keep]
cond = (T.condition.values[wf] == "culture").astype(float)
imm = T.condition2.str.contains("microglial").values[wf].astype(float)
Dm = np.column_stack([np.ones_like(cond), cond, imm, cond * imm])
print("PVALB WFDC2 cells", int(wf.sum()), "| by condition2", pd.Series(T.condition2.values[wf]).value_counts().to_dict())
Y = Xw.values.T
beta, *_ = np.linalg.lstsq(Dm, Y, rcond=None)
resid = Y - Dm @ beta
dof = Dm.shape[0] - np.linalg.matrix_rank(Dm)
s2 = (resid ** 2).sum(0) / dof
XtXi = np.linalg.pinv(Dm.T @ Dm)
se = np.sqrt(np.outer(np.diag(XtXi), s2))
with np.errstate(divide="ignore", invalid="ignore"):
tval = beta / se
pv = 2 * stats.t.sf(np.abs(tval), dof)[1:] # condition, isImmune, interaction
from statsmodels.stats.multitest import multipletests
def holm_cols(P):
"""R's p.adjust(method = "holm") applied to each column of P (here, each gene's three term
p-values), vectorized: sorted p times (m - rank), cumulative maximum, capped at 1."""
m_ = P.shape[0]
order = np.argsort(P, axis=0)
ps = np.take_along_axis(P, order, axis=0)
adj_s = np.minimum(1, np.maximum.accumulate(ps * (m_ - np.arange(m_))[:, None], axis=0))
out = np.empty_like(P)
np.put_along_axis(out, order, adj_s, axis=0)
return out
chk = np.array([[0.01, 0.2], [0.04, 0.03], [0.03, 0.5]])
print("check against statsmodels on two columns:", np.allclose(holm_cols(chk), np.column_stack([multipletests(chk[:, j], method="holm")[1] for j in range(2)])))
adj = holm_cols(pv)[0]
genes = Xw.index
isch = genes.isin(channels)
res = pd.DataFrame({"p_condition": pv[0], "adj_per_gene": adj, "channel": isch}, index=genes)
res["holm_across_genes"] = L.bh(res.p_condition) * np.nan
okp = np.isfinite(res.p_condition)
res.loc[okp, "holm_across_genes"] = multipletests(res.p_condition[okp], method="holm")[1]
res.loc[okp, "bh_across_genes"] = multipletests(res.p_condition[okp], method="fdr_bh")[1]
res["FC"] = Xw.loc[:, cond == 1].mean(1) - Xw.loc[:, cond == 0].mean(1)
chan = res[res.channel]
print("genes tested", len(res), "| channel genes in vgic list", len(channels), "| channel genes tested", len(chan))
n_main = int((chan.adj_per_gene <= 0.01).sum())
print("channel genes with adjusted p <= 0.01 (code's per-gene Holm):", n_main)
print(chan[chan.adj_per_gene <= 0.01].sort_values("adj_per_gene")[["p_condition", "adj_per_gene", "FC"]].round(5))
print("variants: Holm across genes", int((chan.holm_across_genes <= 0.01).sum()), "| BH across genes", int((chan.bh_across_genes <= 0.01).sum()),
"| unadjusted p <= 0.01", int((chan.p_condition <= 0.01).sum()))
print("RESULT figs2d: count", n_main, "channel genes tested", len(chan))
rmd = requests.get(f"https://raw.githubusercontent.com/{L.CODE_REPO}/{L.CODE_COMMIT}/scripts_gene_expression/acute_vs_culture_comparisons_update.Rmd", timeout=120).text.splitlines()
s0 = next(j for j, l in enumerate(rmd) if l.startswith("```{r linear model gene expression WFDC2}"))
print("The code's chunk (Rmd at the pinned commit, lines %d to %d):" % (s0 + 1, s0 + 13))
print("\n".join(rmd[s0:s0 + 13]))
print("apply(X, 1, f) calls f on each row of X (each gene) and returns one column per call, so lm_pval has the three model terms as rows",
"and the genes as columns; apply(lm_pval, 2, p.adjust) then adjusts each column, that is each gene's three term p-values.")
PVALB WFDC2 cells 168 | by condition2 {'culture': 64, 'acute': 48, 'acute_microglial': 31, 'culture_microglial': 25}
check against statsmodels on two columns: True
genes tested 40551 | channel genes in vgic list 145 | channel genes tested 142
channel genes with adjusted p <= 0.01 (code's per-gene Holm): 22
p_condition adj_per_gene FC
TRPM8 0.00000 0.00000 1.81903
SCN3A 0.00000 0.00001 1.67684
CACNA1A 0.00001 0.00002 0.59033
TRPV3 0.00001 0.00003 0.62459
TRPM7 0.00001 0.00003 1.58011
TRPM1 0.00002 0.00005 0.87477
TRPV1 0.00002 0.00007 1.31305
SCN1A 0.00003 0.00009 0.81283
KCNG2 0.00004 0.00013 -1.59666
TRPM3 0.00005 0.00014 1.36609
TRPM6 0.00005 0.00016 0.90487
MCOLN2 0.00023 0.00070 0.78371
HCN3 0.00079 0.00237 1.13052
RYR3 0.00081 0.00242 1.01830
SCN8A 0.00127 0.00380 -1.04440
KCNA6 0.00152 0.00457 0.95384
KCNH5 0.00189 0.00566 0.98094
KCNK10 0.00239 0.00639 0.70294
KCNU1 0.00233 0.00700 0.54888
SCN11A 0.00243 0.00729 0.67055
CATSPER3 0.00323 0.00970 -1.33564
KCNJ15 0.00333 0.00999 0.36731
variants: Holm across genes 1 | BH across genes 12 | unadjusted p <= 0.01 34
RESULT figs2d: count 22 channel genes tested 142
The code's chunk (Rmd at the pinned commit, lines 364 to 376):
```{r linear model gene expression WFDC2}
kpPatch <- metaPatch$cluster_label=="Inh L2-4 PVALB WFDC2"
tmpPatch <- metaPatch[,c("condition","isImmune")]
lm_pval_apply <- function(x){
dat <- data.frame(tmpPatch[kpPatch,],expression = x)
lmOut <- lm(expression~condition+isImmune+condition*isImmune, data = dat)
summary(lmOut)$coefficients[2:dim(summary(lmOut)$coefficients)[1],4]
}
keepGenes3 <- (rowMeans(datPatch[,kpPatch])>0.01)&keepGenes
lm_pval <- apply(datPatch[keepGenes3,kpPatch],1,lm_pval_apply)
lm_pval_adjust <- apply(lm_pval,2,p.adjust) # FDR corrected
apply(X, 1, f) calls f on each row of X (each gene) and returns one column per call, so lm_pval has the three model terms as rows and the genes as columns; apply(lm_pval, 2, p.adjust) then adjusts each column, that is each gene's three term p-values.
Result: blocked. The code's gene filter needs the dissociated-nuclei data, which the repository does not hold. Without it 142 channel genes are tested, against the paper's 114, and 22 differ at adjusted p <= 0.01 (Holm across genes 1, BH across genes 12). The procedure run is therefore not the paper's, and the count is not compared with 7. The code's lines, printed above, show that lm_pval has the model terms as rows, so apply(lm_pval, 2, p.adjust) adjusts each gene's three p-values.
fig5a-dbc-two-ttypes¶
Morphologically classic double bouquet cells map to two t-types, SST CALB1 and SST ADGRG6.
DBC calls from dbc_calb1_ADGRG6.csv; their t-types there (Tree_first_cl) against the tree mapping stored with the transcriptomes (Tree_first_cl of metaPatch) and the metadata table. The tree mapping itself is not re-run (it needs the MTG reference taxonomy).
dbc_yes = dbc_tab[dbc_tab.DBC == "yes"].copy()
mp = metaP.set_index("patched_cell_container") if "patched_cell_container" in metaP.columns else None
dbc_yes["tree_metaPatch"] = mp.loc[dbc_yes.Tube_id, "Tree_first_cl"].values
dbc_yes["ttype_metadata"] = cells_meta.loc[dbc_yes.Tube_id, "Transcriptomic_type"].values
dbc_yes["morph_metadata"] = cells_meta.loc[dbc_yes.Tube_id, "Qualitative_morphology_type"].values
print(dbc_yes[["cell_name_label", "Tree_first_cl", "tree_metaPatch", "ttype_metadata", "morph_metadata"]].to_string())
cnt = dbc_yes.Tree_first_cl.value_counts()
print("DBCs by t-type:", cnt.to_dict())
print("agree with metaPatch:", int((dbc_yes.Tree_first_cl == dbc_yes.tree_metaPatch).sum()), "| with metadata table:",
int((dbc_yes.Tree_first_cl.str.strip() == dbc_yes.ttype_metadata.str.strip()).sum()), "of", len(dbc_yes))
print("metadata cells with Qualitative_morphology_type DBC:", int((m1.Qualitative_morphology_type == "DBC").sum()))
cell_name_label Tree_first_cl tree_metaPatch ttype_metadata morph_metadata
1 H18.03.009.11.16.02 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
2 H19.03.308.99.02.06.01.09 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
3 H19.03.314.1A.03.09 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
4 H20.03.305.11.53.01.01 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
5 H18.29.123.11.01.02 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
6 H19.03.314.1A.01.05 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
7 H19.06.363.11.51.01.04 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 Inh L1-3 SST CALB1 DBC
8 H18.29.135.11.41.01 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 DBC
9 H19.03.004.99.01.04.02.01 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 DBC
10 H20.26.411.11.51.01.04 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 DBC
11 H19.03.316.11.11.01.01 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 Inh L3-5 SST ADGRG6 DBC
DBCs by t-type: {'Inh L1-3 SST CALB1': 7, 'Inh L3-5 SST ADGRG6': 4}
agree with metaPatch: 11 | with metadata table: 11 of 11
metadata cells with Qualitative_morphology_type DBC: 11
Result: reproduced. The 11 DBCs are 7 SST CALB1 and 4 SST ADGRG6, and the t-types of the DBC table agree with the tree mapping stored with the transcriptomes and with the metadata table for all 11. The tree mapping was not re-run.
figs7a-dbc-regions¶
Six of seven DBCs in SST CALB1 come from temporal cortex and three of four DBCs in SST ADGRG6 from frontal cortex.
Region from the lobe column (the NWB files carry no region; see the data check). Over all DBCs and, as a variant, those with an NWB file in the dandiset.
dbc_yes["lobe"] = cells_meta.loc[dbc_yes.Tube_id, "lobe"].values
dbc_yes["nwb_session"] = cells_meta.loc[dbc_yes.Tube_id, "nwb_session"].values
dbc_yes["in_dandiset"] = dbc_yes.nwb_session.isin(R.session)
print(pd.crosstab(dbc_yes.Tree_first_cl, dbc_yes.lobe, margins=True))
print("with an NWB file in the dandiset:"); print(pd.crosstab(dbc_yes[dbc_yes.in_dandiset].Tree_first_cl, dbc_yes[dbc_yes.in_dandiset].lobe, margins=True))
ca = dbc_yes[dbc_yes.Tree_first_cl.str.contains("CALB1")]; ad = dbc_yes[dbc_yes.Tree_first_cl.str.contains("ADGRG6")]
meas_regions = [int((ca.lobe == "TemL").sum()), len(ca), int((ad.lobe == "FroL").sum()), len(ad)]
print("RESULT figs7a-regions:", meas_regions, "expected [6, 7, 3, 4]")
lobe FroL OccL TemL All Tree_first_cl Inh L1-3 SST CALB1 0 1 6 7 Inh L3-5 SST ADGRG6 3 0 1 4 All 3 1 7 11 with an NWB file in the dandiset: lobe FroL OccL TemL All Tree_first_cl Inh L1-3 SST CALB1 0 1 5 6 Inh L3-5 SST ADGRG6 2 0 1 3 All 2 1 6 9 RESULT figs7a-regions: [6, 7, 3, 4] expected [6, 7, 3, 4]
Result: reproduced. Six of 7 SST CALB1 DBCs are from temporal cortex (one occipital) and 3 of 4 SST ADGRG6 DBCs from frontal cortex (one temporal). Two DBCs have no NWB file here. Over the 9 that have one, the counts are 5 of 6 and 2 of 3.
figs7a-dbc-markers¶
Most DBCs strongly express CALB1, only one expresses CALB2, all but one express some SST, and TAC1, NOS1 and NPY expression is mixed.
"Strong" is log2(CPM + 1) > 5 (the criterion's choice); detected is > 0.
G = X.loc[["CALB1", "CALB2", "SST", "TAC1", "NOS1", "NPY"], dbc_yes.Tube_id].T
G.index = dbc_yes.cell_name_label + " | " + dbc_yes.Tree_first_cl.str.replace("Inh ", "")
print(G.round(2).to_string())
n = len(G)
strong_calb1 = int((G.CALB1 > 5).sum()); calb2 = int((G.CALB2 > 0).sum()); sst = int((G.SST > 0).sum())
mixed = {gname: int((G[gname] > 0).sum()) for gname in ["TAC1", "NOS1", "NPY"]}
print(f"DBCs {n}: CALB1 > 5 in {strong_calb1}; CALB2 > 0 in {calb2}; SST > 0 in {sst}; detected TAC1/NOS1/NPY {mixed}")
print("CALB1 > 3 (variant):", int((G.CALB1 > 3).sum()), "| CALB1 > 7:", int((G.CALB1 > 7).sum()))
ok = strong_calb1 > n / 2 and calb2 == 1 and sst == n - 1 and all(0 < v < n for v in mixed.values())
print("RESULT figs7a-markers:", ok)
CALB1 CALB2 SST TAC1 NOS1 NPY
H18.03.009.11.16.02 | L1-3 SST CALB1 8.35 0.0 8.82 5.29 6.27 0.95
H19.03.308.99.02.06.01.09 | L1-3 SST CALB1 7.31 0.0 4.72 0.00 1.04 3.53
H19.03.314.1A.03.09 | L1-3 SST CALB1 4.20 0.0 7.85 2.54 0.00 10.76
H20.03.305.11.53.01.01 | L1-3 SST CALB1 8.81 0.0 10.91 5.83 4.92 8.60
H18.29.123.11.01.02 | L1-3 SST CALB1 8.16 0.0 5.30 0.00 0.99 11.52
H19.03.314.1A.01.05 | L1-3 SST CALB1 4.86 0.0 5.60 0.00 0.00 8.88
H19.06.363.11.51.01.04 | L1-3 SST CALB1 8.29 0.0 9.10 7.84 6.34 8.89
H18.29.135.11.41.01 | L3-5 SST ADGRG6 7.98 0.0 10.68 0.00 1.15 6.71
H19.03.004.99.01.04.02.01 | L3-5 SST ADGRG6 3.03 0.0 0.00 7.21 1.61 8.74
H20.26.411.11.51.01.04 | L3-5 SST ADGRG6 9.14 0.0 8.64 9.26 7.21 8.58
H19.03.316.11.11.01.01 | L3-5 SST ADGRG6 1.82 3.1 10.44 7.26 5.76 0.00
DBCs 11: CALB1 > 5 in 7; CALB2 > 0 in 1; SST > 0 in 10; detected TAC1/NOS1/NPY {'TAC1': 7, 'NOS1': 9, 'NPY': 10}
CALB1 > 3 (variant): 10 | CALB1 > 7: 7
RESULT figs7a-markers: True
Result: reproduced. Of 11 DBCs, 7 have CALB1 log2(CPM + 1) > 5, one expresses CALB2, 10 express SST, and TAC1, NOS1 and NPY are detected in 7, 9 and 10. With a cut of 3 for strong CALB1 it is 10 of 11.
fig5b-merfish-layers¶
In MERFISH, SST CALB1 is mostly restricted to L2 and SST ADGRG6 to L3, in line with the Patch-seq soma positions, and SST CALB1 DBC axon peaks more superficially.
Blocked: the MERFISH data have no public location, and the axon part needs the layer-aligned reconstructions. The criterion asks that the Patch-seq soma layers (Cortical_layer) of the two t-types be reported; they are tabulated here.
L5b = m1[m1.Transcriptomic_type.isin(["Inh L1-3 SST CALB1", "Inh L3-5 SST ADGRG6"])]
print("Patch-seq soma layer, all labelled cells:"); print(pd.crosstab(L5b.Transcriptomic_type, L5b.Cortical_layer.astype(str), margins=True))
L5f = L5b[L5b.nwb_session.isin(R.session)]
print("cells with an NWB file here:"); print(pd.crosstab(L5f.Transcriptomic_type, L5f.Cortical_layer.astype(str), margins=True))
print("modal layer:", L5b.groupby("Transcriptomic_type").Cortical_layer.agg(lambda s: s.astype(str).value_counts().idxmax()).to_dict())
dl = cells_meta.loc[dbc_yes.Tube_id, "Cortical_layer"].astype(str).values
print("DBCs:"); print(pd.crosstab(dbc_yes.Tree_first_cl.values, dl))
Patch-seq soma layer, all labelled cells:
Cortical_layer 2 3 4 5 6 All
Transcriptomic_type
Inh L1-3 SST CALB1 33 26 1 1 2 63
Inh L3-5 SST ADGRG6 9 17 2 1 0 29
All 42 43 3 2 2 92
cells with an NWB file here:
Cortical_layer 2 3 4 5 6 All
Transcriptomic_type
Inh L1-3 SST CALB1 30 24 0 1 2 57
Inh L3-5 SST ADGRG6 8 15 1 1 0 25
All 38 39 1 2 2 82
modal layer: {'Inh L1-3 SST CALB1': '2', 'Inh L3-5 SST ADGRG6': '3'}
DBCs:
col_0 2 3
row_0
Inh L1-3 SST CALB1 4 3
Inh L3-5 SST ADGRG6 1 3
Result: blocked. The MERFISH data have no public location. The Patch-seq soma layers the criterion asks to report agree with the statement: SST CALB1 cells are most often in L2 (33 of 63, 26 in L3) and SST ADGRG6 cells in L3 (17 of 29, 9 in L2).
fig4d-calb1-genes-by-morphology¶
A UMAP on 253 genes differentially expressed between DBC, MC and sparse SST neurons splits SST CALB1 neurons into three clusters that largely separate the morphology types.
Main reading, the Methods (case iv): pairwise t tests (Seurat's t, a Welch test) between DBC, MC and sparse SST cells of SST CALB1, Bonferroni over all genes, adjusted p < 0.05, union of the three pairs. Cells read as (1) all SST CALB1 cells with a morphology call, (2) the culture microglial ones (the code's chunk). Variant, the code's chunk: one-against-rest t tests on the culture microglial cells with genes of median >= 1, counted at Seurat FindAllMarkers' default return threshold (p < 0.01); the code also drops its immune and keepGenes lists, which need data not in the repository. Morphology calls are morpho_call with the code's fix (cell 893655882 and "SMC" are sparse SST). The UMAP and clusters are run in Python (umap-learn, Louvain of networkx), not Seurat.
mpc = metaP.copy()
mpc["morpho_call"] = mpc["morpho_call"].astype(str)
mpc.loc[mpc.spec_id.astype(str) == "893655882", "morpho_call"] = "SMC"
mpc.loc[mpc.morpho_call == "SMC", "morpho_call"] = "Sparse SST"
mpc["topLeaf"] = mpc.topLeaf_label.astype(str).str.split(" \\(").str[0]
calb = mpc[mpc.topLeaf == "Inh L1-3 SST CALB1"]
print("SST CALB1 cells", len(calb), "| morphology calls:", calb.morpho_call.value_counts().to_dict(),
"| condition2 of called cells:", calb[calb.morpho_call.isin(["DBC", "MC", "Sparse SST"])].condition2.value_counts().to_dict())
types = ["DBC", "MC", "Sparse SST"]
def pairwise_de(cols_by_type):
gs = set()
out = {}
ng = X.shape[0]
for i in range(3):
for j in range(i + 1, 3):
A_, B_ = X[cols_by_type[types[i]]].values, X[cols_by_type[types[j]]].values
if A_.shape[1] < 2 or B_.shape[1] < 2:
out[(types[i], types[j])] = None
continue
with np.errstate(all="ignore"):
t_, p_ = stats.ttest_ind(A_, B_, axis=1, equal_var=False)
p_ = np.where(np.isfinite(p_), p_, 1.0)
sig = X.index[np.minimum(p_ * ng, 1) < 0.05]
out[(types[i], types[j])] = len(sig)
gs |= set(sig)
return gs, out
cols1 = {t_: calb[calb.morpho_call == t_].patched_cell_container.tolist() for t_ in types}
cols2 = {t_: calb[(calb.morpho_call == t_) & calb.condition2.astype(str).str.match(r"culture.*(immune|microglial)")].patched_cell_container.tolist() for t_ in types}
DE = {}
for name, cols in [("1 all called cells", cols1), ("2 culture microglial", cols2)]:
gs, per = pairwise_de(cols)
DE[name] = gs
print(f"reading {name}: cells {[len(cols[t_]) for t_ in types]}, per pair {per}, union {len(gs)}")
c3 = sum(cols2.values(), [])
Xc = X[c3]
Xc = Xc[Xc.median(axis=1) >= 1]
lab3 = np.array([t_ for t_ in types for _ in cols2[t_]])
var = set()
for t_ in types:
with np.errstate(all="ignore"):
_, p_ = stats.ttest_ind(Xc.values[:, lab3 == t_], Xc.values[:, lab3 != t_], axis=1, equal_var=False)
var |= set(Xc.index[np.nan_to_num(p_, nan=1) < 0.01])
print("variant (code's chunk, one against rest, p < 0.01, genes median >= 1):", len(var), "genes")
n_rows = 0
for t_ in types:
pct_in = (Xc.values[:, lab3 == t_] > 0).mean(1); pct_out = (Xc.values[:, lab3 != t_] > 0).mean(1)
with np.errstate(all="ignore"):
_, p_ = stats.ttest_ind(Xc.values[:, lab3 == t_], Xc.values[:, lab3 != t_], axis=1, equal_var=False)
n_rows += int(((np.nan_to_num(p_, nan=1) < 0.01) & (np.maximum(pct_in, pct_out) >= 0.1)).sum())
print(" as FindAllMarkers counts rows (a gene once per type), with its default min.pct 0.1:", n_rows)
RES_253 = {k: len(v) for k, v in DE.items()}
RES_253["variant"] = len(var)
SST CALB1 cells 64 | morphology calls: {'': 48, 'DBC': 7, 'Sparse SST': 5, 'MC': 3, 'Basket': 1} | condition2 of called cells: {'culture_immune': 10, 'culture': 3, 'acute_immune': 1, 'acute': 1}
reading 1 all called cells: cells [7, 3, 5], per pair {('DBC', 'MC'): 1, ('DBC', 'Sparse SST'): 1, ('MC', 'Sparse SST'): 0}, union 2
reading 2 culture microglial: cells [3, 3, 4], per pair {('DBC', 'MC'): 0, ('DBC', 'Sparse SST'): 0, ('MC', 'Sparse SST'): 0}, union 0
variant (code's chunk, one against rest, p < 0.01, genes median >= 1): 431 genes as FindAllMarkers counts rows (a gene once per type), with its default min.pct 0.1: 451
import umap, networkx as nx
from sklearn.decomposition import PCA
from sklearn.neighbors import kneighbors_graph
def clusters_on(genes, npcs, nnb, sd):
Z = X.loc[sorted(genes), calb.patched_cell_container].T
Z = (Z - Z.mean()) / Z.std(ddof=0).replace(0, np.nan)
Z = Z.fillna(0).clip(-10, 10)
pcs = PCA(n_components=min(npcs, Z.shape[0] - 1, Z.shape[1]), random_state=sd).fit_transform(Z)
emb = umap.UMAP(n_neighbors=nnb, random_state=sd).fit_transform(pcs)
Gk = nx.from_scipy_sparse_array(kneighbors_graph(emb, 20 if len(emb) > 20 else len(emb) - 1, include_self=False))
comms = nx.community.louvain_communities(Gk, resolution=1, seed=sd)
lab = np.zeros(len(emb), int)
for ci, cm in enumerate(comms):
lab[list(cm)] = ci
return lab
mc_ = calb.morpho_call.values
SEP4D = {}
for name, genes, npcs, nnb in [("main, reading 1 genes, 30 PCs", DE["1 all called cells"], 30, 15),
("variant genes, 6 PCs, 5 neighbours", var, 6, 5)]:
if len(genes) < 3:
print(name, ": too few genes to build clusters"); SEP4D[name] = None; continue
for off in SEED_OFFSETS:
lab = clusters_on(genes, npcs, nnb, seed("fig4d-calb1-genes-by-morphology") + off)
tab = pd.crosstab(mc_, lab).loc[types]
major = tab.idxmax(axis=1)
frac = (tab.max(axis=1) / tab.sum(axis=1)).round(2)
sep = major.nunique() == 3 and (frac > 0.5).all()
SEP4D[(name, off)] = sep
print(f"{name} seed+{off}: clusters {len(set(lab))}, majority cluster {major.to_dict()}, fraction {frac.to_dict()}, separated {sep}")
print("The variant leaves out the code's keepGenes and immune-gene filters, which only remove genes, so its count is an upper bound",
"for the code's reading: a count within 228 to 278 is not excluded under it.")
print("RESULT fig4d: genes, Methods reading 1:", RES_253["1 all called cells"], "| reading 2:", RES_253["2 culture microglial"],
"| variant (upper bound):", RES_253["variant"], "| tolerance 228 to 278 | clusters under the main reading:",
"not built (too few genes)" if SEP4D.get("main, reading 1 genes, 30 PCs", 0) is None else SEP4D)
main, reading 1 genes, 30 PCs : too few genes to build clusters
variant genes, 6 PCs, 5 neighbours seed+0: clusters 3, majority cluster {'DBC': 0, 'MC': 0, 'Sparse SST': 0}, fraction {'DBC': 0.43, 'MC': 1.0, 'Sparse SST': 0.8}, separated False
variant genes, 6 PCs, 5 neighbours seed+1000: clusters 3, majority cluster {'DBC': 0, 'MC': 0, 'Sparse SST': 0}, fraction {'DBC': 0.43, 'MC': 1.0, 'Sparse SST': 0.8}, separated False
variant genes, 6 PCs, 5 neighbours seed+2000: clusters 3, majority cluster {'DBC': 0, 'MC': 2, 'Sparse SST': 2}, fraction {'DBC': 0.57, 'MC': 1.0, 'Sparse SST': 0.8}, separated False
variant genes, 6 PCs, 5 neighbours seed+3000: clusters 3, majority cluster {'DBC': 0, 'MC': 0, 'Sparse SST': 0}, fraction {'DBC': 0.43, 'MC': 1.0, 'Sparse SST': 0.8}, separated False
variant genes, 6 PCs, 5 neighbours seed+4000: clusters 3, majority cluster {'DBC': 1, 'MC': 0, 'Sparse SST': 0}, fraction {'DBC': 0.43, 'MC': 1.0, 'Sparse SST': 0.8}, separated False
The variant leaves out the code's keepGenes and immune-gene filters, which only remove genes, so its count is an upper bound for the code's reading: a count within 228 to 278 is not excluded under it.
RESULT fig4d: genes, Methods reading 1: 2 | reading 2: 0 | variant (upper bound): 431 | tolerance 228 to 278 | clusters under the main reading: not built (too few genes)
Result: not reproduced. The Methods' pairwise t tests with Bonferroni correction find 2 genes over the 15 called SST CALB1 cells and none over the 10 culture microglial ones, against 253 (228 to 278). Clusters cannot be built on 2 genes, so the main reading fails. The code's one-against-rest variant finds 431 genes (451 rows as FindAllMarkers counts them); it leaves out the code's keepGenes and immune-gene filters, which only remove genes, so 431 is an upper bound and a count within 228 to 278 is not excluded under that reading. On the variant genes three clusters form, but MC and sparse SST cells have their majority in the same cluster under all five seeds. The main reading's 2 genes, against the paper's 253, suggests that the pairwise tests the Methods describe are not the procedure the paper ran, so its failure may say as much about the description as about the data.
PVALB WFDC2, acute against culture¶
The electrophysiology claims below use the features computed here from the NWB files, labelled through cell-metadata-link.
W = E[E.ttype == "Inh L2-4 PVALB WFDC2"].copy()
print("PVALB WFDC2 cells with a QC-passing long square sweep:", W.condition.value_counts().to_dict(),
"| by condition2", W.condition2.value_counts().to_dict(), "| donors", W.Donor.nunique())
MW_W = L.mannwhitney_table(W, FEATS, "condition", "acute", "culture")
print("features tested", len(MW_W), "| significant at BH-FDR < 0.05 across these features:", int((MW_W.p_fdr < 0.05).sum()))
PVALB WFDC2 cells with a QC-passing long square sweep: {'culture': 82, 'acute': 65} | by condition2 {'culture': 59, 'acute': 36, 'acute_microglial': 29, 'culture_microglial': 23} | donors 68
features tested 65 | significant at BH-FDR < 0.05 across these features: 41
figs2b-wfdc2-ephys-43-of-84¶
In PVALB WFDC2 neurons, 43 of 84 electrophysiological features differ between the acute and culture paradigms.
Per feature a two-sided Mann-Whitney, BH-FDR across features, at FDR p < 0.05. Only the features public IPFX computes are measured here. The count over all 84 is bounded: the missing features add at most their number to the count, and they change the BH adjustment of the others; the bounds take them all non-significant (p = 1) or all significant (p = 0).
p = MW_W.p.dropna().values
n_missing = len(FEATS84) - len(p)
def bh_count(pvals):
return int((L.bh(pvals) < 0.05).sum())
lo = bh_count(np.concatenate([p, np.ones(n_missing)]))
hi = bh_count(np.concatenate([p, np.zeros(n_missing)]))
own = bh_count(p)
print(f"features with a test here {len(p)}; missing from the 84: {n_missing}")
print(f"significant over the features computed (BH over them): {own} of {len(p)} ({own / len(p):.1%}); paper 43 of 84 ({43/84:.1%})")
print(f"bounds for the count over 84: {lo} to {hi}; tolerance 38.7 to 47.3")
J84 = W[["specimen_id_x", "condition"]].merge(fx_paper, left_on="specimen_id_x", right_on="specimen_id")
mw_paper = L.mannwhitney_table(J84, FEATS84, "condition", "acute", "culture")
print("variant, on the paper's own table for the same cells (all 84):", int((mw_paper.p_fdr < 0.05).sum()), "| all 93:",
int((L.mannwhitney_table(J84, FEATS84 + L.CHIRP, "condition", "acute", "culture").p_fdr < 0.05).sum()))
mix = MW_W[["feature", "p"]].set_index("feature").p.reindex(FEATS84)
mix = mix.fillna(mw_paper.set_index("feature").p)
print("variant, computed features with the paper's values for the missing ones:", bh_count(mix.dropna().values))
for c2 in ["culture", "culture_microglial"]:
sub = W[W.condition2.isin(["acute", "acute_microglial", c2])]
t2 = L.mannwhitney_table(sub, FEATS, "condition", "acute", "culture")
print(f"variant, culture cells restricted to {c2}: {int((t2.p_fdr < 0.05).sum())} of {len(t2)}")
inside = 38.7 <= lo and hi <= 47.3
outside = hi < 38.7 or lo > 47.3
print("RESULT figs2b:", "inside" if inside else ("outside" if outside else "undecided"), (lo, hi))
features with a test here 65; missing from the 84: 19 significant over the features computed (BH over them): 41 of 65 (63.1%); paper 43 of 84 (51.2%) bounds for the count over 84: 39 to 61; tolerance 38.7 to 47.3
variant, on the paper's own table for the same cells (all 84): 47 | all 93: 53 variant, computed features with the paper's values for the missing ones: 50 variant, culture cells restricted to culture: 37 of 65 variant, culture cells restricted to culture_microglial: 30 of 65 RESULT figs2b: undecided (39, 61)
Result: blocked. 19 of the 84 features need code the paper has not released, so the count over 84 is bounded between 39 and 61 and the tolerance (38.7 to 47.3) lies inside the bounds. Over the 65 features computed, 41 differ (63%, against the paper's 51%). On the paper's own table, the same cells give 47 of 84.
fig1l-width-sag-differ¶
In PVALB WFDC2 neurons AP width and sag differ between acute and culture slices (sag is higher in culture), while interspike interval and input resistance do not.
Two-sided Mann-Whitney, BH-FDR across the features computed (the 84 cannot all be computed). Width read as rheo, hero, short square and ramp; ISI as mean_isi_rheo and mean_isi_hero. The sampling rate of the files by condition, the test over 50 kHz files only, and the largest FDR values BH over all 84 features could give are shown as variants.
t = MW_W.set_index("feature")
show = ["sag", "width_rheo", "width_hero", "width_short_square", "width_ramp", "mean_isi_rheo", "mean_isi_hero", "input_resistance"]
print(t.loc[show, ["n_a", "n_b", "median_a", "median_b", "p", "p_fdr", "rbc"]].to_string(float_format=lambda v: f"{v:.4g}"))
sag_ok = t.loc["sag", "p_fdr"] < 1e-4 and t.loc["sag", "median_b"] > t.loc["sag", "median_a"]
outcomes = {}
for w in ["width_rheo", "width_hero", "width_short_square", "width_ramp"]:
for isi in ["mean_isi_rheo", "mean_isi_hero"]:
outcomes[(w, isi)] = bool(sag_ok and t.loc[w, "p_fdr"] < 1e-4 and t.loc[isi, "p_fdr"] >= 0.05 and t.loc["input_resistance", "p_fdr"] >= 0.05)
print("sag higher in culture at FDR p < 1e-4:", bool(sag_ok))
for k, v in outcomes.items():
print(k, v, "| width direction culture/acute median ratio %.2f" % (t.loc[k[0], "median_b"] / t.loc[k[0], "median_a"]))
print("by condition and donor count: acute donors", W[W.condition == "acute"].Donor.nunique(), "culture donors", W[W.condition == "culture"].Donor.nunique())
print("RESULT fig1l: all readings", all(outcomes.values()), "| any", any(outcomes.values()))
print("sampling rate of the analysed sweeps by condition, PVALB WFDC2 cells:"); print(pd.crosstab(W.rates.astype(str), W.condition))
W50 = W[W.rates.astype(str) == "[50000.0]"]
t50 = L.mannwhitney_table(W50, FEATS, "condition", "acute", "culture").set_index("feature")
print("variant, 50 kHz files only (BH over the same features):")
print(t50.loc[show, ["n_a", "n_b", "median_a", "median_b", "p", "p_fdr"]].to_string(float_format=lambda v: f"{v:.4g}"))
p84 = np.concatenate([MW_W.p.values, np.ones(len(FEATS84) - len(MW_W))])
worst = pd.Series(L.bh(p84)[:len(MW_W)], index=MW_W.feature)
print("variant, BH over 84 with the 19 missing features at p = 1 (the largest these FDR values can be):",
worst.loc[show].map(lambda v: f"{v:.3g}").to_dict())
n_a n_b median_a median_b p p_fdr rbc
feature
sag 65 80 0.1103 0.2843 1.846e-16 1.2e-14 0.7965
width_rheo 61 77 0.00044 0.00054 1.719e-05 5.586e-05 0.4269
width_hero 65 80 0.00042 0.0005 1.635e-06 6.641e-06 0.4637
width_short_square 64 79 0.00041 0.00048 2.718e-05 7.68e-05 0.4088
width_ramp 63 74 0.0004933 0.00056 0.003678 0.007712 0.2887
mean_isi_rheo 33 41 0.1008 0.1363 0.008497 0.0157 0.3585
mean_isi_hero 63 75 0.03797 0.04314 0.6474 0.7515 0.0455
input_resistance 65 80 148.8 140.8 0.7309 0.8053 -0.03346
sag higher in culture at FDR p < 1e-4: True
('width_rheo', 'mean_isi_rheo') False | width direction culture/acute median ratio 1.23
('width_rheo', 'mean_isi_hero') True | width direction culture/acute median ratio 1.23
('width_hero', 'mean_isi_rheo') False | width direction culture/acute median ratio 1.19
('width_hero', 'mean_isi_hero') True | width direction culture/acute median ratio 1.19
('width_short_square', 'mean_isi_rheo') False | width direction culture/acute median ratio 1.17
('width_short_square', 'mean_isi_hero') True | width direction culture/acute median ratio 1.17
('width_ramp', 'mean_isi_rheo') False | width direction culture/acute median ratio 1.14
('width_ramp', 'mean_isi_hero') False | width direction culture/acute median ratio 1.14
by condition and donor count: acute donors 40 culture donors 35
RESULT fig1l: all readings False | any True
sampling rate of the analysed sweeps by condition, PVALB WFDC2 cells:
condition acute culture
rates
[200000.0] 0 10
[50000.0] 65 72
variant, 50 kHz files only (BH over the same features):
n_a n_b median_a median_b p p_fdr
feature
sag 65 71 0.1103 0.2823 2.371e-15 1.541e-13
width_rheo 61 68 0.00044 0.00054 1.094e-05 3.556e-05
width_hero 65 71 0.00042 0.0005 9.444e-07 4.385e-06
width_short_square 64 70 0.00041 0.00048 7.49e-06 2.864e-05
width_ramp 63 65 0.0004933 0.00056 0.002267 0.004911
mean_isi_rheo 33 39 0.1008 0.1363 0.01291 0.02397
mean_isi_hero 63 67 0.03797 0.04314 0.6716 0.7659
input_resistance 65 71 148.8 137.3 0.5741 0.6911
variant, BH over 84 with the 19 missing features at p = 1 (the largest these FDR values can be): {'sag': '1.55e-14', 'width_rheo': '7.22e-05', 'width_hero': '8.58e-06', 'width_short_square': '9.92e-05', 'width_ramp': '0.00997', 'mean_isi_rheo': '0.0203', 'mean_isi_hero': '0.971', 'input_resistance': '1'}
Result: blocked. The readings disagree. Sag is higher in culture (median 0.284 against 0.110, FDR p = 1.2e-14). AP width is wider in culture at FDR p < 1e-4 for the rheobase, hero and short square sweeps, but not the ramp (FDR p = 0.0077). Input resistance does not differ (FDR p = 0.81). The hero-sweep ISI does not differ (FDR p = 0.75), but the rheobase-sweep ISI does (FDR p = 0.016, 74 cells). The 10 culture cells sampled at 200 kHz do not explain the width difference: over 50 kHz files only, width differs at FDR p 4.4e-06 to 3.6e-05 for the same three sweeps. With BH over 84 features (the 19 missing ones at p = 1), width_short_square has FDR p 9.9e-05, just under 1e-4.
figs2c-no-change-with-days¶
The features that differ in culture already differ at 2 days in culture and do not change with further days in culture.
Pearson's correlation of sag and of AP width with days in culture over culture PVALB WFDC2 cells, BH over the two; and the 2 DIC cells against the acute median.
Wc = W[W.condition == "culture"]
acute_med = W[W.condition == "acute"][["sag"] + ["width_rheo", "width_hero", "width_short_square", "width_ramp"]].median()
print("culture PVALB WFDC2 cells by days in culture:", Wc.Days_In_culture.value_counts().sort_index().to_dict())
print("all 2 DIC cells in the dandiset:", E[E.Days_In_culture == 2][["ttype", "subclass"]].values.tolist())
res = {}
for w in ["width_rheo", "width_hero", "width_short_square", "width_ramp"]:
ps, rs = [], []
for f in ["sag", w]:
d = Wc[[f, "Days_In_culture"]].dropna()
r, p = stats.pearsonr(d.Days_In_culture, d[f]); ps.append(p); rs.append(r)
pf = L.bh(ps)
res[w] = dict(r_sag=rs[0], p_sag=pf[0], r_width=rs[1], p_width=pf[1])
print(pd.DataFrame(res).T.round(4))
early = Wc[Wc.Days_In_culture == Wc.Days_In_culture.min()]
print("earliest DIC among culture PVALB WFDC2:", int(Wc.Days_In_culture.min()), "cells", len(early))
for f in ["sag", "width_rheo", "width_hero", "width_short_square", "width_ramp"]:
print(f" {f}: earliest-DIC median {early[f].median():.4g}, acute median {acute_med[f]:.4g}, culture median {Wc[f].median():.4g}")
for f in MW_W[MW_W.p_fdr < 0.05].feature:
pass
sigf = MW_W[MW_W.p_fdr < 0.05].feature.tolist()
pp = []
for f in sigf:
d = Wc[[f, "Days_In_culture"]].dropna()
pp.append(stats.pearsonr(d.Days_In_culture, d[f])[1] if len(d) > 2 and d[f].nunique() > 1 else np.nan)
print(f"variant, all {len(sigf)} differing features: significant correlations with DIC at BH < 0.05:", int((L.bh(pp) < 0.05).sum()))
culture PVALB WFDC2 cells by days in culture: {2.0: 1, 3.0: 10, 4.0: 10, 5.0: 6, 6.0: 22, 7.0: 18, 8.0: 2, 9.0: 4, 10.0: 2, 11.0: 2, 13.0: 1, 14.0: 1, 15.0: 2, 16.0: 1}
all 2 DIC cells in the dandiset: [['Inh L2-4 PVALB WFDC2', 'PVALB'], ['Inh L2-4 SST FRZB', 'PVALB']]
r_sag p_sag r_width p_width
width_rheo 0.074 0.6290 0.0559 0.6290
width_hero 0.074 0.5140 0.0831 0.5140
width_short_square 0.074 0.5140 0.3715 0.0015
width_ramp 0.074 0.6964 -0.0461 0.6964
earliest DIC among culture PVALB WFDC2: 2 cells 1
sag: earliest-DIC median 0.3787, acute median 0.1103, culture median 0.2843
width_rheo: earliest-DIC median 0.00058, acute median 0.00044, culture median 0.00054
width_hero: earliest-DIC median 0.00054, acute median 0.00042, culture median 0.0005
width_short_square: earliest-DIC median 0.00056, acute median 0.00041, culture median 0.00048
width_ramp: earliest-DIC median 0.0006067, acute median 0.0004933, culture median 0.00056
variant, all 41 differing features: significant correlations with DIC at BH < 0.05: 4
Result: blocked. It depends on fig1l-width-sag-differ, and its own width readings disagree. Sag does not correlate with days in culture (r = 0.07). Width does not correlate for the rheobase, hero and ramp sweeps, but does for the short square (r = 0.37, FDR p = 0.0015). The one 2 DIC PVALB WFDC2 cell has higher sag and wider APs than the acute median, as the culture group does.
Feature sets for the neighbour measures¶
The neighbour claims name the 84 features (reading a). Public IPFX computes 65 of them here. The measures are computed on these 65 (the dataset), and, as variants, on the paper's own table for the same cells (all 84) and on the 65 computed here with the paper's values for the 19 missing ones. The paper's table is the paper's derived data, not the dataset, so the variants show how far the missing features could move a result; they do not decide it.
JP = E[["specimen_id_x"]].merge(fx_paper, left_on="specimen_id_x", right_on="specimen_id", how="left")
JP.index = E.index
MISSING19 = [c for c in FEATS84 if c not in FEATS]
RAW = {"computed 65": E[FEATS], "paper's table, 84": JP[FEATS84], "computed 65 + paper's 19": pd.concat([E[FEATS], JP[MISSING19]], axis=1)}
print("cells with a row in the paper's feature table:", int(JP.specimen_id.notna().sum()), "of", len(E))
cells with a row in the paper's feature table: 681 of 686
fig1i-wfdc2-ephys-umap-overlap¶
In electrophysiology UMAP space of all 84 features, acute and culture PVALB WFDC2 neurons occupy a similar space.
All cells, the computed features z-scored with missing values at the median; for each PVALB WFDC2 cell, the fraction of its 15 nearest PVALB WFDC2 neighbours from the other condition, against 1000 label shuffles; in feature space and in a default umap-learn embedding.
Z_all = L.zscore_impute(E[FEATS])
def cross_fraction(Xs, lab, mask, k):
qidx, nb = L.neighbour_fraction(Xs, lab, k, among=mask, query=mask)
own = lab[qidx]
frac = np.array([np.mean(n != o) for n, o in zip(nb, own)])
return {g_: frac[own == g_].mean() for g_ in np.unique(own)}
def overlap_test(Xs, lab, mask, k, rng, nshuf=1000):
obs = cross_fraction(Xs, lab, mask, k)
labm = lab.copy()
null = {g_: [] for g_ in obs}
idx = np.where(mask)[0]
for _ in range(nshuf):
labm[idx] = rng.permutation(lab[idx])
cf = cross_fraction(Xs, labm, mask, k)
for g_ in obs:
null[g_].append(cf[g_])
return {g_: (obs[g_], np.median(null[g_])) for g_ in obs}
labW = E.condition.values
maskW = (E.ttype == "Inh L2-4 PVALB WFDC2").values
OUT_1i = {}
for off in SEED_OFFSETS:
sd = seed("fig1i-wfdc2-ephys-umap-overlap") + off
emb = L.umap_embed(Z_all, sd)
rng = np.random.default_rng(seed("fig1i-wfdc2-ephys-umap-overlap", 1) + off)
for space, Xs in [("features", Z_all.values), ("umap", emb)]:
for k in ([15, 10, 30] if off == 0 else [15]):
r_ = overlap_test(Xs, labW, maskW, k, rng, nshuf=1000 if k == 15 else 200)
OUT_1i[(off, space, k)] = r_
print(f"seed+{off} {space:8s} k={k}: " + ", ".join(f"{g_} cross {o:.3f} vs shuffle median {n:.3f} (ratio {o/n:.2f})" for g_, (o, n) in r_.items()))
holds = {key: all(o >= 0.5 * n for o, n in v.values()) for key, v in OUT_1i.items() if key[2] == 15}
print("criterion holds (k=15, both spaces) per seed offset:", {off: holds[(off, "features", 15)] and holds[(off, "umap", 15)] for off in SEED_OFFSETS})
print("variants on the feature set (claim's seed, k = 15):")
for vname in ["paper's table, 84", "computed 65 + paper's 19"]:
Zv = L.zscore_impute(RAW[vname])
embv = L.umap_embed(Zv, seed("fig1i-wfdc2-ephys-umap-overlap"))
rng = np.random.default_rng(seed("fig1i-wfdc2-ephys-umap-overlap", 1))
for space, Xs in [("features", Zv.values), ("umap", embv)]:
r_ = overlap_test(Xs, labW, maskW, 15, rng)
print(f" {vname}, {space}: " + ", ".join(f"{g_} cross {o:.3f} vs shuffle median {n:.3f} (ratio {o/n:.2f})" for g_, (o, n) in r_.items())
+ f"; holds {all(o >= 0.5 * n for o, n in r_.values())}")
seed+0 features k=15: acute cross 0.408 vs shuffle median 0.563 (ratio 0.72), culture cross 0.191 vs shuffle median 0.446 (ratio 0.43)
seed+0 features k=10: acute cross 0.378 vs shuffle median 0.566 (ratio 0.67), culture cross 0.159 vs shuffle median 0.443 (ratio 0.36)
seed+0 features k=30: acute cross 0.481 vs shuffle median 0.558 (ratio 0.86), culture cross 0.218 vs shuffle median 0.449 (ratio 0.48)
seed+0 umap k=15: acute cross 0.432 vs shuffle median 0.563 (ratio 0.77), culture cross 0.307 vs shuffle median 0.446 (ratio 0.69)
seed+0 umap k=10: acute cross 0.422 vs shuffle median 0.563 (ratio 0.75), culture cross 0.318 vs shuffle median 0.447 (ratio 0.71)
seed+0 umap k=30: acute cross 0.444 vs shuffle median 0.565 (ratio 0.79), culture cross 0.294 vs shuffle median 0.446 (ratio 0.66)
seed+1000 features k=15: acute cross 0.408 vs shuffle median 0.563 (ratio 0.73), culture cross 0.191 vs shuffle median 0.446 (ratio 0.43)
seed+1000 umap k=15: acute cross 0.444 vs shuffle median 0.562 (ratio 0.79), culture cross 0.324 vs shuffle median 0.446 (ratio 0.72)
seed+2000 features k=15: acute cross 0.408 vs shuffle median 0.562 (ratio 0.73), culture cross 0.191 vs shuffle median 0.446 (ratio 0.43)
seed+2000 umap k=15: acute cross 0.440 vs shuffle median 0.563 (ratio 0.78), culture cross 0.315 vs shuffle median 0.446 (ratio 0.71)
seed+3000 features k=15: acute cross 0.408 vs shuffle median 0.564 (ratio 0.72), culture cross 0.191 vs shuffle median 0.446 (ratio 0.43)
seed+3000 umap k=15: acute cross 0.442 vs shuffle median 0.563 (ratio 0.79), culture cross 0.331 vs shuffle median 0.445 (ratio 0.74)
seed+4000 features k=15: acute cross 0.408 vs shuffle median 0.562 (ratio 0.73), culture cross 0.191 vs shuffle median 0.449 (ratio 0.43)
seed+4000 umap k=15: acute cross 0.434 vs shuffle median 0.562 (ratio 0.77), culture cross 0.305 vs shuffle median 0.446 (ratio 0.68)
criterion holds (k=15, both spaces) per seed offset: {0: False, 1000: False, 2000: False, 3000: False, 4000: False}
variants on the feature set (claim's seed, k = 15):
paper's table, 84, features: acute cross 0.446 vs shuffle median 0.564 (ratio 0.79), culture cross 0.227 vs shuffle median 0.444 (ratio 0.51); holds True
paper's table, 84, umap: acute cross 0.462 vs shuffle median 0.562 (ratio 0.82), culture cross 0.336 vs shuffle median 0.447 (ratio 0.75); holds True
computed 65 + paper's 19, features: acute cross 0.403 vs shuffle median 0.562 (ratio 0.72), culture cross 0.202 vs shuffle median 0.446 (ratio 0.45); holds False
computed 65 + paper's 19, umap: acute cross 0.412 vs shuffle median 0.564 (ratio 0.73), culture cross 0.312 vs shuffle median 0.446 (ratio 0.70); holds True
Result: not reproduced. In feature space, a culture PVALB WFDC2 cell has a mean of 0.19 acute cells among its 15 nearest PVALB WFDC2 neighbours, against 0.45 for shuffled labels (ratio 0.43, under the criterion's 0.5), under all five seeds. Acute cells have a ratio of 0.72. In the UMAP embedding the ratios are 0.68 to 0.82, which passes. With 30 neighbours the feature-space culture ratio is 0.48. The 19 missing features do not explain the failure: with the paper's values for them added, the feature-space culture ratio is 0.45. On the paper's own table of all 84 features it is 0.51, just above the threshold, so the features computed here differ from the paper's in a way that moves this result.
fig2b-ephys-umap-subclasses¶
The four GABAergic subclasses are separable in electrophysiology feature space, with PVALB neurons occupying the most distinct region.
For each cell, the fraction of its 15 nearest neighbours of its own subclass (Revised_subclass_label), in feature space and a default umap-learn embedding.
labS = E.subclass.values
share = pd.Series(labS).value_counts(normalize=True)
OUT_2b = {}
for off in SEED_OFFSETS:
emb = L.umap_embed(Z_all, seed("fig2b-ephys-umap-subclasses") + off)
for space, Xs in ([("features", Z_all.values)] if off == 0 else []) + [("umap", emb)]:
qidx, nb = L.neighbour_fraction(Xs, labS, 15)
same = pd.Series([np.mean(n == labS[q]) for q, n in zip(qidx, nb)]).groupby(labS[qidx]).mean()
tab = pd.DataFrame({"same_fraction": same, "share": share, "excess": same - share})
ok = bool((tab.excess >= 0.2).all() and tab.same_fraction.idxmax() == "PVALB")
OUT_2b[(off, space)] = ok
print(f"seed+{off} {space}: ok={ok}"); print(tab.round(3).to_string())
print("by subclass, cells:", pd.Series(labS).value_counts().to_dict())
print("variants on the feature set (feature space, and the UMAP of the claim's seed):")
for vname in ["paper's table, 84", "computed 65 + paper's 19"]:
Zv = L.zscore_impute(RAW[vname])
for space, Xs in [("features", Zv.values), ("umap", L.umap_embed(Zv, seed("fig2b-ephys-umap-subclasses")))]:
qidx, nb = L.neighbour_fraction(Xs, labS, 15)
same = pd.Series([np.mean(n == labS[q]) for q, n in zip(qidx, nb)]).groupby(labS[qidx]).mean()
ex = (same - share).round(3)
print(f" {vname}, {space}: same-subclass fraction {same.round(3).to_dict()}; excess {ex.to_dict()}; "
f"ok {bool((ex >= 0.2).all() and same.idxmax() == 'PVALB')}")
seed+0 features: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.433 0.093 0.340
PVALB 0.844 0.529 0.315
SST 0.454 0.230 0.223
VIP 0.342 0.147 0.195
seed+0 umap: ok=True
same_fraction share excess
LAMP5/PAX6/Other 0.402 0.093 0.309
PVALB 0.879 0.529 0.350
SST 0.439 0.230 0.209
VIP 0.417 0.147 0.269
seed+1000 umap: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.403 0.093 0.310
PVALB 0.877 0.529 0.348
SST 0.427 0.230 0.197
VIP 0.396 0.147 0.249
seed+2000 umap: ok=True
same_fraction share excess
LAMP5/PAX6/Other 0.429 0.093 0.336
PVALB 0.871 0.529 0.342
SST 0.462 0.230 0.232
VIP 0.381 0.147 0.234
seed+3000 umap: ok=True
same_fraction share excess
LAMP5/PAX6/Other 0.397 0.093 0.304
PVALB 0.877 0.529 0.347
SST 0.447 0.230 0.217
VIP 0.389 0.147 0.242
seed+4000 umap: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.399 0.093 0.306
PVALB 0.876 0.529 0.347
SST 0.429 0.230 0.199
VIP 0.393 0.147 0.246
by subclass, cells: {'PVALB': 363, 'SST': 158, 'VIP': 101, 'LAMP5/PAX6/Other': 64}
variants on the feature set (feature space, and the UMAP of the claim's seed):
paper's table, 84, features: same-subclass fraction {'LAMP5/PAX6/Other': 0.477, 'PVALB': 0.823, 'SST': 0.523, 'VIP': 0.358}; excess {'LAMP5/PAX6/Other': 0.384, 'PVALB': 0.294, 'SST': 0.292, 'VIP': 0.211}; ok True
paper's table, 84, umap: same-subclass fraction {'LAMP5/PAX6/Other': 0.504, 'PVALB': 0.859, 'SST': 0.498, 'VIP': 0.405}; excess {'LAMP5/PAX6/Other': 0.411, 'PVALB': 0.33, 'SST': 0.268, 'VIP': 0.258}; ok True
computed 65 + paper's 19, features: same-subclass fraction {'LAMP5/PAX6/Other': 0.478, 'PVALB': 0.853, 'SST': 0.486, 'VIP': 0.369}; excess {'LAMP5/PAX6/Other': 0.385, 'PVALB': 0.324, 'SST': 0.256, 'VIP': 0.222}; ok True
computed 65 + paper's 19, umap: same-subclass fraction {'LAMP5/PAX6/Other': 0.479, 'PVALB': 0.876, 'SST': 0.454, 'VIP': 0.401}; excess {'LAMP5/PAX6/Other': 0.386, 'PVALB': 0.347, 'SST': 0.224, 'VIP': 0.253}; ok True
Result: blocked (methods underspecified). PVALB has the highest same-subclass fraction in every space and seed (0.84 in feature space, 0.88 in UMAP). In feature space three subclasses exceed their share by at least 0.2 and VIP by 0.195. In the UMAP all four pass under the claim's seed (smallest excess SST 0.202) and three others, and SST misses under +1000 (0.200, under 0.2 before rounding). With the 19 missing features added from the paper's table, all four exceed their share by at least 0.2 in both spaces (smallest excess 0.222 in both), and on the paper's own table as well (0.211 and 0.256). The failing part rests on the 19 features public IPFX does not compute. The criterion asks for the 84 features and only 65 can be computed from the dataset, so separability cannot be decided on the data, as for figs2b-wfdc2-ephys-43-of-84, which is blocked for the same 19 features. The third verification round agreed. UMAP numbers differ between machines under the same seed: in the executed copy that round reviewed, the smallest UMAP excess under the claim's seed was 0.209, SST missed under +1000 (0.197) and +4000 (0.199), and the UMAP with the 19 features added gave 0.224.
fig2f-ap-kinetics¶
APs of the PVALB subclass have the fastest kinetics, and LAMP5/PAX6 APs have the highest peak amplitude of the four subclasses.
Kruskal-Wallis with Dunn's post hoc (BH-FDR over pairs); short square features first, rheobase sweep second.
SUBS = ["LAMP5/PAX6/Other", "VIP", "SST", "PVALB"]
def kd_report(df, f, gcol, groups):
p, dunn, med = L.kruskal_dunn(df, f, gcol, groups)
print(f"--- {f}: KW p={p:.3g}"); print(med.T.round(5).to_string()); print("Dunn FDR p:"); print(dunn.map(lambda v: f"{v:.2g}").to_string())
return p, dunn, med
res2f = {}
for sw in ["short_square", "rheo"]:
ok = True
for f, best, how in [(f"width_{sw}", "PVALB", "min"), (f"upstroke_downstroke_ratio_{sw}", "PVALB", "min"), (f"peak_deltav_{sw}", "LAMP5/PAX6/Other", "max")]:
p, dunn, med = kd_report(E, f, "subclass", SUBS)
m_ = med["median"]
top_ = m_.idxmin() if how == "min" else m_.idxmax()
pair_ok = all(dunn.loc[best, o] < 0.05 for o in SUBS if o != best)
print(f" extreme group {top_} (expected {best}); Dunn p < 0.05 against every other: {pair_ok}")
ok &= (top_ == best) and pair_ok
res2f[(sw, f)] = (top_ == best, pair_ok)
print("reading", sw, "holds:", ok)
--- width_short_square: KW p=1.15e-62
subclass LAMP5/PAX6/Other PVALB SST VIP
median 0.00066 0.00048 0.00074 0.00071
count 63.00000 352.00000 153.00000 99.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.097 0.037 2.1e-14
VIP 0.097 1 0.67 1.5e-31
SST 0.037 0.67 1 3e-46
PVALB 2.1e-14 1.5e-31 3e-46 1
extreme group PVALB (expected PVALB); Dunn p < 0.05 against every other: True
--- upstroke_downstroke_ratio_short_square: KW p=1.18e-40
subclass LAMP5/PAX6/Other PVALB SST VIP
median 2.37515 1.81166 2.27604 2.24641
count 63.00000 354.00000 153.00000 99.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.073 0.79 5.4e-17
VIP 0.073 1 0.063 7.1e-14
SST 0.79 0.063 1 2e-30
PVALB 5.4e-17 7.1e-14 2e-30 1
extreme group PVALB (expected PVALB); Dunn p < 0.05 against every other: True
--- peak_deltav_short_square: KW p=0.000203
subclass LAMP5/PAX6/Other PVALB SST VIP
median 71.86875 67.38125 69.9 70.60782
count 63.00000 354.00000 153.0 99.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.08 0.039 0.00036
VIP 0.08 1 0.77 0.039
SST 0.039 0.77 1 0.039
PVALB 0.00036 0.039 0.039 1
extreme group LAMP5/PAX6/Other (expected LAMP5/PAX6/Other); Dunn p < 0.05 against every other: False
reading short_square holds: False
--- width_rheo: KW p=2.41e-51
subclass LAMP5/PAX6/Other PVALB SST VIP
median 0.00074 0.00052 0.0008 0.00076
count 58.00000 336.00000 134.0000 77.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.45 0.39 4.5e-15
VIP 0.45 1 0.87 1.2e-23
SST 0.39 0.87 1 1.6e-36
PVALB 4.5e-15 1.2e-23 1.6e-36 1
extreme group PVALB (expected PVALB); Dunn p < 0.05 against every other: True
--- upstroke_downstroke_ratio_rheo: KW p=5.56e-57
subclass LAMP5/PAX6/Other PVALB SST VIP
median 2.51915 1.68217 2.32493 2.3371
count 58.00000 336.00000 134.00000 78.0000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.56 0.68 1.1e-22
VIP 0.56 1 0.64 8.9e-23
SST 0.68 0.64 1 2e-38
PVALB 1.1e-22 8.9e-23 2e-38 1
extreme group PVALB (expected PVALB); Dunn p < 0.05 against every other: True
--- peak_deltav_rheo: KW p=1.08e-20
subclass LAMP5/PAX6/Other PVALB SST VIP
median 70.5625 58.91563 67.23125 68.3625
count 63.0000 358.00000 155.00000 99.0000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.014 0.061 6.8e-13
VIP 0.014 1 0.33 5.2e-07
SST 0.061 0.33 1 6.8e-13
PVALB 6.8e-13 5.2e-07 6.8e-13 1
extreme group LAMP5/PAX6/Other (expected LAMP5/PAX6/Other); Dunn p < 0.05 against every other: False
reading rheo holds: False
Result: partially reproduced. PVALB APs have the narrowest width and the lowest upstroke/downstroke ratio, with Dunn's p < 0.05 against every subclass, for both the short square and the rheobase sweep. LAMP5/PAX6 have the highest median peak in both readings, but not significantly against VIP for the short square (p = 0.08) and against SST for the rheobase sweep (p = 0.061).
fig2g-sag-by-subclass¶
LAMP5/PAX6 and VIP neurons have minimal sag compared with PVALB and SST neurons.
Kruskal-Wallis with Dunn's post hoc over the four subclasses, pooled over conditions as the criterion does; the same within acute and within culture cells is shown as a variant, as the subclass mix differs by condition.
p, dunn, med = kd_report(E, "sag", "subclass", SUBS)
m_ = med["median"]
pairs = [(a_, b_) for a_ in ["LAMP5/PAX6/Other", "VIP"] for b_ in ["PVALB", "SST"]]
ok = all(m_[a_] < m_[b_] and dunn.loc[a_, b_] < 0.05 for a_, b_ in pairs)
print({f"{a_} vs {b_}": (round(m_[a_], 3), round(m_[b_], 3), float(dunn.loc[a_, b_])) for a_, b_ in pairs})
print("by condition (acute / culture) medians and cells:"); print(E.groupby(["subclass", "condition"]).sag.agg(["median", "count"]).unstack().round(3))
for cnd in ["acute", "culture"]:
pc, dc, mc2 = L.kruskal_dunn(E[E.condition == cnd], "sag", "subclass", SUBS)
print(f"variant, {cnd} cells only: KW p={pc:.3g}; pairs (median a, median b, Dunn FDR p):",
{f"{a_} vs {b_}": (round(mc2.loc[a_, "median"], 3), round(mc2.loc[b_, "median"], 3), float(f"{dc.loc[a_, b_]:.3g}")) for a_, b_ in pairs})
print("RESULT fig2g:", ok)
--- sag: KW p=8.14e-18
subclass LAMP5/PAX6/Other PVALB SST VIP
median 0.10016 0.24074 0.30032 0.15259
count 63.00000 358.00000 155.00000 99.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.27 8.7e-13 1.9e-07
VIP 0.27 1 1.8e-12 1.9e-06
SST 8.7e-13 1.8e-12 1 0.00011
PVALB 1.9e-07 1.9e-06 0.00011 1
{'LAMP5/PAX6/Other vs PVALB': (np.float64(0.1), np.float64(0.241), 1.929106863700219e-07), 'LAMP5/PAX6/Other vs SST': (np.float64(0.1), np.float64(0.3), 8.662584715762286e-13), 'VIP vs PVALB': (np.float64(0.153), np.float64(0.241), 1.8962910490361484e-06), 'VIP vs SST': (np.float64(0.153), np.float64(0.3), 1.8357296059951442e-12)}
by condition (acute / culture) medians and cells:
median count
condition acute culture acute culture
subclass
LAMP5/PAX6/Other 0.059 0.256 39 24
PVALB 0.106 0.283 115 243
SST 0.251 0.303 19 136
VIP 0.167 0.133 57 42
variant, acute cells only: KW p=2.76e-09; pairs (median a, median b, Dunn FDR p): {'LAMP5/PAX6/Other vs PVALB': (np.float64(0.059), np.float64(0.106), 0.000344), 'LAMP5/PAX6/Other vs SST': (np.float64(0.059), np.float64(0.251), 2.27e-07), 'VIP vs PVALB': (np.float64(0.167), np.float64(0.106), 0.00477), 'VIP vs SST': (np.float64(0.167), np.float64(0.251), 0.197)}
variant, culture cells only: KW p=1.53e-10; pairs (median a, median b, Dunn FDR p): {'LAMP5/PAX6/Other vs PVALB': (np.float64(0.256), np.float64(0.283), 0.403), 'LAMP5/PAX6/Other vs SST': (np.float64(0.256), np.float64(0.303), 0.306), 'VIP vs PVALB': (np.float64(0.133), np.float64(0.283), 1.98e-10), 'VIP vs SST': (np.float64(0.133), np.float64(0.303), 1.36e-10)}
RESULT fig2g: True
Result: reproduced. The median sag is 0.10 for LAMP5/PAX6 and 0.15 for VIP, against 0.24 for PVALB and 0.30 for SST, and all four pairs differ (Dunn's p <= 1.9e-6). The pooled result mixes conditions: sag is higher in culture, and most LAMP5/PAX6 and VIP cells are acute. Within acute cells VIP (0.167) has higher sag than PVALB (0.106, Dunn p = 0.0048); within culture cells LAMP5/PAX6 (0.256) does not differ from PVALB (0.283) or SST (0.303). The criterion pools, as the paper does.
fig2h-several-features-distinct¶
Several additional electrophysiological features differ between the subclasses.
Kruskal-Wallis across subclasses for every computed feature, BH-FDR across features; counted outside width, upstroke/downstroke ratio, peak and sag features.
rows = []
for f in FEATS:
d = E[[f, "subclass"]].dropna()
samples = [d[d.subclass == s][f].values for s in SUBS]
if min(len(s) for s in samples) < 2 or d[f].nunique() < 2:
continue
rows.append(dict(feature=f, p=stats.kruskal(*samples).pvalue))
kw = pd.DataFrame(rows); kw["p_fdr"] = L.bh(kw.p)
excl = kw.feature.str.contains("width|upstroke_downstroke_ratio|peak_deltav|sag")
other = kw[~excl & (kw.p_fdr < 0.05)].sort_values("p_fdr")
print("features tested", len(kw), "| significant", int((kw.p_fdr < 0.05).sum()), "| outside width/ratio/peak/sag:", len(other))
n_dunn = 0
for f in other.feature:
_, dunn, _ = L.kruskal_dunn(E, f, "subclass", SUBS)
n_dunn += int((dunn.values[np.triu_indices(4, 1)] < 0.05).any())
print("of these, with at least one Dunn pair p < 0.05:", n_dunn)
print(other.head(15).to_string(float_format=lambda v: f"{v:.3g}"))
features tested 65 | significant 59 | outside width/ratio/peak/sag: 44
of these, with at least one Dunn pair p < 0.05: 43
feature p p_fdr
22 tau 1.99e-65 6.47e-64
43 downstroke_hero 1.91e-59 2.48e-58
52 upstroke_adapt_ratio 6.98e-57 5.67e-56
13 downstroke_short_square 9.9e-55 7.15e-54
56 fast_trough_v_adapt_ratio 2.43e-50 1.44e-49
30 downstroke_rheo 7.64e-49 4.14e-48
21 input_resistance 3.94e-47 1.83e-46
53 downstroke_adapt_ratio 1.15e-44 4.66e-44
17 rheobase_i 6.86e-44 2.62e-43
4 downstroke_ramp 8.74e-44 3.16e-43
7 fast_trough_deltav_ramp 5.66e-40 1.84e-39
59 fast_trough_deltav_rheo 1.48e-39 4.57e-39
5 threshold_i_ramp 8.69e-37 2.46e-36
6 trough_deltav_ramp 2.88e-35 7.81e-35
57 trough_deltav_rheo 1.48e-34 3.85e-34
Result: reproduced. 59 of 65 features differ across subclasses at FDR < 0.05. 44 of them are outside width, ratio, peak and sag, and 43 of those have a significant Dunn pair.
fig3c-frzb-ephys-with-pvalb¶
Most SST FRZB neurons colocalize with the PVALB subclass in electrophysiology space.
Groups: SST (subclass_label SST, not SST FRZB), PVALB (not SST FRZB), SST FRZB (t-type). Features z-scored over the SST and PVALB cells (median, mean and sd from them, applied to all three groups); for each SST FRZB cell, its 15 nearest SST or PVALB neighbours. Shown with the chance level: the fraction of cells with a PVALB majority, and the mean PVALB fraction, when the SST and PVALB labels of the reference cells are shuffled (1000 times). Variants: z-scoring over all three groups (round 1), and the feature sets with the paper's values.
F3 = E[E.subclass_label.isin(["SST", "PVALB"])].copy()
F3["grp"] = np.where(F3.ttype == "Inh L2-4 SST FRZB", "SST FRZB", F3.subclass_label)
print("groups:", F3.grp.value_counts().to_dict())
lab3g = np.asarray(F3.grp, dtype=object)
ref3 = lab3g != "SST FRZB"
n_ref, n_pv = int(ref3.sum()), int((lab3g[ref3] == "PVALB").sum())
print(f"PVALB share of the reference cells {n_pv / n_ref:.3f}; chance that 8 or more of 15 neighbours drawn at random are PVALB:",
f"{stats.hypergeom(n_ref, n_pv, 15).sf(7):.3f}")
def frzb_pv(Xs, lab):
qidx, nbi = L.neighbour_fraction(Xs, np.arange(len(Xs)), 15, among=lab != "SST FRZB", query=lab == "SST FRZB")
return np.array(nbi)
rng3 = np.random.default_rng(seed("fig3c-frzb-ephys-with-pvalb", 1))
Z3 = None
for zname, raw, zref, offs in [("z-scored over SST and PVALB cells (the criterion)", RAW["computed 65"], ref3, SEED_OFFSETS),
("z-scored over all three groups (round 1)", RAW["computed 65"], None, [0]),
("paper's table, 84", RAW["paper's table, 84"], ref3, [0]),
("computed 65 + paper's 19", RAW["computed 65 + paper's 19"], ref3, [0])]:
Zc = L.zscore_impute(raw.loc[F3.index], ref=zref)
if Z3 is None:
Z3 = Zc
for off in offs:
emb = L.umap_embed(Zc, seed("fig3c-frzb-ephys-with-pvalb") + off)
for space, Xs in ([("features", Zc.values)] if off == 0 else []) + [("umap", emb)]:
nbi = frzb_pv(Xs, lab3g)
pv_frac = (lab3g[nbi] == "PVALB").mean(1)
null, null_m = [], []
for _ in range(1000):
lp = lab3g.copy(); lp[ref3] = rng3.permutation(lab3g[ref3])
fr_ = (lp[nbi] == "PVALB").mean(1)
null.append((fr_ > 0.5).mean()); null_m.append(fr_.mean())
print(f"{zname} seed+{off} {space}: SST FRZB cells {len(pv_frac)}, with a PVALB majority {int((pv_frac > 0.5).sum())} ({(pv_frac > 0.5).mean():.2f}), "
f"mean PVALB fraction {pv_frac.mean():.2f}; shuffled reference labels: majority fraction median {np.median(null):.2f}, 99th percentile {np.quantile(null, 0.99):.2f}; "
f"mean PVALB fraction median {np.median(null_m):.2f}, 99th percentile {np.quantile(null_m, 0.99):.2f}")
groups: {'PVALB': 290, 'SST': 158, 'SST FRZB': 73}
PVALB share of the reference cells 0.647; chance that 8 or more of 15 neighbours drawn at random are PVALB: 0.886
z-scored over SST and PVALB cells (the criterion) seed+0 features: SST FRZB cells 73, with a PVALB majority 72 (0.99), mean PVALB fraction 0.85; shuffled reference labels: majority fraction median 0.90, 99th percentile 1.00; mean PVALB fraction median 0.65, 99th percentile 0.74 z-scored over SST and PVALB cells (the criterion) seed+0 umap: SST FRZB cells 73, with a PVALB majority 72 (0.99), mean PVALB fraction 0.87; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.71
z-scored over SST and PVALB cells (the criterion) seed+1000 umap: SST FRZB cells 73, with a PVALB majority 73 (1.00), mean PVALB fraction 0.87; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.70
z-scored over SST and PVALB cells (the criterion) seed+2000 umap: SST FRZB cells 73, with a PVALB majority 70 (0.96), mean PVALB fraction 0.86; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.71
z-scored over SST and PVALB cells (the criterion) seed+3000 umap: SST FRZB cells 73, with a PVALB majority 72 (0.99), mean PVALB fraction 0.87; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.64, 99th percentile 0.71
z-scored over SST and PVALB cells (the criterion) seed+4000 umap: SST FRZB cells 73, with a PVALB majority 72 (0.99), mean PVALB fraction 0.87; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.70
z-scored over all three groups (round 1) seed+0 features: SST FRZB cells 73, with a PVALB majority 72 (0.99), mean PVALB fraction 0.85; shuffled reference labels: majority fraction median 0.90, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.74 z-scored over all three groups (round 1) seed+0 umap: SST FRZB cells 73, with a PVALB majority 72 (0.99), mean PVALB fraction 0.87; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.71
paper's table, 84 seed+0 features: SST FRZB cells 73, with a PVALB majority 64 (0.88), mean PVALB fraction 0.77; shuffled reference labels: majority fraction median 0.90, 99th percentile 1.00; mean PVALB fraction median 0.65, 99th percentile 0.73 paper's table, 84 seed+0 umap: SST FRZB cells 73, with a PVALB majority 71 (0.97), mean PVALB fraction 0.85; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.70
computed 65 + paper's 19 seed+0 features: SST FRZB cells 73, with a PVALB majority 71 (0.97), mean PVALB fraction 0.85; shuffled reference labels: majority fraction median 0.90, 99th percentile 1.00; mean PVALB fraction median 0.65, 99th percentile 0.75 computed 65 + paper's 19 seed+0 umap: SST FRZB cells 73, with a PVALB majority 70 (0.96), mean PVALB fraction 0.83; shuffled reference labels: majority fraction median 0.89, 99th percentile 0.99; mean PVALB fraction median 0.65, 99th percentile 0.70
Result: reproduced. With features z-scored over the SST and PVALB cells, 72 of 73 SST FRZB cells have a PVALB majority among their 15 nearest SST or PVALB neighbours in feature space, and 70 to 72 in UMAP over the five seeds. The criterion's threshold (more than half of the cells) is below chance: with PVALB 0.65 of the reference, 0.886 of cells would have a PVALB majority among random neighbours, and shuffled labels give a median of 0.89 to 0.90. The mean PVALB fraction among the neighbours, 0.85 to 0.88, is above the shuffled 99th percentile (0.70 to 0.74). On the paper's own table of 84 features 64 of 73 (0.88) have a PVALB majority in feature space, at the chance level.
fig3e-frzb-ap-like-pvalb¶
The AP upstroke/downstroke ratio and AP width of SST FRZB neurons align with fast-spiking PVALB neurons and differ from SST neurons.
Kruskal-Wallis over the three groups, Dunn's post hoc (BH-FDR); rheobase, short square and rheobase + 40 pA (hero) sweeps.
G3 = ["SST", "SST FRZB", "PVALB"]
res3e = {}
for sw in ["rheo", "short_square", "hero"]:
for f in [f"upstroke_downstroke_ratio_{sw}", f"width_{sw}"]:
p, dunn, med = kd_report(F3, f, "grp", G3)
m_ = med["median"]
nearer = abs(m_["SST FRZB"] - m_["PVALB"]) < abs(m_["SST FRZB"] - m_["SST"])
res3e[f] = (bool(dunn.loc["SST FRZB", "SST"] < 1e-4), bool(nearer), float(dunn.loc["SST FRZB", "PVALB"]))
print(f" FRZB vs SST p<1e-4: {res3e[f][0]}; FRZB nearer PVALB: {nearer}; FRZB vs PVALB p={res3e[f][2]:.3g}")
print("RESULT fig3e:", all(v[0] and v[1] for v in res3e.values()), res3e)
--- upstroke_downstroke_ratio_rheo: KW p=4.84e-40
grp PVALB SST SST FRZB
median 1.67976 2.32493 1.69185
count 268.00000 134.00000 68.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 1.1e-19 2.4e-38
SST FRZB 1.1e-19 1 0.88
PVALB 2.4e-38 0.88 1
FRZB vs SST p<1e-4: True; FRZB nearer PVALB: True; FRZB vs PVALB p=0.876
--- width_rheo: KW p=7.5e-38
grp PVALB SST SST FRZB
median 0.00052 0.0008 0.0006
count 268.00000 134.0000 68.0000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 7.2e-09 1.5e-38
SST FRZB 7.2e-09 1 0.00017
PVALB 1.5e-38 0.00017 1
FRZB vs SST p<1e-4: True; FRZB nearer PVALB: True; FRZB vs PVALB p=0.000166
--- upstroke_downstroke_ratio_short_square: KW p=1.09e-31
grp PVALB SST SST FRZB
median 1.79177 2.27604 1.87845
count 283.00000 153.00000 71.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 6.4e-11 5.5e-32
SST FRZB 6.4e-11 1 0.067
PVALB 5.5e-32 0.067 1
FRZB vs SST p<1e-4: True; FRZB nearer PVALB: True; FRZB vs PVALB p=0.0665
--- width_short_square: KW p=2.35e-46
grp PVALB SST SST FRZB
median 0.00046 0.00074 0.00052
count 282.00000 153.00000 70.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 7.4e-12 4.2e-47
SST FRZB 7.4e-12 1 0.0006
PVALB 4.2e-47 0.0006 1
FRZB vs SST p<1e-4: True; FRZB nearer PVALB: True; FRZB vs PVALB p=0.0006
--- upstroke_downstroke_ratio_hero: KW p=2.59e-44
grp PVALB SST SST FRZB
median 1.73346 2.38455 1.76718
count 283.00000 151.00000 72.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 2e-19 4.6e-43
SST FRZB 2e-19 1 0.46
PVALB 4.6e-43 0.46 1
FRZB vs SST p<1e-4: True; FRZB nearer PVALB: True; FRZB vs PVALB p=0.461
--- width_hero: KW p=1.73e-49
grp PVALB SST SST FRZB
median 0.00048 0.00078 0.00056
count 283.00000 151.00000 72.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 7.6e-12 2.7e-50
SST FRZB 7.6e-12 1 7.8e-05
PVALB 2.7e-50 7.8e-05 1
FRZB vs SST p<1e-4: True; FRZB nearer PVALB: True; FRZB vs PVALB p=7.77e-05
RESULT fig3e: True {'upstroke_downstroke_ratio_rheo': (True, True, 0.8762361331359254), 'width_rheo': (True, True, 0.00016605590877121707), 'upstroke_downstroke_ratio_short_square': (True, True, 0.06651446225081369), 'width_short_square': (True, True, 0.0005999387045085892), 'upstroke_downstroke_ratio_hero': (True, True, 0.46052862565478503), 'width_hero': (True, True, 7.771563696409076e-05)}
Result: reproduced. For the rheobase, short square and hero sweeps, SST FRZB differs from SST in width and upstroke/downstroke ratio (Dunn's p 7.4e-12 to 7.2e-09 for width, 1.1e-19 to 6.4e-11 for the ratio), and its medians are nearer PVALB. SST FRZB still differs from PVALB in width (p 7.8e-05 to 0.0006) but not in the ratio (p 0.067 to 0.88).
figs6-sst-features-acute-culture¶
The upstroke/downstroke ratio and AP width of SST subclass neurons do not differ between acute and culture recordings.
A claim of absence: two-sided Mann-Whitney, acute against culture, BH-FDR over the two features of a sweep reading; SST (subclass_label) with and without SST FRZB.
anyd = False
for with_frzb in [True, False]:
S6 = E[(E.subclass_label == "SST") & (with_frzb | (E.ttype != "Inh L2-4 SST FRZB"))]
for sw in ["rheo", "short_square", "hero"]:
tt = L.mannwhitney_table(S6, [f"upstroke_downstroke_ratio_{sw}", f"width_{sw}"], "condition", "acute", "culture")
anyd |= bool((tt.p_fdr < 0.05).any())
print(f"SST {'with' if with_frzb else 'without'} FRZB, {sw}:"); print(tt[["feature", "n_a", "n_b", "median_a", "median_b", "p", "p_fdr", "rbc"]].to_string(float_format=lambda v: f"{v:.4g}"))
print("RESULT figs6: any difference", anyd)
SST with FRZB, rheo:
feature n_a n_b median_a median_b p p_fdr rbc
0 upstroke_downstroke_ratio_rheo 23 179 2.219 2.009 0.4088 0.4088 -0.1061
1 width_rheo 23 179 0.0008 0.00072 0.1754 0.3508 -0.1739
SST with FRZB, short_square:
feature n_a n_b median_a median_b p p_fdr rbc
0 upstroke_downstroke_ratio_short_square 25 199 2.18 2.095 0.8111 0.8111 -0.02955
1 width_short_square 25 198 0.00074 0.0006467 0.122 0.244 -0.1901
SST with FRZB, hero:
feature n_a n_b median_a median_b p p_fdr rbc
0 upstroke_downstroke_ratio_hero 25 198 2.245 2.092 0.6821 0.6821 -0.05051
1 width_hero 25 198 0.0008 0.00068 0.1097 0.2195 -0.1966
SST without FRZB, rheo:
feature n_a n_b median_a median_b p p_fdr rbc
0 upstroke_downstroke_ratio_rheo 17 117 2.364 2.31 0.784 0.784 -0.04173
1 width_rheo 17 117 0.00088 0.0008 0.1899 0.3798 -0.1976
SST without FRZB, short_square:
feature n_a n_b median_a median_b p p_fdr rbc
0 upstroke_downstroke_ratio_short_square 19 134 2.263 2.309 0.763 0.763 0.04321
1 width_short_square 19 134 0.00078 0.0007325 0.1135 0.2271 -0.2251
SST without FRZB, hero:
feature n_a n_b median_a median_b p p_fdr rbc
0 upstroke_downstroke_ratio_hero 19 132 2.311 2.39 0.6435 0.6435 0.06619
1 width_hero 19 132 0.00082 0.0007625 0.1682 0.3365 -0.1962
RESULT figs6: any difference False
Result: reproduced. Neither feature differs between acute and culture SST cells under any sweep reading, with or without SST FRZB (smallest FDR p 0.22; rank-biserial -0.23 to 0.07).
fig4c-calb1-ephys-by-morphology¶
Within SST CALB1, sparse SST neurons tend to have lower sag, higher adaptation ratio and slightly delayed AP onset than DBCs and MCs, and MCs have the highest AP peak.
SST CALB1 cells with a qualitative morphology type and a file here. Adaptation ratio is isi_adapt_ratio (the Methods' first-to-third spike ISI ratio as computed in the helper; its agreement with the paper's table is in cell-metadata-link); adapt_hero is shown as a variant only.
C4 = E[(E.ttype == "Inh L1-3 SST CALB1") & E.Qualitative_morphology_type.notna()].copy()
C4["mt"] = C4.Qualitative_morphology_type
print("cells by type:", C4.mt.value_counts().to_dict(), "| metadata (all, with or without a file):",
m1[m1.Transcriptomic_type == "Inh L1-3 SST CALB1"].Qualitative_morphology_type.value_counts().to_dict())
cols = ["sag", "isi_adapt_ratio", "latency_rheo", "latency_hero", "peak_deltav_rheo", "peak_deltav_hero", "adapt_hero"]
print(C4[["specimen_id_x", "mt"] + cols].sort_values("mt").to_string(float_format=lambda v: f"{v:.4g}"))
med4 = C4.groupby("mt")[cols].median()
print(med4.round(4).to_string())
sp_, dbc_, mc_ = "Sparse SST", "DBC", "MC"
st = {
"sag lower": bool(med4.loc[sp_, "sag"] < min(med4.loc[dbc_, "sag"], med4.loc[mc_, "sag"])),
"adaptation higher": bool(med4.loc[sp_, "isi_adapt_ratio"] > max(med4.loc[dbc_, "isi_adapt_ratio"], med4.loc[mc_, "isi_adapt_ratio"])),
"latency higher (rheo)": bool(med4.loc[sp_, "latency_rheo"] > max(med4.loc[dbc_, "latency_rheo"], med4.loc[mc_, "latency_rheo"])),
"latency higher (hero)": bool(med4.loc[sp_, "latency_hero"] > max(med4.loc[dbc_, "latency_hero"], med4.loc[mc_, "latency_hero"])),
"MC peak highest (rheo)": bool(med4["peak_deltav_rheo"].idxmax() == mc_),
"MC peak highest (hero)": bool(med4["peak_deltav_hero"].idxmax() == mc_),
}
print(st)
print("variant, adapt_hero (adaptation index): sparse higher than DBC and MC:",
bool(med4.loc[sp_, "adapt_hero"] > max(med4.loc[dbc_, "adapt_hero"], med4.loc[mc_, "adapt_hero"])))
Jc = C4[["specimen_id_x", "mt"]].merge(fx_paper[["specimen_id", "isi_adapt_ratio"]], left_on="specimen_id_x", right_on="specimen_id")
print("variant, the paper's own isi_adapt_ratio values for these cells, medians:", Jc.groupby("mt").isi_adapt_ratio.median().round(3).to_dict())
for f in ["sag", "isi_adapt_ratio", "latency_rheo", "peak_deltav_rheo"]:
d = C4[[f, "mt"]].dropna()
groups = [d[d.mt == t_][f].values for t_ in d.mt.unique() if (d.mt == t_).sum() > 0]
print(f" KW {f}: p={stats.kruskal(*groups).pvalue:.3g}")
cells by type: {'DBC': 6, 'Sparse SST': 4, 'MC': 3, 'Basket': 1} | metadata (all, with or without a file): {'DBC': 7, 'Sparse SST': 4, 'MC': 3, 'Basket': 1}
specimen_id_x mt sag isi_adapt_ratio latency_rheo latency_hero peak_deltav_rheo peak_deltav_hero adapt_hero
700 1.08e+09 Basket 0.2938 0.9084 0.7294 0.07967 51.59 50.84 -0.00102
124 1.037e+09 DBC 0.4123 3.77 0.0378 0.02032 57.66 59.51 NaN
241 6.893e+08 DBC 0.3764 1.257 0.0856 0.0174 68.59 71.16 0.01234
388 8.558e+08 DBC 0.4648 1.086 0.117 0.0269 64.08 67.14 0.3146
449 8.936e+08 DBC 0.4815 1.189 0.05432 0.026 64.73 64.97 0.1118
460 8.946e+08 DBC 0.5435 1.088 0.01972 0.01304 66.59 67.25 NaN
567 9.669e+08 DBC 0.5728 1.09 0.1278 0.01394 55.3 56.56 0.006474
172 1.069e+09 MC 0.3952 0.929 0.1692 0.0114 86.16 88.88 0.008987
452 8.937e+08 MC 0.5209 1.819 0.07848 0.02562 77.94 78.45 0.04023
459 8.945e+08 MC 0.509 1.372 0.07366 0.02214 84.02 83.14 0.01101
168 1.062e+09 Sparse SST 0.2109 3.121 0.4276 0.02758 59.64 59.34 0.0634
314 8.199e+08 Sparse SST 0.3183 1.672 0.0766 0.02658 82.63 81.85 0.05007
543 9.419e+08 Sparse SST 0.3578 1.344 0.2442 0.03272 74.64 75.37 0.1926
699 1.08e+09 Sparse SST 0.2816 1.823 0.1293 0.04642 67.56 66.38 0.424
sag isi_adapt_ratio latency_rheo latency_hero peak_deltav_rheo peak_deltav_hero adapt_hero
mt
Basket 0.2938 0.9084 0.7294 0.0797 51.5938 50.8438 -0.0010
DBC 0.4731 1.1399 0.0700 0.0189 64.4063 66.0563 0.0621
MC 0.5090 1.3719 0.0785 0.0221 84.0188 83.1375 0.0110
Sparse SST 0.3000 1.7477 0.1868 0.0302 71.1031 70.8719 0.1280
{'sag lower': True, 'adaptation higher': True, 'latency higher (rheo)': True, 'latency higher (hero)': True, 'MC peak highest (rheo)': True, 'MC peak highest (hero)': True}
variant, adapt_hero (adaptation index): sparse higher than DBC and MC: True
variant, the paper's own isi_adapt_ratio values for these cells, medians: {'Basket': 0.833, 'DBC': 1.392, 'MC': 1.927, 'Sparse SST': 3.835}
KW sag: p=0.0293
KW isi_adapt_ratio: p=0.159
KW latency_rheo: p=0.11
KW peak_deltav_rheo: p=0.0317
Result: reproduced, under an assumption, on 14 cells. Sparse SST cells have the lowest median sag (0.300 against 0.473 and 0.509), the highest ISI adaptation ratio (1.75 against 1.14 and 1.37) and the longest latency, and MCs the highest peak, under every reading. The ISI adaptation ratio computed here does not match the paper's definition (27% of cells within 10%). The paper's own values for these cells order the types the same way. No Kruskal-Wallis test of adaptation or latency is significant (p = 0.16 and 0.11).
fig5c-dbc-higher-sag¶
A higher sag ratio is a consistent and prominent feature of all DBCs.
DBCs from dbc_calb1_ADGRG6.csv. Comparison (a) the other cells of SST CALB1 and SST ADGRG6, (b) MC and sparse SST cells of SST CALB1.
E["is_dbc"] = E.patched_cell_container.isin(dbc_yes.Tube_id)
two = E[E.ttype.isin(["Inh L1-3 SST CALB1", "Inh L3-5 SST ADGRG6"])]
dbc_e = two[two.is_dbc]
print("DBCs with a file and sag:", int(dbc_e.sag.notna().sum()), "of", len(dbc_yes), "| sag values", dbc_e.sag.round(3).tolist(), dbc_e.ttype.str[4:].tolist())
comp_a = two[~two.is_dbc]
comp_b = E[(E.ttype == "Inh L1-3 SST CALB1") & E.Qualitative_morphology_type.isin(["MC", "Sparse SST"])]
for name, cmp_ in [("a", comp_a), ("b", comp_b)]:
cm = cmp_.sag.median(); dm = dbc_e.sag.median()
u, p = stats.mannwhitneyu(dbc_e.sag.dropna(), cmp_.sag.dropna(), alternative="two-sided")
print(f"reading {name}: comparison n={cmp_.sag.notna().sum()} median {cm:.3f}; DBC median {dm:.3f}; DBCs above comparison median "
f"{int((dbc_e.sag > cm).sum())} of {int(dbc_e.sag.notna().sum())}; Mann-Whitney p={p:.3g}")
DBCs with a file and sag: 8 of 11 | sag values [0.412, nan, 0.376, 0.564, 0.465, 0.481, 0.544, 0.363, 0.573] ['L1-3 SST CALB1', 'L3-5 SST ADGRG6', 'L1-3 SST CALB1', 'L3-5 SST ADGRG6', 'L1-3 SST CALB1', 'L1-3 SST CALB1', 'L1-3 SST CALB1', 'L3-5 SST ADGRG6', 'L1-3 SST CALB1'] reading a: comparison n=73 median 0.389; DBC median 0.473; DBCs above comparison median 6 of 8; Mann-Whitney p=0.0276 reading b: comparison n=7 median 0.358; DBC median 0.473; DBCs above comparison median 8 of 8; Mann-Whitney p=0.0721
Result: partially reproduced. The DBC median sag (0.473, 8 DBCs) is above both comparison groups. All 8 DBCs are above the median of the MC and sparse SST cells (0.358, reading b). Only 6 of 8 are above the median of the other SST CALB1 and ADGRG6 cells (0.389, reading a; Mann-Whitney p = 0.028).
fig5d-dbc-ephys-intermingled¶
In electrophysiology space, DBCs of the SST CALB1 and SST ADGRG6 types are intermingled with other SST neurons.
SST subclass cells, features z-scored over them; for each DBC, the fraction of its 10 nearest SST neighbours that are DBCs. The SST subclass is Revised_subclass_label, the default the claims file's header sets for the subclass (SST FRZB counted in PVALB); subclass_label (SST FRZB in SST) is shown as a variant, as are the feature sets with the paper's values.
RES5D = {}
for gcol in ["Revised_subclass_label", "subclass_label"]:
S5 = E[E[gcol] == "SST"].copy()
lab5 = np.where(S5.is_dbc, "DBC", "other"); share5 = np.mean(lab5 == "DBC")
print(f"--- SST by {gcol}: {len(S5)} cells, {int(S5.is_dbc.sum())} DBCs, share {share5:.3f}, limit (twice the share) {2 * share5:.3f}")
for fname in (list(RAW) if gcol == "Revised_subclass_label" else ["computed 65"]):
Z5 = L.zscore_impute(RAW[fname].loc[S5.index])
for off in (SEED_OFFSETS if fname == "computed 65" else [0]):
emb = L.umap_embed(Z5, seed("fig5d-dbc-ephys-intermingled") + off)
for space, Xs in ([("features", Z5.values)] if off == 0 else []) + [("umap", emb)]:
qidx, nb = L.neighbour_fraction(Xs, lab5, 10, query=lab5 == "DBC")
fr = np.array([np.mean(n == "DBC") for n in nb])
RES5D[(gcol, fname, off, space)] = bool(fr.mean() <= 2 * share5)
print(f"{fname} seed+{off} {space}: DBCs {len(fr)}, mean DBC fraction among 10 neighbours {fr.mean():.3f}; "
f"ratio to share {fr.mean() / share5:.2f}; holds {fr.mean() <= 2 * share5}")
print("RESULT fig5d-ephys, Revised_subclass_label, computed features, claim's seed: features",
RES5D[("Revised_subclass_label", "computed 65", 0, "features")], "umap", RES5D[("Revised_subclass_label", "computed 65", 0, "umap")])
--- SST by Revised_subclass_label: 158 cells, 9 DBCs, share 0.057, limit (twice the share) 0.114
computed 65 seed+0 features: DBCs 9, mean DBC fraction among 10 neighbours 0.144; ratio to share 2.54; holds False computed 65 seed+0 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.133; ratio to share 2.34; holds False
computed 65 seed+1000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.078; ratio to share 1.37; holds True
computed 65 seed+2000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.111; ratio to share 1.95; holds True
computed 65 seed+3000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.078; ratio to share 1.37; holds True
computed 65 seed+4000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.100; ratio to share 1.76; holds True
paper's table, 84 seed+0 features: DBCs 9, mean DBC fraction among 10 neighbours 0.144; ratio to share 2.54; holds False paper's table, 84 seed+0 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.144; ratio to share 2.54; holds False
computed 65 + paper's 19 seed+0 features: DBCs 9, mean DBC fraction among 10 neighbours 0.156; ratio to share 2.73; holds False computed 65 + paper's 19 seed+0 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.122; ratio to share 2.15; holds False --- SST by subclass_label: 231 cells, 9 DBCs, share 0.039, limit (twice the share) 0.078
computed 65 seed+0 features: DBCs 9, mean DBC fraction among 10 neighbours 0.133; ratio to share 3.42; holds False computed 65 seed+0 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.111; ratio to share 2.85; holds False
computed 65 seed+1000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.144; ratio to share 3.71; holds False
computed 65 seed+2000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.089; ratio to share 2.28; holds False
computed 65 seed+3000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.067; ratio to share 1.71; holds True
computed 65 seed+4000 umap: DBCs 9, mean DBC fraction among 10 neighbours 0.111; ratio to share 2.85; holds False RESULT fig5d-ephys, Revised_subclass_label, computed features, claim's seed: features False umap False
Result: not reproduced. SST is read as Revised_subclass_label, the claims file's default (SST FRZB counted in PVALB): 158 cells with 9 DBCs (share 0.057, limit 0.114). The DBCs have a mean of 0.144 DBCs among their 10 nearest SST neighbours in feature space, 2.54 times their share, above the criterion's 2, under every seed. In the UMAP the ratio is 1.56 under the claim's seed and 1.56 to 2.15 under the five seeds, so the UMAP passes under four and fails under seed +3000. With the paper's table or the paper's 19 features added the ratios are 2.15 to 2.73. Under subclass_label (231 cells) the ratios are 3.42 in feature space and 2.28 to 3.42 in UMAP. With 9 DBCs one shared neighbour moves the mean by 0.011, so the measure is coarse.
figs5-vip-enhancer-enrichment¶
Neurons labelled with the VIP enhancer AAV CN2039 did not map only to VIP types but were strongly enriched for VIP types.
The Virus values are listed first, to check that no label mixes CN2039 with another vector. By Revised_subclass_label; comparison (a) all cells without CN2039, (b) CN1390-only cells; two-sided Fisher exact test (the criterion's choice). Over all labelled cells, and over those with a file in the dandiset as a variant.
print("Virus values of the labelled cells:", m1.Virus.value_counts(dropna=False).to_dict())
print("values containing CN2039:", sorted(set(v for v in m1.Virus.dropna().unique() if "2039" in str(v))))
for name, M in [("all labelled cells", m1), ("cells with a file here", m1[m1.nwb_session.isin(R.session)])]:
vip = M.Revised_subclass_label == "VIP"
cn = M.Virus == "CN2039"
print(f"{name}: CN2039 cells {int(cn.sum())}, VIP among them {int((vip & cn).sum())} ({(vip & cn).sum() / cn.sum():.2f}); subclasses",
M[cn].Revised_subclass_label.value_counts().to_dict())
for rd, other in [("a", ~cn), ("b", M.Virus == "CN1390")]:
tab = [[int((vip & cn).sum()), int((~vip & cn).sum())], [int((vip & other).sum()), int((~vip & other).sum())]]
o, p = stats.fisher_exact(tab)
print(f" reading {rd}: comparison VIP fraction {tab[1][0] / sum(tab[1]):.3f} (n={sum(tab[1])}), odds ratio {o:.2f}, Fisher p={p:.3g}")
Virus values of the labelled cells: {'CN1390': 378, nan: 313, 'CN1827': 33, 'CN2039': 30, 'CN1816': 10, 'CN1817': 3, 'unknown': 3, 'CN1294': 2, 'CN1408': 2, 'CN1366': 2, 'CN1418': 1, 'CN1818': 1}
values containing CN2039: ['CN2039']
all labelled cells: CN2039 cells 30, VIP among them 19 (0.63); subclasses {'VIP': 19, 'PVALB': 8, 'SST': 2, 'LAMP5/PAX6/Other': 1}
reading a: comparison VIP fraction 0.138 (n=748), odds ratio 10.82, Fisher p=1.74e-09
reading b: comparison VIP fraction 0.053 (n=378), odds ratio 30.92, Fisher p=1e-14
cells with a file here: CN2039 cells 30, VIP among them 19 (0.63); subclasses {'VIP': 19, 'PVALB': 8, 'SST': 2, 'LAMP5/PAX6/Other': 1}
reading a: comparison VIP fraction 0.126 (n=660), odds ratio 12.01, Fisher p=4.94e-10
reading b: comparison VIP fraction 0.054 (n=368), odds ratio 30.05, Fisher p=1.6e-14
Result: reproduced. The only Virus value with CN2039 is "CN2039". 19 of 30 CN2039 cells are VIP (0.63), against 0.138 of other cells (Fisher p = 1.7e-09) and 0.053 of CN1390 cells (p = 1e-14). The other 11 are PVALB, SST or LAMP5/PAX6.
Morphology features (elsewhere)¶
The morphology claims are data: elsewhere. They are tested on the paper's morphology feature table (LeeDalley_morpho_features.csv, 140 reconstructions, at commit 5eb357a); the features are not recomputed from the reconstructions at the Brain Image Library.
MF = morph.drop(columns=[c for c in morph.columns if c.startswith("Unnamed")]).merge(
m1, left_on="specimen_id", right_on="specimen_id_x", how="left")
MFEATS = [c for c in morph.columns if c not in ("specimen_id",) and not c.startswith("Unnamed")]
print("reconstructions", len(MF), "| labelled", int(MF.specimen_id_x.notna().sum()), "| features", len(MFEATS))
print("by subclass:", MF.Revised_subclass_label.value_counts().to_dict())
print("soma depth range (um):", MF.soma_aligned_dist_from_pia.min().round(1), MF.soma_aligned_dist_from_pia.max().round(1))
reconstructions 140 | labelled 140 | features 51
by subclass: {'PVALB': 62, 'SST': 35, 'VIP': 30, 'LAMP5/PAX6/Other': 13}
soma depth range (um): 147.3 2609.5
fig4a-calb1-morphology-types¶
The SST CALB1 t-type contains four qualitative morphology types, Martinotti cells, double bouquet cells, one basket-like cell and sparse SST cells.
Blocked: two of the criterion's four traits (MC axon in L1 against below the soma layer; the basket-like cell with the least L1 axon) need axon length by layer, which the feature table does not hold (its columns are listed in the cell above). The other two are tested here on the table: DBCs have the narrowest axon extent relative to dendrite width (axon_over_basal_dendrite_extent_x), and sparse SST cells have fewer axon branches per length than MCs (axon_num_branches over axon_total_length; the table's axon_branch_freq as a second reading).
print("feature table columns:", MFEATS)
C4m = MF[MF.Transcriptomic_type == "Inh L1-3 SST CALB1"].copy()
C4m["mt"] = C4m.Qualitative_morphology_type.fillna("none")
C4m["branches_per_mm"] = C4m.axon_num_branches / C4m.axon_total_length * 1000
cols4a = ["axon_over_basal_dendrite_extent_x", "axon_extent_x", "basal_dendrite_extent_x", "axon_num_branches", "axon_total_length", "branches_per_mm", "axon_branch_freq"]
print("SST CALB1 reconstructions by type:", C4m.mt.value_counts().to_dict())
print(C4m[["specimen_id", "mt"] + cols4a].sort_values("mt").to_string(float_format=lambda v: f"{v:.4g}"))
med4a = C4m.groupby("mt")[cols4a].median()
print(med4a.round(4).to_string())
print("RESULT fig4a, testable parts: DBC narrowest axon/dendrite extent ratio:", med4a.axon_over_basal_dendrite_extent_x.idxmin() == "DBC",
"| sparse SST fewer branches per mm than MC:", bool(med4a.loc["Sparse SST", "branches_per_mm"] < med4a.loc["MC", "branches_per_mm"]),
"| by axon_branch_freq:", bool(med4a.loc["Sparse SST", "axon_branch_freq"] < med4a.loc["MC", "axon_branch_freq"]))
feature table columns: ['axon_bias_x', 'axon_bias_y', 'axon_depth_pc_0', 'axon_depth_pc_1', 'axon_depth_pc_2', 'axon_depth_pc_3', 'axon_emd_with_basal_dendrite', 'axon_exit_distance', 'axon_exit_theta', 'axon_extent_x', 'axon_extent_y', 'axon_frac_above_basal_dendrite', 'axon_frac_below_basal_dendrite', 'axon_frac_intersect_basal_dendrite', 'axon_max_branch_order', 'axon_max_euclidean_distance', 'axon_max_path_distance', 'axon_mean_contraction', 'axon_num_branches', 'axon_soma_percentile_x', 'axon_soma_percentile_y', 'axon_total_length', 'basal_dendrite_bias_x', 'basal_dendrite_bias_y', 'basal_dendrite_calculate_number_of_stems', 'basal_dendrite_extent_x', 'basal_dendrite_extent_y', 'basal_dendrite_frac_above_axon', 'basal_dendrite_frac_below_axon', 'basal_dendrite_frac_intersect_axon', 'basal_dendrite_max_branch_order', 'basal_dendrite_max_euclidean_distance', 'basal_dendrite_max_path_distance', 'basal_dendrite_mean_contraction', 'basal_dendrite_mean_diameter', 'basal_dendrite_num_branches', 'basal_dendrite_soma_percentile_x', 'basal_dendrite_soma_percentile_y', 'basal_dendrite_stem_exit_down', 'basal_dendrite_stem_exit_side', 'basal_dendrite_stem_exit_up', 'basal_dendrite_total_length', 'basal_dendrite_total_surface_area', 'soma_surface', 'soma_aligned_dist_from_pia', 'axon_over_basal_dendrite_extent_x', 'axon_over_basal_dendrite_extent_y', 'axon_extent_x_over_y', 'basal_dendrite_extent_x_over_y', 'axon_over_basal_dendrite_ratio_xy', 'axon_branch_freq']
SST CALB1 reconstructions by type: {'DBC': 7, 'none': 6, 'Sparse SST': 4, 'MC': 3, 'Basket': 1}
specimen_id mt axon_over_basal_dendrite_extent_x axon_extent_x basal_dendrite_extent_x axon_num_branches axon_total_length branches_per_mm axon_branch_freq
139 1079573757 Basket 1.554 848.9 546.4 271 2.742e+04 9.882 0.9882
118 1037452707 DBC 1.909 383.4 200.8 335 2.64e+04 12.69 1.269
112 966905488 DBC 4.438 360.4 81.21 141 9647 14.62 1.462
93 893647190 DBC 1.676 335.3 200.1 229 1.581e+04 14.49 1.449
82 855783147 DBC 2.943 524 178 225 1.926e+04 11.68 1.168
5 681546151 DBC 1.114 230.4 206.8 157 9807 16.01 1.601
11 689306781 DBC 2.323 426.1 183.4 323 2.036e+04 15.87 1.587
97 894610619 DBC 1.529 312.4 204.4 165 1.395e+04 11.83 1.183
94 893714311 MC 1.673 321.4 192.1 99 7317 13.53 1.353
96 894528079 MC 2.635 435.6 165.3 151 1.107e+04 13.64 1.364
134 1069242387 MC 2.583 466.5 180.6 255 2.008e+04 12.7 1.27
67 819891764 Sparse SST 2.406 977.1 406.1 143 1.779e+04 8.04 0.804
138 1079568285 Sparse SST 2.391 1111 464.4 119 1.571e+04 7.574 0.7574
107 941862585 Sparse SST 2.348 1176 500.6 85 1.457e+04 5.835 0.5835
129 1061696800 Sparse SST 8.504 2154 253.3 115 2e+04 5.751 0.5751
60 819194697 none 0.6861 189.9 276.8 67 5937 11.28 1.128
106 941707648 none 1.357 406.6 299.5 139 1.274e+04 10.91 1.091
42 759960718 none 5.347 325.3 60.83 69 5922 11.65 1.165
115 1002962250 none 3.12 461.5 147.9 178 1.292e+04 13.78 1.378
128 1060169142 none 1.424 247.1 173.5 95 6340 14.98 1.498
72 848629140 none 2.741 446.2 162.8 77 6117 12.59 1.259
axon_over_basal_dendrite_extent_x axon_extent_x basal_dendrite_extent_x axon_num_branches axon_total_length branches_per_mm axon_branch_freq
mt
Basket 1.5537 848.9294 546.4077 271.0 27422.7756 9.8823 0.9882
DBC 1.9094 360.4189 200.1342 225.0 15807.0910 14.4872 1.4487
MC 2.5830 435.5505 180.5913 151.0 11067.4611 13.5293 1.3529
Sparse SST 2.3985 1143.0748 435.2694 117.0 16748.5045 6.7046 0.6705
none 2.0826 365.9061 168.1444 86.0 6228.4843 12.1198 1.2120
RESULT fig4a, testable parts: DBC narrowest axon/dendrite extent ratio: False | sparse SST fewer branches per mm than MC: True | by axon_branch_freq: True
Result: partially reproduced, on two of the four traits. The table holds the four types (7 DBC, 3 MC, 4 sparse SST, 1 basket). Sparse SST cells have fewer axon branches per length than MCs (median 6.7 against 13.5 per mm; axon_branch_freq 0.67 against 1.35). DBCs do not have the narrowest axon extent relative to dendrite width: their median ratio (1.91) is below MC (2.58) and sparse SST (2.40) but above the one basket cell (1.55). The two traits about axon in L1 need the layer-aligned reconstructions and were not tested.
fig1g-wfdc2-morphology-unchanged¶
Fifty morphological features of depth-matched PVALB WFDC2 neurons do not differ between culture (n = 9) and acute (n = 10) slices.
Mann-Whitney per feature, BH over the 50 features (the 51 columns less soma depth, used for matching). Readings: (a) all PVALB WFDC2 reconstructions, (b) depth-matched, here the cells inside the depth range both groups share, (c) nearest-depth pairs.
MW_ = MF[MF.Transcriptomic_type == "Inh L2-4 PVALB WFDC2"].copy()
F50 = [c for c in MFEATS if c != "soma_aligned_dist_from_pia"]
print("PVALB WFDC2 reconstructions:", MW_.condition.value_counts().to_dict(), "| features", len(F50))
print(MW_.groupby("condition").soma_aligned_dist_from_pia.describe().round(1))
lo_d = MW_.groupby("condition").soma_aligned_dist_from_pia.min().max(); hi_d = MW_.groupby("condition").soma_aligned_dist_from_pia.max().min()
rb = MW_[MW_.soma_aligned_dist_from_pia.between(lo_d, hi_d)]
cu = MW_[MW_.condition == "culture"]; ac = MW_[MW_.condition == "acute"].copy()
pick = []
for _, r_ in cu.sort_values("soma_aligned_dist_from_pia").iterrows():
j = (ac.soma_aligned_dist_from_pia - r_.soma_aligned_dist_from_pia).abs().drop(pick, errors="ignore").idxmin(); pick.append(j)
rc = pd.concat([cu, ac.loc[pick]])
for name, d in [("a all", MW_), ("b shared depth range", rb), ("c nearest-depth pairs", rc)]:
tt = L.mannwhitney_table(d, F50, "condition", "acute", "culture")
print(f"reading {name}: acute {int((d.condition == 'acute').sum())}, culture {int((d.condition == 'culture').sum())}; "
f"features with FDR p < 0.05: {int((tt.p_fdr < 0.05).sum())}; smallest FDR p {tt.p_fdr.min():.3g}; smallest raw p {tt.p.min():.3g} ({tt.loc[tt.p.idxmin(), 'feature']})")
PVALB WFDC2 reconstructions: {'acute': 16, 'culture': 10} | features 50
count mean std min 25% 50% 75% max
condition
acute 16.0 855.9 294.4 410.2 620.9 836.7 1124.5 1338.4
culture 10.0 598.5 173.9 407.1 475.4 534.6 713.4 877.3
reading a all: acute 16, culture 10; features with FDR p < 0.05: 0; smallest FDR p 0.117; smallest raw p 0.0029 (soma_surface)
reading b shared depth range: acute 9, culture 9; features with FDR p < 0.05: 0; smallest FDR p 0.202; smallest raw p 0.00619 (soma_surface)
reading c nearest-depth pairs: acute 10, culture 10; features with FDR p < 0.05: 0; smallest FDR p 0.0903; smallest raw p 0.00361 (basal_dendrite_bias_x)
Result: reproduced. No morphology feature differs at FDR p < 0.05 between acute and culture PVALB WFDC2 cells under any reading (smallest FDR p 0.09 to 0.20). The table holds 16 acute and 10 culture reconstructions, against the paper's 10 and 9.
fig2c-morph-umap-subclasses¶
The four subclasses are separable in morphological feature space, PVALB the most distinct.
As fig2b-ephys-umap-subclasses on the morphology features of the 140 reconstructed neurons.
ZM = L.zscore_impute(MF[MFEATS]); labM = MF.Revised_subclass_label.values
shareM = pd.Series(labM).value_counts(normalize=True)
for off in SEED_OFFSETS:
emb = L.umap_embed(ZM, seed("fig2c-morph-umap-subclasses") + off)
for space, Xs in ([("features", ZM.values)] if off == 0 else []) + [("umap", emb)]:
qidx, nb = L.neighbour_fraction(Xs, labM, 15)
same = pd.Series([np.mean(n == labM[q]) for q, n in zip(qidx, nb)]).groupby(labM[qidx]).mean()
tab = pd.DataFrame({"same_fraction": same, "share": shareM, "excess": same - shareM})
ok = bool((tab.excess >= 0.2).all() and tab.same_fraction.idxmax() == "PVALB")
print(f"seed+{off} {space}: ok={ok}"); print(tab.round(3).to_string())
seed+0 features: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.195 0.093 0.102
PVALB 0.782 0.443 0.339
SST 0.474 0.250 0.224
VIP 0.407 0.214 0.192
seed+0 umap: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.344 0.093 0.251
PVALB 0.746 0.443 0.303
SST 0.398 0.250 0.148
VIP 0.507 0.214 0.292
seed+1000 umap: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.395 0.093 0.302
PVALB 0.726 0.443 0.283
SST 0.448 0.250 0.198
VIP 0.491 0.214 0.277
seed+2000 umap: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.313 0.093 0.220
PVALB 0.730 0.443 0.287
SST 0.419 0.250 0.169
VIP 0.520 0.214 0.306
seed+3000 umap: ok=False
same_fraction share excess
LAMP5/PAX6/Other 0.369 0.093 0.276
PVALB 0.733 0.443 0.290
SST 0.400 0.250 0.150
VIP 0.529 0.214 0.315
seed+4000 umap: ok=True
same_fraction share excess
LAMP5/PAX6/Other 0.374 0.093 0.282
PVALB 0.732 0.443 0.289
SST 0.459 0.250 0.209
VIP 0.538 0.214 0.323
Result: partially reproduced. PVALB has the highest same-subclass fraction in both spaces and every seed (0.78 in feature space, 0.72 to 0.75 in UMAP). In feature space LAMP5/PAX6 (13 cells) exceed their share by only 0.10 and VIP by 0.19, under the 0.2 the criterion asks. In UMAP SST exceeds its share by 0.175 under the claim's seed and 0.137 to 0.213 over the five seeds; all four pass under one seed (+2000).
fig2e-lamp5-shortest-extent¶
LAMP5/PAX6 neurons have the shortest soma-to-branch-tip Euclidean distance for both axon and dendrite.
MF["subclass"] = MF.Revised_subclass_label
for f in ["axon_max_euclidean_distance", "basal_dendrite_max_euclidean_distance"]:
p, dunn, med = kd_report(MF, f, "subclass", SUBS)
print(f" lowest median: {med['median'].idxmin()}")
--- axon_max_euclidean_distance: KW p=4.63e-06
subclass LAMP5/PAX6/Other PVALB SST VIP
median 434.18834 639.34749 920.40402 706.62059
count 13.00000 62.00000 35.00000 30.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.0003 1.6e-06 0.00079
VIP 0.0003 1 0.15 0.35
SST 1.6e-06 0.15 1 0.0079
PVALB 0.00079 0.35 0.0079 1
lowest median: LAMP5/PAX6/Other
--- basal_dendrite_max_euclidean_distance: KW p=0.000237
subclass LAMP5/PAX6/Other PVALB SST VIP
median 171.2305 348.39454 299.9863 345.33533
count 13.0000 62.00000 35.0000 30.00000
Dunn FDR p:
LAMP5/PAX6/Other VIP SST PVALB
LAMP5/PAX6/Other 1 0.004 0.053 0.00035
VIP 0.004 1 0.15 0.47
SST 0.053 0.15 1 0.021
PVALB 0.00035 0.47 0.021 1
lowest median: LAMP5/PAX6/Other
Result: reproduced. LAMP5/PAX6 have the lowest median axon (434 um) and dendrite (171 um) maximum Euclidean distance, with Kruskal-Wallis p = 4.6e-06 and 2.4e-04.
fig3g-frzb-morphology-like-pvalb¶
SST FRZB neurons overlap more with PVALB than with SST neurons in morphology space, their horizontal axon extent and axon versus dendrite earth mover's distance resemble PVALB basket cells, and in co-clustering they fall more often into PVALB-dominated types.
Kruskal-Wallis with Dunn (BH-FDR) for axon_extent_x and axon_emd_with_basal_dendrite; co-clustering as the Methods (95% subsamples, shared nearest neighbour graph, fast-greedy, 500 resamplings, Ward linkage on the co-clustering matrix, cut at six clusters), with 10 and 20 graph neighbours. A cluster is PVALB- or SST-dominated by the majority subclass_label of its cells other than SST FRZB.
M3 = MF[MF.subclass_label.isin(["SST", "PVALB"])].copy()
M3["grp"] = np.where(M3.Transcriptomic_type == "Inh L2-4 SST FRZB", "SST FRZB", M3.subclass_label)
print("groups:", M3.grp.value_counts().to_dict())
r3g = {}
for f in ["axon_extent_x", "axon_emd_with_basal_dendrite"]:
p, dunn, med = kd_report(M3, f, "grp", G3)
m_ = med["median"]
r3g[f] = (bool(abs(m_["SST FRZB"] - m_["PVALB"]) < abs(m_["SST FRZB"] - m_["SST"])), float(dunn.loc["SST", "SST FRZB"]))
print("nearer PVALB, Dunn SST vs FRZB p:", r3g)
import igraph as ig
from scipy.cluster.hierarchy import linkage, fcluster
from scipy.spatial.distance import squareform
Z3m = L.zscore_impute(M3[MFEATS]).values
def snn_fastgreedy(Xs, k):
from sklearn.neighbors import NearestNeighbors
_, ind = NearestNeighbors(n_neighbors=k + 1).fit(Xs).kneighbors(Xs)
sets = [set(r) for r in ind]
edges, w = [], []
for i in range(len(Xs)):
for j in ind[i][1:]:
if i < j or i not in ind[j]:
s = len(sets[i] & sets[j]) / len(sets[i] | sets[j])
if s > 0 and (min(i, j), max(i, j)) not in edges:
edges.append((min(i, j), max(i, j))); w.append(s)
g_ = ig.Graph(n=len(Xs), edges=edges); g_.es["weight"] = w
return np.array(g_.community_fastgreedy(weights="weight").as_clustering().membership)
for off in SEED_OFFSETS:
rng = np.random.default_rng(seed("fig3g-frzb-morphology-like-pvalb") + off)
for k in [10, 20]:
n = len(Z3m); co = np.zeros((n, n)); both = np.zeros((n, n))
for _ in range(500):
idx = np.sort(rng.choice(n, int(round(0.95 * n)), replace=False))
lab_ = snn_fastgreedy(Z3m[idx], k)
same = (lab_[:, None] == lab_[None, :]).astype(float)
co[np.ix_(idx, idx)] += same; both[np.ix_(idx, idx)] += 1
C = co / np.maximum(both, 1)
dist = 1 - C; np.fill_diagonal(dist, 0)
cl = fcluster(linkage(squareform(dist, checks=False), "ward"), 6, "maxclust")
M3["cl"] = cl
dom = M3[M3.grp != "SST FRZB"].groupby("cl").subclass_label.agg(lambda s: s.value_counts().idxmax() if len(s) else "none")
fz = M3[M3.grp == "SST FRZB"].cl.map(dom).fillna("none").value_counts().to_dict()
if off == 0:
print(f"k={k}:"); print(pd.crosstab(M3.cl, M3.grp))
print(f"seed+{off} k={k}: SST FRZB cells by cluster dominance {fz}")
groups: {'PVALB': 48, 'SST': 35, 'SST FRZB': 14}
--- axon_extent_x: KW p=1e-05
grp PVALB SST SST FRZB
median 910.32308 435.55054 854.81462
count 48.00000 35.00000 14.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 0.00079 2.7e-05
SST FRZB 0.00079 1 0.72
PVALB 2.7e-05 0.72 1
--- axon_emd_with_basal_dendrite: KW p=1.69e-06
grp PVALB SST SST FRZB
median 15.77902 43.9332 15.65133
count 48.00000 35.0000 14.00000
Dunn FDR p:
SST SST FRZB PVALB
SST 1 0.00056 3.6e-06
SST FRZB 0.00056 1 0.88
PVALB 3.6e-06 0.88 1
nearer PVALB, Dunn SST vs FRZB p: {'axon_extent_x': (True, 0.000794331240533727), 'axon_emd_with_basal_dendrite': (True, 0.0005596008031723634)}
k=10:
grp PVALB SST SST FRZB
cl
1 3 1 0
2 1 1 0
3 2 23 2
4 22 7 3
5 7 1 8
6 13 2 1
seed+0 k=10: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
k=20:
grp PVALB SST SST FRZB
cl
1 2 1 0
2 4 25 2
3 34 5 3
4 3 1 4
5 4 1 5
6 1 2 0
seed+0 k=20: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+1000 k=10: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+1000 k=20: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+2000 k=10: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+2000 k=20: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+3000 k=10: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+3000 k=20: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+4000 k=10: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
seed+4000 k=20: SST FRZB cells by cluster dominance {'PVALB': 12, 'SST': 2}
Result: reproduced. SST FRZB medians of axon_extent_x (855) and axon_emd_with_basal_dendrite (15.7) are near PVALB (910, 15.8) and differ from SST (Dunn's p 0.0008 and 0.0006). In co-clustering, 12 of 14 SST FRZB cells fall in PVALB-dominated clusters, for 10 and 20 neighbours and all five seeds.
fig1h-wfdc2-morph-umap-overlap¶
In morphological UMAP space, culture and acute PVALB WFDC2 neurons occupy similar space in the PVALB-rich portion.
The measure of fig1i-wfdc2-ephys-umap-overlap with 5 neighbours on all reconstructions (z-scored morphology features); PVALB-rich part: most of each PVALB WFDC2 cell's 5 nearest neighbours among all cells are PVALB, for most cells of each group. Groups: all PVALB WFDC2 reconstructions, and the shared-depth subset of fig1g.
labC = MF.condition.values
labSub = MF.Revised_subclass_label.values
for setname, ids in [("all PVALB WFDC2", MW_.specimen_id), ("shared depth range", rb.specimen_id)]:
maskM = MF.specimen_id.isin(ids).values
for off in SEED_OFFSETS:
emb = L.umap_embed(ZM, seed("fig1h-wfdc2-morph-umap-overlap") + off)
rng = np.random.default_rng(seed("fig1h-wfdc2-morph-umap-overlap", 1) + off)
for space, Xs in ([("features", ZM.values)] if off == 0 else []) + [("umap", emb)]:
ov = overlap_test(Xs, labC, maskM, 5, rng)
qidx, nb = L.neighbour_fraction(Xs, labSub, 5, query=maskM)
pv = np.array([np.mean(n == "PVALB") for n in nb]) > 0.5
rich = {g_: pv[labC[qidx] == g_].mean() for g_ in ["acute", "culture"]}
ok = all(o >= 0.5 * n_ for o, n_ in ov.values()) and all(v > 0.5 for v in rich.values())
print(f"{setname} seed+{off} {space}: " + ", ".join(f"{g_} cross {o:.2f} vs shuffle {n_:.2f}" for g_, (o, n_) in ov.items())
+ f"; PVALB-majority fraction {({k: round(v, 2) for k, v in rich.items()})}; holds {ok}")
all PVALB WFDC2 seed+0 features: acute cross 0.36 vs shuffle 0.40, culture cross 0.56 vs shuffle 0.64; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(1.0)}; holds True
all PVALB WFDC2 seed+0 umap: acute cross 0.40 vs shuffle 0.41, culture cross 0.60 vs shuffle 0.64; PVALB-majority fraction {'acute': np.float64(0.94), 'culture': np.float64(1.0)}; holds True
all PVALB WFDC2 seed+1000 umap: acute cross 0.35 vs shuffle 0.40, culture cross 0.66 vs shuffle 0.66; PVALB-majority fraction {'acute': np.float64(0.81), 'culture': np.float64(1.0)}; holds True
all PVALB WFDC2 seed+2000 umap: acute cross 0.33 vs shuffle 0.40, culture cross 0.74 vs shuffle 0.64; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(0.9)}; holds True
all PVALB WFDC2 seed+3000 umap: acute cross 0.34 vs shuffle 0.40, culture cross 0.66 vs shuffle 0.64; PVALB-majority fraction {'acute': np.float64(0.94), 'culture': np.float64(1.0)}; holds True
all PVALB WFDC2 seed+4000 umap: acute cross 0.40 vs shuffle 0.41, culture cross 0.66 vs shuffle 0.64; PVALB-majority fraction {'acute': np.float64(0.88), 'culture': np.float64(0.9)}; holds True
shared depth range seed+0 features: acute cross 0.60 vs shuffle 0.53, culture cross 0.53 vs shuffle 0.53; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(1.0)}; holds True
shared depth range seed+0 umap: acute cross 0.58 vs shuffle 0.53, culture cross 0.58 vs shuffle 0.53; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(1.0)}; holds True
shared depth range seed+1000 umap: acute cross 0.49 vs shuffle 0.53, culture cross 0.58 vs shuffle 0.53; PVALB-majority fraction {'acute': np.float64(0.89), 'culture': np.float64(1.0)}; holds True
shared depth range seed+2000 umap: acute cross 0.60 vs shuffle 0.53, culture cross 0.64 vs shuffle 0.53; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(0.89)}; holds True
shared depth range seed+3000 umap: acute cross 0.51 vs shuffle 0.53, culture cross 0.64 vs shuffle 0.53; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(1.0)}; holds True
shared depth range seed+4000 umap: acute cross 0.56 vs shuffle 0.53, culture cross 0.60 vs shuffle 0.53; PVALB-majority fraction {'acute': np.float64(1.0), 'culture': np.float64(0.89)}; holds True
Result: reproduced. Acute and culture PVALB WFDC2 reconstructions are mixed: cross-group fractions are 0.30 to 0.72 against shuffled 0.40 to 0.66, at least half the shuffle in every case. In both cell sets, both spaces and all five seeds, at least 88% of the cells of each condition have a PVALB majority among their 5 nearest neighbours.
fig5d-dbc-morph-umap¶
In morphological UMAP space, DBCs of the SST CALB1 and SST ADGRG6 types cluster near each other.
SST subclass reconstructions, z-scored, with the SST subclass read as Revised_subclass_label (the claims file's default) and subclass_label as a variant; for each DBC, the fraction of its 5 nearest SST neighbours that are DBCs; reproduced when the mean is at least twice the DBC share.
RES5DM = {}
for gcol in ["Revised_subclass_label", "subclass_label"]:
MS = MF[MF[gcol] == "SST"].copy()
MS["is_dbc"] = MS.patched_cell_container.isin(dbc_yes.Tube_id)
ZS = L.zscore_impute(MS[MFEATS]); labD = np.where(MS.is_dbc, "DBC", "other"); shareD = np.mean(labD == "DBC")
ttD = MS.Transcriptomic_type.values
print(f"--- SST by {gcol}: {len(MS)} reconstructions, {int(MS.is_dbc.sum())} DBCs, share {shareD:.3f}, threshold (twice the share) {2 * shareD:.3f}")
for off in SEED_OFFSETS:
emb = L.umap_embed(ZS, seed("fig5d-dbc-morph-umap") + off)
for space, Xs in ([("features", ZS.values)] if off == 0 else []) + [("umap", emb)]:
qidx, nb = L.neighbour_fraction(Xs, labD, 5, query=labD == "DBC")
fr = np.array([np.mean(n == "DBC") for n in nb])
_, nbt = L.neighbour_fraction(Xs, ttD, 5, among=labD == "DBC", query=labD == "DBC")
own_tt = np.mean([np.mean(n == ttD[q]) for q, n in zip(qidx, nbt)])
RES5DM[(gcol, off, space)] = bool(fr.mean() >= 2 * shareD)
print(f"seed+{off} {space}: mean DBC fraction {fr.mean():.3f}, ratio {fr.mean() / shareD:.2f}, holds {fr.mean() >= 2 * shareD}; "
f"own t-type among DBC neighbours {own_tt:.2f}")
print("RESULT fig5d-morph, Revised_subclass_label, claim's seed: features", RES5DM[("Revised_subclass_label", 0, "features")],
"umap", RES5DM[("Revised_subclass_label", 0, "umap")])
--- SST by Revised_subclass_label: 35 reconstructions, 11 DBCs, share 0.314, threshold (twice the share) 0.629 seed+0 features: mean DBC fraction 0.800, ratio 2.55, holds True; own t-type among DBC neighbours 0.49 seed+0 umap: mean DBC fraction 0.509, ratio 1.62, holds False; own t-type among DBC neighbours 0.56 seed+1000 umap: mean DBC fraction 0.509, ratio 1.62, holds False; own t-type among DBC neighbours 0.58 seed+2000 umap: mean DBC fraction 0.582, ratio 1.85, holds False; own t-type among DBC neighbours 0.49
seed+3000 umap: mean DBC fraction 0.545, ratio 1.74, holds False; own t-type among DBC neighbours 0.51
seed+4000 umap: mean DBC fraction 0.527, ratio 1.68, holds False; own t-type among DBC neighbours 0.47 --- SST by subclass_label: 49 reconstructions, 11 DBCs, share 0.224, threshold (twice the share) 0.449 seed+0 features: mean DBC fraction 0.782, ratio 3.48, holds True; own t-type among DBC neighbours 0.49 seed+0 umap: mean DBC fraction 0.509, ratio 2.27, holds True; own t-type among DBC neighbours 0.60 seed+1000 umap: mean DBC fraction 0.473, ratio 2.11, holds True; own t-type among DBC neighbours 0.62
seed+2000 umap: mean DBC fraction 0.600, ratio 2.67, holds True; own t-type among DBC neighbours 0.55
seed+3000 umap: mean DBC fraction 0.400, ratio 1.78, holds False; own t-type among DBC neighbours 0.60 seed+4000 umap: mean DBC fraction 0.382, ratio 1.70, holds False; own t-type among DBC neighbours 0.56 RESULT fig5d-morph, Revised_subclass_label, claim's seed: features True umap False
Result: not reproduced (rests on an assumption). SST is read as Revised_subclass_label: 35 reconstructions with 11 DBCs (share 0.314, threshold 0.629). In feature space DBCs have a mean of 0.80 DBCs among their 5 nearest SST neighbours (2.55 times their share), which passes. In UMAP the fraction is 0.40 to 0.53 under all five seeds (ratio 1.27 to 1.68), under the threshold. Under subclass_label (49 reconstructions, share 0.224) the feature space passes (ratio 3.48) and the UMAP passes under three seeds, the claim's among them (ratio 2.02), and fails under two (1.54, 1.62). Among a DBC's DBC neighbours, 0.45 to 0.60 share its t-type. UMAP numbers differ between machines under the same seed: in the executed copy the third verification round reviewed, the UMAP ratios were 1.62 to 1.85 under the revised label, and 2.27 under the claim's seed and 1.78 and 1.70 under the two failing seeds under subclass_label, with the same outcome under each reading.
The claims file's default subclass is stated for the electrophysiology claims, so it does not fix the subclass here, and the outcome differs between the two readings. The paper supports the revised label: after moving SST FRZB to PVALB it says "This assignment has been applied for subclass-level analyses" (Results, section "Revising subclass assignment based on multimodal data", last paragraph), and the electrophysiology panel of the same figure is tested with it (fig5d-dbc-ephys-intermingled). Under that reading the UMAP fails under every seed, and the criterion asks for both spaces with no partial case, so the outcome is not reproduced. The third verification round agreed.
Summary¶
| Claim | Outcome |
|---|---|
| cell-metadata-link | reproduced |
| dataset-composition | partially reproduced |
| fig1b-more-genes-in-culture | reproduced |
| figs1a-genes-across-days | partially reproduced |
| fig1d-nms-no-difference | reproduced |
| fig1c-marker-expression-correlated | reproduced (assumption) |
| figs1-microglial-signature | blocked (methods underspecified) |
| figs2d-seven-channel-genes | blocked (other) |
| fig5a-dbc-two-ttypes | reproduced |
| figs7a-dbc-regions | reproduced |
| figs7a-dbc-markers | reproduced |
| fig4d-calb1-genes-by-morphology | not reproduced |
| figs2b-wfdc2-ephys-43-of-84 | blocked (methods underspecified) |
| fig1l-width-sag-differ | blocked (methods underspecified) |
| figs2c-no-change-with-days | blocked (methods underspecified) |
| fig1i-wfdc2-ephys-umap-overlap | not reproduced |
| fig2b-ephys-umap-subclasses | blocked (methods underspecified) |
| fig2f-ap-kinetics | partially reproduced |
| fig2g-sag-by-subclass | reproduced |
| fig2h-several-features-distinct | reproduced |
| fig3c-frzb-ephys-with-pvalb | reproduced |
| fig3e-frzb-ap-like-pvalb | reproduced |
| figs6-sst-features-acute-culture | reproduced |
| fig4c-calb1-ephys-by-morphology | reproduced (assumption) |
| fig5c-dbc-higher-sag | partially reproduced |
| fig4a-calb1-morphology-types | partially reproduced (two of four traits tested) |
| fig5d-dbc-ephys-intermingled | not reproduced |
| figs5-vip-enhancer-enrichment | reproduced |
| fig1g-wfdc2-morphology-unchanged | reproduced |
| fig2c-morph-umap-subclasses | partially reproduced |
| fig2e-lamp5-shortest-extent | reproduced |
| fig3g-frzb-morphology-like-pvalb | reproduced |
| fig1h-wfdc2-morph-umap-overlap | reproduced |
| fig5d-dbc-morph-umap | not reproduced (assumption) |
| fig1e, figs1de, fig2a, fig3-frzb-transcriptome, fig5b, fig5e, fig6b (7) | blocked |
| mouse-label-link, fig6c, fig6e, figs8b, figs9 | see species_lee_2023.ipynb |
After the third verification round fig2b-ephys-umap-subclasses is blocked and fig5d-dbc-morph-umap is not reproduced, as proposed after the second round.
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
How the analysis differs from the paper's. 19 of the 84 electrophysiology features need code the paper has not released, so the multivariate measures use the 65 that public IPFX computes. The paper's own 84-feature table, used as a variant, changes the outcome of fig1i (it passes narrowly) and of the feature-space part of fig2b (it passes), so these two depend on how the features are computed; fig2b is blocked for this reason. Cell-level QC (seal, access resistance) is not recomputed. The sweep QC of the Methods is applied, and non-positive input resistance or width values (4) are set missing. Seurat's microglial clustering is run with a Python substitute. The UMAP claims are judged by the neighbour measures the claims file fixes, not by the paper's plots. UMAP embeddings differ between runs on different machines under the same seed and lock file (umap-learn and its nearest-neighbour search), so UMAP numbers can differ in another run of this notebook. In the run before the second verification, on another machine, the UMAP numbers differed (for example the fig5d-dbc-ephys UMAP ratio under the claim's seed was 2.34, here 1.56), and no outcome changed. The morphology claims use the paper's feature table. The Seurat integration analyses are not run.
What was found about the dataset. The files can be linked to the paper's tables through nwb_id, and the features computed from them match the paper's table for most cells. 16 files have no row in the paper's metadata, 20 rows with electrophysiology have no file, and the archive's summary gives 616 cells for 706 one-cell files. 79 files have sweeps sampled at 200 kHz where the Methods state 50 kHz. The files carry no cell type, region, layer, condition or days in culture, so every label comes from the code repository. Species is written two ways. In the paper's own tables, the microglial calls (condition2) call a larger fraction of acute (0.418) than of culture (0.385) cells microglial.
print(f"notebook runtime {(time.time() - T0) / 60:.1f} min; peak memory of this process {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
notebook runtime 25.4 min; peak memory of this process 2.04 GB